/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #3A7D44;
  --green-dark:   #2E6235;
  --green-light:  #EAF4EC;
  --orange:       #E07B1A;
  --orange-dark:  #C46A10;
  --orange-light: #FEF3E7;
  --navy:         #1B3A5C;
  --text:         #1A2332;
  --text-muted:   #5A6A7A;
  --border:       #D8E2EC;
  --bg:           #F0F4F8;
  --white:        #FFFFFF;
  --radius:       12px;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 6px 24px rgba(0,0,0,0.14);
  --transition:   0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 72px;
  overflow-x: hidden;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== NAVBAR ===== */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.logo-icon svg { width: 38px; height: 38px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.25; }
.logo-name { font-size: 16px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; }
.logo-sub  { font-size: 11px; font-weight: 500; color: var(--text-muted); }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--navy); background: var(--bg); }
.nav-link.active { color: var(--navy); font-weight: 700; border-bottom-color: var(--navy); border-radius: 6px 6px 0 0; background: transparent; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.hamburger span { display: block; width: 24px; height: 2px; background: var(--navy); border-radius: 2px; transition: all 0.3s ease; }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 8px 0;
}
.mobile-menu.open { display: flex; }
.mobile-link {
  text-decoration: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 20px;
  cursor: pointer;
  transition: background var(--transition);
}
.mobile-link:hover, .mobile-link.active { background: var(--bg); color: var(--navy); font-weight: 600; }

/* ===== SPA PAGE TRANSITIONS ===== */
.page-wrapper { position: relative; }

.page {
  display: none;
  opacity: 0;
  transform: translateY(12px);
  padding: 28px 0 40px;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.page.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}
.page.entering {
  display: block;
  opacity: 0;
  transform: translateY(12px);
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.btn-back {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-back svg { width: 16px; height: 16px; }
.btn-back:hover { background: var(--bg); color: var(--navy); border-color: var(--navy); }

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.page-title-icon.green { background: var(--green-light); color: var(--green); }
.page-title-icon.orange { background: var(--orange-light); color: var(--orange); }
.page-title-icon svg { width: 20px; height: 20px; }

/* ===== ACTION CARDS (home) ===== */
.action-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 36px;
}
.action-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.action-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.action-card-inner { display: flex; align-items: center; gap: 14px; }
.action-icon svg { width: 52px; height: 52px; }
.action-text h2 { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.action-text p  { font-size: 13px; color: var(--text-muted); }

.btn-start {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-start:hover { transform: translateY(-1px); }
.btn-start:active { transform: translateY(0); }
.btn-green  { background: var(--green);  color: var(--white); }
.btn-green:hover  { background: var(--green-dark); }
.btn-orange { background: var(--orange); color: var(--white); }
.btn-orange:hover { background: var(--orange-dark); }

/* ===== LISTING ===== */
.section-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 20px; }

.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.product-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  animation: fadeInUp 0.35s ease both;
}
.product-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }
.product-card:nth-child(1){animation-delay:.05s} .product-card:nth-child(2){animation-delay:.10s}
.product-card:nth-child(3){animation-delay:.15s} .product-card:nth-child(4){animation-delay:.20s}
.product-card:nth-child(5){animation-delay:.25s} .product-card:nth-child(6){animation-delay:.30s}

.product-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #f0f0f0; }
.product-info { padding: 12px 14px 14px; }
.product-meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.product-name  { font-size: 14px; font-weight: 600; color: var(--text); }
.product-price { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; }

