:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--gray-900); background: var(--gray-50); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ─── Navbar ─── */
.navbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: box-shadow 0.25s, border-color 0.25s;
}
.navbar.scrolled { box-shadow: 0 4px 24px rgba(0,0,0,.07); border-bottom-color: transparent; }
/* Brand */
.navbar-brand { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.nb-logo { font-size: 1.375rem; line-height: 1; }
.nb-wordmark { font-weight: 800; font-size: 1.125rem; color: var(--primary); letter-spacing: -.025em; }
/* Nav links */
.navbar-links { display: flex; align-items: center; gap: .125rem; }
.navbar-link { padding: .5rem .875rem; border-radius: .5rem; font-size: .875rem; font-weight: 500; color: var(--gray-600); transition: background .15s, color .15s; white-space: nowrap; }
.navbar-link:hover { background: var(--gray-100); color: var(--gray-900); }
.navbar-link.active { color: var(--primary); font-weight: 600; background: var(--primary-light, #eff6ff); }
.nb-admin { color: var(--primary) !important; font-weight: 600 !important; }
/* Auth section */
.navbar-auth { display: flex; align-items: center; gap: .5rem; }
.nb-signin { color: var(--gray-700) !important; }
/* User button */
.nb-user-btn { display: flex; align-items: center; gap: .4rem; padding: .3rem .75rem .3rem .35rem; background: var(--gray-100); border-radius: 9999px; cursor: pointer; position: relative; user-select: none; transition: background .15s; margin-left: .25rem; }
.nb-user-btn:hover { background: var(--gray-200); }
.nb-avatar { width: 28px; height: 28px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0; }
.nb-name { font-size: .875rem; font-weight: 600; color: var(--gray-800); }
.nb-chevron { font-size: .625rem; color: var(--gray-500); transition: transform .2s; margin-left: .1rem; }
.nb-user-btn.open .nb-chevron { transform: rotate(180deg); }
/* Dropdown */
.nb-dropdown { position: absolute; top: calc(100% + .625rem); right: 0; background: white; border: 1px solid var(--gray-200); border-radius: .875rem; box-shadow: 0 16px 48px rgba(0,0,0,.12); min-width: 220px; padding: .625rem; opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .18s, visibility .18s, transform .18s; z-index: 100; }
.nb-user-btn.open .nb-dropdown { opacity: 1; visibility: visible; transform: none; }
.nb-dd-name { font-weight: 700; font-size: .875rem; color: var(--gray-900); padding: .375rem .625rem .1rem; }
.nb-dd-email { font-size: .75rem; color: var(--gray-500); padding: 0 .625rem .5rem; }
.nb-dd-divider { border-top: 1px solid var(--gray-100); margin: .375rem 0; }
.nb-dd-item { display: flex; align-items: center; gap: .625rem; padding: .575rem .75rem; border-radius: .5rem; font-size: .875rem; color: var(--gray-700); font-weight: 500; transition: background .12s; cursor: pointer; text-decoration: none; width: 100%; text-align: left; background: none; border: none; font-family: inherit; }
.nb-dd-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nb-dd-logout { color: var(--danger) !important; }
.nb-dd-logout:hover { background: #fef2f2 !important; }
/* Hamburger */
.nb-hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 36px; height: 36px; background: none; border: none; cursor: pointer; border-radius: .375rem; padding: .375rem; }
.nb-hamburger span { display: block; width: 20px; height: 2px; background: var(--gray-700); border-radius: 2px; transition: transform .25s, opacity .25s; }
.nb-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nb-hamburger.open span:nth-child(2) { opacity: 0; }
.nb-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
/* Mobile menu */
.nb-mobile { display: none; position: absolute; top: 64px; left: 0; right: 0; background: white; border-bottom: 1px solid var(--gray-200); padding: .75rem 1.25rem 1rem; flex-direction: column; gap: .125rem; box-shadow: 0 8px 24px rgba(0,0,0,.07); }
.nb-mobile.open { display: flex; }
.nb-mobile-divider { border-top: 1px solid var(--gray-100); margin: .5rem 0; }
@media (max-width: 768px) {
  .navbar-links { display: none; }
  .navbar-auth  { display: none; }
  .nb-hamburger { display: flex; }
}

/* ─── Container ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 480px; margin: 0 auto; padding: 0 1.5rem; }
.container-md { max-width: 768px; margin: 0 auto; padding: 0 1.5rem; }

/* ─── Buttons ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.5625rem 1.25rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 600; border: none; cursor: pointer; transition: all 0.15s; line-height: 1; text-align: center; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* ─── Card ─── */
.card { background: white; border-radius: 0.75rem; border: 1px solid var(--gray-100); padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.card-hover { transition: box-shadow 0.15s, transform 0.15s; }
.card-hover:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }

/* ─── Badge ─── */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ─── Form ─── */
.input-field { width: 100%; padding: 0.625rem 0.875rem; border: 1px solid var(--gray-300); border-radius: 0.5rem; font-size: 0.875rem; outline: none; transition: border-color 0.15s, box-shadow 0.15s; background: white; color: var(--gray-900); }
.input-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.input-label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--gray-700); margin-bottom: 0.375rem; }
.input-group { margin-bottom: 1.25rem; }
.input-error { font-size: 0.8125rem; color: var(--danger); margin-top: 0.25rem; }
.form-section { background: white; border-radius: 0.75rem; border: 1px solid var(--gray-100); padding: 1.5rem; margin-bottom: 1.25rem; }
.form-section-title { font-size: 1rem; font-weight: 600; color: var(--gray-900); margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--gray-100); }
/* ─── Image dropzone ─── */
#img-dropzone { border: 2px dashed var(--gray-300); border-radius: 0.75rem; padding: 2.5rem 1.5rem; text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
#img-dropzone:hover { border-color: var(--primary); background: var(--primary-light, #eff6ff); }
#img-dropzone.drag-over { border-color: var(--primary); background: var(--primary-light, #eff6ff); }

