@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-alt: #f5f3ee;
  --color-border: #e5e7eb;
  --color-text: #1a1a1a;
  --color-text-secondary: #4b5563;
  --color-text-muted: #6b7280;
  --color-primary: #2d5f3b;
  --color-primary-hover: #1f4a2b;
  --color-accent: #8b7355;
  --color-success: #16a34a;
  --color-warning: #f59e0b;
  --color-error: #dc2626;

  --font-heading: 'Playfair Display', serif;
  --font-body: 'DM+ Sans', sans-serif;
  --radius: 8px;
  --touch-min: 44px;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --transition: 0.2s ease;

  /* Status colors */
  --status-placed: #94a3b8;
  --status-confirmed: #3b82f6;
  --status-preparing: #f59e0b;
  --status-out-for-delivery: #f97316;
  --status-delivered: #10b981;
  --status-cancelled: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: var(--font-body); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
body { background: var(--color-bg); color: var(--color-text); min-height: 100vh; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Auth page */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  max-width: 400px;
  margin: 0 auto;
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.75rem;
}

.auth-logo h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

/* Header */
.site-header { position: sticky; top: 0; z-index: 100; background: rgba(255,255,255,0.95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; max-width: 1200px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; }
.logo-mark { width: 36px; height: 36px; background: var(--color-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-family: var(--font-heading); }
.logo-img { width: 36px; height: 36px; object-fit: contain; display: block; flex-shrink: 0; }
.logo-img-sm { width: 28px; height: 28px; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn { width: var(--touch-min); height: var(--touch-min); display: flex; align-items: center; justify-content: center; border-radius: 50%; position: relative; }

/* App main */
.app-main { min-height: calc(100vh - 120px); padding-bottom: 80px; }

/* Section */
.section { padding: 2rem 1rem; }
.section-header { margin-bottom: 1.5rem; }
.section-header h2 { font-family: var(--font-heading); font-size: 1.75rem; margin-bottom: 0.5rem; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: white; border-radius: var(--radius); padding: 1.25rem; border: 1px solid var(--color-border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.stat-card .label { font-size: 0.875rem; color: var(--color-text-muted); margin-bottom: 0.25rem; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; font-family: var(--font-heading); }
.stat-card .change { font-size: 0.875rem; margin-top: 0.25rem; }
.stat-card .change.positive { color: var(--color-success); }
.stat-card .change.negative { color: var(--color-error); }

/* Table */
.table-wrapper { background: white; border-radius: var(--radius); border: 1px solid var(--color-border); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { background: var(--color-surface-alt); font-weight: 600; color: var(--color-text-secondary); padding: 0.75rem 1rem; text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border); }
tr:last-child td { border-bottom: none; }
tr:hover { background: var(--color-surface-alt); }

/* Badges */
.badge { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-placed { background: #e5e7eb; color: #4b5563; }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-preparing { background: #fef3c7; color: #92400e; }
.badge-out-for-delivery { background: #fed7aa; color: #9a3412; }
.badge-delivered { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #e5e7eb; color: #4b5563; }
.badge-approved { background: var(--color-accent); }
.badge-hidden { background: var(--status-cancelled); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border-radius: var(--radius); font-weight: 600; min-height: var(--touch-min); transition: var(--transition); font-size: 0.875rem; }
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.75rem; min-height: 36px; }
.btn-secondary { background: var(--color-surface-alt); color: var(--color-text); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger { color: var(--color-error); }
.btn-success { color: var(--color-success); }

/* Form */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.375rem; font-weight: 600; font-size: 0.875rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-family: inherit; font-size: 1rem; }

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  list-style: none;
  padding: 0;
}
.product-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid var(--color-border);
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  padding: 0;
  list-style: none;
}
.product-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.product-card-link { display: block; color: inherit; text-decoration: none; }
.product-image {
  width: 100%;
  height: 200px;
  background: var(--color-surface-alt);
  overflow: hidden;
}.product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.product-info { padding: 0.75rem 1rem; }
.product-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
  line-height: 1.3;
  word-break: break-word;
}
.product-price { color: var(--color-primary); font-weight: 600; }
.product-card > .btn { margin: 0 0.75rem 0.75rem; align-self: flex-start; }

/* Loading */
.loading { text-align: center; padding: 3rem; color: var(--color-text-muted); }

/* Toast */
#toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); background: var(--color-text); color: white; padding: 0.75rem 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200; opacity: 0; transition: opacity 0.3s; }
#toast.show { opacity: 1; }
#toast.error { background: var(--color-error); }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }

/* List */
.list { list-style: none; }
.list li { padding: 0.85rem; border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 0.25rem; }

/* Modal overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
}

.confirm-box {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  margin: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Filter bar */
.filter-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; overflow-x: auto; padding-bottom: 0.5rem; }
.filter-chip { background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 999px; padding: 0.4rem 0.75rem; font-size: 0.8rem; white-space: nowrap; min-height: var(--touch-min); cursor: pointer; }
.filter-chip.active { background: var(--color-primary); color: #fff; }

/* Order detail */
.detail-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.back-link { color: var(--color-primary); font-weight: 600; }

/* Card */
.card { background: white; border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--color-border); }
.card-header { font-weight: 600; font-size: 1.125rem; margin-bottom: 0.75rem; color: var(--color-text-secondary); }

/* Responsive */
@media (min-width: 768px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
  .hero h1 { font-size: 3rem; }
}

/* Sidebar - Desktop */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--color-border);
  z-index: 60;
  overflow-y: auto;
  transition: transform 0.25s ease;
  box-shadow: none;
}

/* Mobile drawer backdrop */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.nav-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

body.nav-open {
  overflow: hidden;
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}

.nav-header .logo-main-img {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.875rem;
}

.nav-header span {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
}

.nav-header .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.nav-header .icon-btn:hover {
  background: var(--color-surface-alt);
}

.nav-list {
  list-style: none;
  padding: 1rem;
}

.nav-list li {
  margin-bottom: 0.5rem;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.nav-list a:hover {
  background: var(--color-surface-alt);
  color: var(--color-primary);
}

.nav-list a.active {
  background: rgba(45, 95, 59, 0.1);
  color: var(--color-primary);
  border-right: 3px solid var(--color-primary);
}

/* Mobile Nav - YouTube style bottom nav */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.mobile-nav a svg {
  width: 20px;
  height: 20px;
}

.mobile-nav a.active {
  color: var(--color-primary);
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Notification bell badge */
.cart-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--color-error);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

/* Notifications dropdown */
.notifications-panel {
  position: fixed;
  top: 64px;
  right: 1rem;
  width: min(92vw, 380px);
  max-height: 70vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 130;
  display: none;
}

.notifications-panel.show {
  display: block;
}

.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: #ffffff;
}

.notification-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item:hover {
  background: var(--color-surface-alt);
}

.notification-item.unread {
  background: rgba(45, 95, 59, 0.06);
}

.notification-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.notification-msg {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-top: 0.15rem;
}

.notification-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* Responsive */
@media (min-width: 768px) {
  .mobile-nav {
    display: none;
  }

  .sidebar {
    display: block;
    width: 260px;
    transform: none;
    box-shadow: none;
  }

  /* Desktop keeps the permanent sidebar, so the drawer controls are unnecessary */
  #menu-btn,
  #menu-close {
    display: none;
  }

  .nav-overlay {
    display: none;
  }

  .app-main {
    margin-left: 260px;
    padding-top: 2rem;
  }

  .product-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
  .hero h1 { font-size: 3rem; }
}

@media (max-width: 767px) {
  /* Off-canvas drawer holding every navigation tab */
  .sidebar {
    display: block;
    width: min(84vw, 300px);
    z-index: 120;
    transform: translateX(-105%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Backdrop must sit above the sticky header so taps close the drawer */
  .nav-overlay {
    z-index: 110;
  }

  .mobile-nav {
    display: flex;
  }

  .app-main {
    padding-bottom: 70px;
  }
}

.loading { text-align: center; padding: 3rem; color: var(--color-text-muted); }
/* ===== Admin product detail: two-column layout + image gallery ===== */
.product-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: start;
}

@media (min-width: 900px) {
  .product-detail-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.product-gallery {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  aspect-ratio: 4 / 3;
}

.gallery-main {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.gallery-main-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.3s ease;
}

.gallery-nav {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}

.gallery-nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: var(--color-text);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: none;
  cursor: pointer;
}

.gallery-dots {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
}

.gallery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.gallery-dot.active {
  background: var(--color-primary);
  width: 24px;
  border-radius: 4px;
}

.gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.75rem;
  background: var(--color-surface-alt);
}

.gallery-thumb {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: #ffffff;
  border-radius: var(--radius);
  border: 2px solid transparent;
  opacity: 0.6;
  cursor: pointer;
  flex-shrink: 0;
}

.gallery-thumb.active {
  opacity: 1;
  border-color: var(--color-primary);
}