.btn-detail {
  width: 100%;
  padding: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn-detail:hover { background: var(--bg); border-color: #b0bec5; }

.view-more-wrap { text-align: center; margin-top: 24px; }
.btn-view-more {
  padding: 10px 32px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-view-more:hover { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* ===== FORM CARD ===== */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  max-width: 760px;
}

.form-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin: 20px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.form-section-label:first-child { margin-top: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { margin-bottom: 16px; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.required { color: #e53e3e; }

input[type="text"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27,58,92,0.1);
}
input.error, select.error, textarea.error {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229,62,62,0.1);
}
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6A7A' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.field-error { font-size: 12px; color: #e53e3e; min-height: 16px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.btn-cancel {
  padding: 10px 22px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-cancel:hover { background: var(--bg); color: var(--text); border-color: #b0bec5; }

.btn-submit {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-submit svg { width: 16px; height: 16px; }
.btn-submit:hover { transform: translateY(-1px); }
.btn-submit:active { transform: translateY(0); }

/* ===== TABS (đơn của tôi) ===== */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
  width: fit-content;
}
.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn svg { width: 16px; height: 16px; }
.tab-btn.active { background: var(--navy); color: var(--white); }
.tab-btn:not(.active):hover { background: var(--bg); color: var(--text); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== ORDER LIST ===== */
.order-list { display: flex; flex-direction: column; gap: 12px; }

.order-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  animation: fadeInUp 0.3s ease both;
}
.order-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.order-icon.green  { background: var(--green-light);  color: var(--green); }
.order-icon.orange { background: var(--orange-light); color: var(--orange); }
.order-icon svg { width: 22px; height: 22px; }

.order-body { flex: 1; min-width: 0; }
.order-name  { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.order-meta  { font-size: 13px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 12px; }
.order-meta span { display: flex; align-items: center; gap: 4px; }
.order-meta svg  { width: 13px; height: 13px; flex-shrink: 0; }

.order-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
}
.badge-pending  { background: #FEF3C7; color: #92400E; }
.badge-active   { background: var(--green-light); color: var(--green-dark); }
.badge-done     { background: #E0E7FF; color: #3730A3; }

.order-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.order-empty svg { width: 48px; height: 48px; margin: 0 auto 12px; display: block; opacity: 0.35; }
.order-empty p { font-size: 15px; font-weight: 500; }
.order-empty small { font-size: 13px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1A2332;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--green); }
.toast.error   { background: #e53e3e; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--navy); }
.bottom-nav-item:hover  { color: var(--navy); }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  body { padding-bottom: 68px; }
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .bottom-nav { display: flex; }

  .action-cards { grid-template-columns: 1fr; gap: 12px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .section-title { font-size: 17px; }

  .form-card { padding: 20px 18px; }
  .page-title { font-size: 18px; }

  .tab-bar { width: 100%; }
  .tab-btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
  .container { padding: 0 14px; }
  .page { padding: 16px 0 32px; }

  /* Action cards horizontal */
  .action-card { flex-direction: row; align-items: center; padding: 14px 16px; gap: 0; }
  .action-card-inner { flex: 1; }
  .action-icon svg { width: 44px; height: 44px; }
  .action-text h2 { font-size: 15px; }
  .btn-start { width: auto; padding: 10px 16px; font-size: 14px; white-space: nowrap; flex-shrink: 0; }

  /* Product list style */
  .product-grid { grid-template-columns: 1fr; gap: 0; }
  .product-card {
    display: flex; flex-direction: row; align-items: center;
    border-radius: 0; border-left: none; border-right: none; border-top: none;
    box-shadow: none; border-bottom: 1px solid var(--border);
    transform: none !important;
  }
  .product-card:first-child { border-radius: var(--radius) var(--radius) 0 0; border-top: 1px solid var(--border); }
  .product-card:last-child  { border-radius: 0 0 var(--radius) var(--radius); }
  .product-img { width: 72px; height: 72px; aspect-ratio: 1; flex-shrink: 0; border-radius: 8px; margin: 10px; }
  .product-info { flex: 1; padding: 10px 10px 10px 0; display: flex; align-items: center; gap: 8px; }
  .product-meta { flex: 1; flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 0; }
  .product-name { font-size: 14px; }
  .product-price { font-size: 13px; color: var(--text-muted); }
  .btn-detail { display: none; }
  .product-card::after {
    content: ''; display: block; width: 8px; height: 8px;
    border-right: 2px solid var(--text-muted); border-top: 2px solid var(--text-muted);
    transform: rotate(45deg); margin-right: 16px; flex-shrink: 0;
  }

  /* Form */
  .form-row { grid-template-columns: 1fr; gap: 12px; }
  .form-card { padding: 16px 14px; border-radius: 10px; }
  .form-actions { flex-direction: column-reverse; }
  .btn-cancel, .btn-submit { width: 100%; justify-content: center; }

  .page-header { gap: 10px; }
  .page-title { font-size: 16px; }
  .page-title-icon { width: 30px; height: 30px; border-radius: 8px; }
  .page-title-icon svg { width: 16px; height: 16px; }

  .logo-name { font-size: 14px; }
  .logo-sub  { font-size: 10px; }

  .order-card { padding: 12px 14px; gap: 12px; }
  .order-name { font-size: 14px; }

  .toast { bottom: 76px; font-size: 13px; padding: 10px 18px; max-width: calc(100vw - 32px); white-space: normal; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .product-card, .page, .order-card { animation: none; transition: none; }
}
