/* ─── Variables ────────────────────────────────────────────────────────────── */
:root {
  --primary:        #0f2544;
  --primary-light:  #1a3a6b;
  --accent:         #e8a020;
  --accent-hover:   #d4911c;
  --bg:             #f0f2f5;
  --surface:        #ffffff;
  --surface-2:      #f8f9fc;
  --text:           #1a2332;
  --text-muted:     #6b7a8d;
  --border:         #e0e6ef;
  --success:        #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --sidebar-w:      260px;
  --topbar-h:       64px;
  --radius:         10px;
  --shadow:         0 2px 12px rgba(15,37,68,.08);
  --shadow-md:      0 4px 20px rgba(15,37,68,.12);
  --transition:     .2s ease;
}

/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Inter', 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
input, textarea, select { font-family: inherit; }

/* ─── Auth pages ───────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}
.auth-logo img { height: 52px; }
.auth-logo-text {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
}
.auth-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.auth-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 32px; }

/* ─── Layout avec sidebar ──────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 24px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
}
.brand-tagline { font-size: .72rem; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section { padding: 16px 20px 6px; font-size: .68rem; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,.35); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: rgba(255,255,255,.75); font-size: .9rem; font-weight: 500; border-radius: 0; transition: background var(--transition), color var(--transition); cursor: pointer; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(232,160,32,.15); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: var(--primary);
  flex-shrink: 0;
}
.user-info .user-name { font-size: .85rem; font-weight: 600; color: #fff; }
.user-info .user-role { font-size: .72rem; color: rgba(255,255,255,.45); }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.page-content { flex: 1; padding: 28px; }

/* Cart badge */
.cart-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: all var(--transition);
}
.cart-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--primary); }
.cart-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--accent);
  color: var(--primary);
  font-size: .65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

/* ─── Cards & surfaces ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 24px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.stat-accent { color: var(--accent); }

/* ─── Product grid ──────────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.product-img {
  aspect-ratio: 4/3;
  background: var(--surface-2);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.product-img img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.product-img-placeholder {
  width: 64px; height: 64px;
  opacity: .15;
}
.product-body {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.product-ref { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.product-name { font-size: .95rem; font-weight: 600; margin: 4px 0 8px; color: var(--text); line-height: 1.3; }
.product-cat { font-size: .72rem; color: var(--primary-light); background: rgba(15,37,68,.06); border-radius: 4px; padding: 2px 7px; display: inline-block; margin-bottom: 8px; }
.product-price { font-size: 1.1rem; font-weight: 800; color: var(--primary); margin-top: auto; }
.product-colisage { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.product-actions { padding: 0 16px 14px; }
.product-qty-row { display: flex; align-items: center; gap: 8px; }

/* ─── Product detail ────────────────────────────────────────────────────────── */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}
.product-detail-img {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.product-detail-img img { width: 100%; height: 100%; object-fit: contain; padding: 24px; }
.product-detail-info { padding: 8px 0; }
.product-detail-name { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.product-detail-price { font-size: 2rem; font-weight: 800; color: var(--primary); margin: 16px 0; }
.product-detail-desc { color: var(--text-muted); line-height: 1.7; font-size: .95rem; margin-bottom: 24px; }

/* ─── Cart ──────────────────────────────────────────────────────────────────── */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-img {
  width: 64px; height: 64px;
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.cart-item-img img { width: 100%; height: 100%; object-fit: contain; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; font-size: .9rem; }
.cart-item-ref  { font-size: .78rem; color: var(--text-muted); }
.cart-item-price { font-weight: 700; color: var(--primary); white-space: nowrap; margin-right: 8px; }
.cart-summary { position: sticky; top: 80px; }
.cart-total-row { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); }
.cart-total-label { font-weight: 600; }
.cart-total-value { font-size: 1.3rem; font-weight: 800; color: var(--primary); }

/* ─── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

/* ─── Badges & status ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #f1f5f9; color: #64748b; }

/* ─── Forms & inputs ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-control {
  display: block; width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,37,68,.1); }
.form-control::placeholder { color: #b0b9c6; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.form-check-label { font-size: .88rem; cursor: pointer; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* Quantity input */
.qty-input-group { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); width: fit-content; }
.qty-btn { width: 32px; height: 36px; border: none; background: none; cursor: pointer; font-size: 1rem; color: var(--text); display: flex; align-items: center; justify-content: center; transition: background var(--transition); }
.qty-btn:hover { background: var(--surface-2); }
.qty-input { width: 48px; height: 36px; border: none; text-align: center; font-size: .9rem; font-weight: 600; outline: none; background: none; color: var(--text); -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: .88rem; font-weight: 600;
  border: none; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn-sm { padding: 6px 12px; font-size: .78rem; border-radius: 6px; }
.btn-lg { padding: 13px 28px; font-size: 1rem; border-radius: 10px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); color: #fff; }
.btn-accent  { background: var(--accent); color: var(--primary); }
.btn-accent:hover  { background: var(--accent-hover); color: var(--primary); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(15,37,68,.04); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost   { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-full { width: 100%; }

/* ─── Toggle switch ─────────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 24px;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ─── Filters bar ───────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  appearance: none;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.filter-pill:hover, .filter-pill.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.search-bar {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.search-bar input { padding-left: 38px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

/* ─── Profile ───────────────────────────────────────────────────────────────── */
.profile-section { margin-bottom: 28px; }
.profile-section h3 { font-size: .9rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.info-row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { width: 180px; flex-shrink: 0; font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.info-value { font-size: .9rem; color: var(--text); }

/* ─── Alerts & flash ────────────────────────────────────────────────────────── */
.alert {
  padding: 13px 18px;
  border-radius: 8px;
  font-size: .88rem;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ─── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: .4; }
.empty-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }

/* ─── Breadcrumb ────────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-muted); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { opacity: .4; }

/* ─── Admin product table specifics ─────────────────────────────────────────── */
.product-row-thumb {
  width: 40px; height: 40px;
  background: var(--surface-2);
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.product-row-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .product-detail { grid-template-columns: 1fr; }
  .cart-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .form-grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
}

/* ─── Misc ──────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.mt-auto { margin-top: auto; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