/* ─── Alert ─── */
.alert { padding: 0.875rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; margin-bottom: 1rem; }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }

/* ─── Grid ─── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }

/* ─── Product Card ─── */
.product-card { background: white; border-radius: 0.75rem; border: 1px solid var(--gray-100); overflow: hidden; transition: box-shadow 0.25s, transform 0.25s; }
.product-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.14); transform: translateY(-4px) scale(1.035); }
.product-card-img { width: 100%; height: 220px; object-fit: contain; background: var(--gray-100); display: block; }
.product-card-img-placeholder { width: 100%; height: 180px; background: var(--gray-100); display: flex; align-items: center; justify-content: center; color: var(--gray-300); font-size: 3rem; }
.product-card-body { padding: 1rem; }
.product-card-title { font-weight: 600; font-size: 0.9375rem; color: var(--gray-900); margin-bottom: 0.5rem; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card-price { font-size: 1.125rem; font-weight: 700; color: var(--primary); }
/* ─── Price block (compare price / savings) ─── */
.price-block { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem; }
.price-main { font-size: 1.5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.price-compare { font-size: .9375rem; font-weight: 500; color: var(--gray-400); text-decoration: line-through; }
.price-badge { font-size: .7rem; font-weight: 700; background: #dcfce7; color: #16a34a; padding: .15rem .45rem; border-radius: .3rem; }
.price-save { width: 100%; font-size: .8125rem; font-weight: 600; color: #16a34a; margin-top: .1rem; }
/* Compact version inside product cards */
.product-card-price .price-main { font-size: 1.125rem; }
.product-card-price .price-save { font-size: .75rem; }
.product-card-meta { font-size: 0.8125rem; color: var(--gray-500); margin-top: 0.25rem; }

/* ─── Table ─── */
.table-wrap { background: white; border-radius: 0.75rem; border: 1px solid var(--gray-100); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { background: var(--gray-50); padding: 0.75rem 1rem; text-align: left; font-weight: 600; color: var(--gray-600); border-bottom: 1px solid var(--gray-100); white-space: nowrap; }
td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--gray-50); color: var(--gray-800); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ─── Modal ─── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.hidden { display: none; }
.modal { background: white; border-radius: 1rem; padding: 1.75rem; max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-title { font-size: 1.125rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--gray-400); padding: 0.25rem; font-size: 1.25rem; line-height: 1; }
.modal-close:hover { color: var(--gray-700); }

/* ─── Stat Card ─── */
.stat-card { background: white; border-radius: 0.75rem; border: 1px solid var(--gray-100); padding: 1.5rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 0.75rem; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; margin-bottom: 1rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 0.875rem; color: var(--gray-500); margin-top: 0.25rem; }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 0.25rem; background: var(--gray-100); padding: 0.25rem; border-radius: 0.75rem; width: fit-content; }
.tab { padding: 0.5rem 1.25rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; color: var(--gray-500); cursor: pointer; border: none; background: none; transition: all 0.15s; }
.tab.active { background: white; color: var(--gray-900); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ─── Search bar ─── */
.search-bar { position: relative; }
.search-bar input { padding-left: 2.5rem; }
.search-bar-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; font-size: 1rem; }

/* ─── Page header ─── */
.page-header { padding: 2rem 0 1.5rem; }
.page-title { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.page-subtitle { color: var(--gray-500); margin-top: 0.25rem; font-size: 0.9375rem; }

/* ─── Empty state ─── */
.empty-state { text-align: center; padding: 4rem 1rem; }
.empty-state-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state-title { font-size: 1.25rem; font-weight: 600; color: var(--gray-900); margin-bottom: 0.5rem; }
.empty-state-text { color: var(--gray-500); margin-bottom: 1.5rem; }

/* ─── Toast ─── */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--gray-900); color: white; padding: 0.75rem 1.25rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.2); animation: slideIn 0.2s ease; max-width: 320px; }
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Misc ─── */
.divider { border: none; border-top: 1px solid var(--gray-100); margin: 1.25rem 0; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 4rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 3rem; }

/* ─── Admin layout ─── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar { width: 220px; background: var(--gray-900); color: white; display: flex; flex-direction: column; flex-shrink: 0; }
.admin-sidebar-brand { padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.1); font-weight: 700; font-size: 1rem; }
.admin-sidebar-brand span { color: var(--primary); }
.admin-nav { flex: 1; padding: 0.75rem; }
.admin-nav-link { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.875rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; color: rgba(255,255,255,.6); transition: background 0.15s, color 0.15s; margin-bottom: 0.25rem; }
.admin-nav-link:hover, .admin-nav-link.active { background: rgba(255,255,255,.1); color: white; }
.admin-nav-link.active { background: var(--primary); color: white; }
.admin-content { flex: 1; overflow: auto; padding: 2rem; }

/* ─── Pagination ─── */
.pagination { display: flex; gap: 0.375rem; margin-top: 1.5rem; }
.page-btn { width: 36px; height: 36px; border-radius: 0.5rem; border: 1px solid var(--gray-200); background: white; font-size: 0.875rem; font-weight: 500; color: var(--gray-700); cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center; }
.page-btn:hover { background: var(--gray-50); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── Hero ─── */
.hero { background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%); color: white; padding: 5rem 1.5rem; text-align: center; }
.hero-title { font-size: 3rem; font-weight: 800; line-height: 1.1; margin-bottom: 1.25rem; }
.hero-sub { font-size: 1.1875rem; opacity: 0.9; max-width: 560px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.btn-white { background: white; color: var(--primary); font-weight: 700; }
.btn-white:hover { background: var(--gray-50); }
.btn-outline-white { background: transparent; color: white; border: 2px solid rgba(255,255,255,.5); font-weight: 600; }
.btn-outline-white:hover { background: rgba(255,255,255,.1); border-color: white; }

/* ─── Filter bar ─── */
.filter-bar { background: white; border-radius: 0.75rem; border: 1px solid var(--gray-200); padding: 1rem 1.25rem; margin-bottom: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 150px; }
.filter-group label { font-size: 0.75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .03em; }
.filter-group select, .filter-group input { padding: 0.5rem 0.75rem; border: 1px solid var(--gray-300); border-radius: 0.5rem; font-size: 0.875rem; background: white; outline: none; }
.filter-group select:focus, .filter-group input:focus { border-color: var(--primary); }

/* ─── Image gallery ─── */
.gallery-main { width: 100%; height: 420px; object-fit: contain; border-radius: 0.75rem; background: var(--gray-100); }
.gallery-thumbs { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.gallery-thumb { width: 70px; height: 70px; object-fit: contain; border-radius: 0.5rem; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s; background: var(--gray-100); }
.gallery-thumb.active, .gallery-thumb:hover { border-color: var(--primary); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .hero-title { font-size: 2rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .navbar-links .navbar-link span { display: none; }
  .filter-bar { gap: 0.5rem; }
  .filter-group { min-width: 120px; }
}
