/* =============================================
   NEXAADMIN — style.css
   Dark: Noir/Or  |  Light: Blanc/Corail/Fuchsia
   Glassmorphism + Animations fluides
   ============================================= */

/* ─── VARIABLES ─────────────────────────────── */
:root {
  --gold: #f5c842;
  --gold-soft: rgba(245, 200, 66, 0.15);
  --gold-glow: 0 0 20px rgba(245, 200, 66, 0.3);
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(20px);
  --surface: #131318;
  --surface2: #1a1a22;
  --text: #f0f0f8;
  --text-muted: rgba(240, 240, 248, 0.5);
  --radius: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --modal-bg: #18181f;
  --input-bg: rgba(255,255,255,0.06);
  --input-border: rgba(255,255,255,0.1);
}

/* ─── LIGHT MODE ─────────────────────────────── */
[data-theme="light"] {
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.08);
  --surface: #f5f5fa;
  --surface2: #ebebf5;
  --text: #0d0d1a;
  --text-muted: rgba(13, 13, 26, 0.5);
  --shadow: 0 8px 32px rgba(0,0,0,0.12);
  --modal-bg: #ffffff;
  --input-bg: rgba(0,0,0,0.04);
  --input-border: rgba(0,0,0,0.1);
  --gold: #e6420a;        /* Corail en light */
  --gold-soft: rgba(230, 66, 10, 0.1);
  --gold-glow: 0 0 20px rgba(230, 66, 10, 0.2);
}

/* ─── RESET & BASE ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'DM Sans', sans-serif;
  background: #0d0d0d;
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

[data-theme="light"] body { background: #f0f0f8; }

/* Scrollbar fine */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 2px; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ─── GLASSMORPHISM ──────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.glass-header {
  background: rgba(13, 13, 13, 0.8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-color: var(--glass-border);
}

[data-theme="light"] .glass-header {
  background: rgba(240, 240, 248, 0.85);
}

.glass-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  backdrop-filter: var(--glass-blur);
  transition: all var(--transition);
  cursor: pointer;
}
.glass-btn:hover { background: var(--gold-soft); border-color: var(--gold); }

.glass-input {
  background: rgba(255,255,255,0.08);  /* Fond légèrement plus visible en dark */
  border: 1px solid var(--input-border);
  color: var(--text) !important;        /* Force texte visible — contre Tailwind text-white */
  -webkit-text-fill-color: var(--text); /* Fix Safari */
  outline: none;
  font-family: 'DM Sans', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.glass-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.glass-input::placeholder { color: var(--text-muted) !important; }

/* Dark mode explicite : texte clair sur fond sombre */
[data-theme="dark"] .glass-input {
  background: rgba(255,255,255,0.08);
  color: #f0f0f8 !important;
  -webkit-text-fill-color: #f0f0f8;
}
[data-theme="dark"] .glass-input::placeholder { color: rgba(240,240,248,0.4) !important; }

/* Light mode : fond blanc, texte sombre */
[data-theme="light"] .glass-input {
  background: rgba(255,255,255,0.92) !important;
  color: #0d0d1a !important;
  -webkit-text-fill-color: #0d0d1a;
  border-color: rgba(0,0,0,0.12);
}
[data-theme="light"] .glass-input::placeholder { color: rgba(13,13,26,0.38) !important; }
[data-theme="light"] .glass-input:focus { background: #fff !important; }

/* Select options lisibles dans tous les modes */
select.glass-input option {
  background: var(--surface2);
  color: var(--text);
}

select.glass-input option {
  background: var(--surface2);
  color: var(--text);
}

/* ─── GOLD GRADIENT & BUTTONS ───────────────── */
.gold-gradient { background: linear-gradient(135deg, #f5c842, #c9a200); }
[data-theme="light"] .gold-gradient { background: linear-gradient(135deg, #ff6b35, #e6420a); }

.shadow-gold { box-shadow: var(--gold-glow); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), color-mix(in srgb, var(--gold) 70%, #000));
  color: #000;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--gold-glow);
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(245,200,66,0.4); }
.btn-gold:active { transform: translateY(0); }

[data-theme="light"] .btn-gold { color: #fff; }

/* ─── NAVIGATION ─────────────────────────────── */
.nav-item {
  color: var(--text-muted);
  transition: all var(--transition);
  font-family: 'DM Sans', sans-serif;
  border: none;
  background: none;
  cursor: pointer;
}
.nav-item.active {
  color: var(--gold);
  background: var(--gold-soft);
}
.nav-item:hover { color: var(--gold); }

/* ─── FILTER BUTTONS ─────────────────────────── */
.filter-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.filter-btn.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
}

/* ─── CATALOGUE TABS ─────────────────────────── */
.cat-tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all var(--transition);
}
.cat-tab.active {
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
}

/* ─── THEME BUTTONS ─────────────────────────── */
.theme-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all var(--transition);
}
.theme-btn.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 700;
}

/* ─── FIELD LABELS ───────────────────────────── */
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ─── ORDER CARD ─────────────────────────────── */
.order-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px;
  transition: all var(--transition);
  animation: fadeSlideUp 0.4s ease both;
}
.order-card:hover { border-color: var(--gold); }

/* Status badges */
.badge-pending  { background: rgba(251,191,36,0.15); color: #fbbf24; border: 1px solid rgba(251,191,36,0.3); }
.badge-completed { background: rgba(34,197,94,0.15); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }
.badge-cancelled { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }

/* ─── PRODUCT CARD ───────────────────────────── */
.product-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  transition: all var(--transition);
  animation: fadeSlideUp 0.4s ease both;
}
.product-card:hover { border-color: var(--gold); }
.product-thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}
.product-thumb-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

/* ─── TRANSACTION ROW ────────────────────────── */
.transaction-row {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: fadeSlideUp 0.3s ease both;
}

/* ─── TOGGLE SWITCH ──────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  inset: 0; background: var(--glass-border);
  border-radius: 12px; transition: var(--transition);
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: white; border-radius: 50%;
  transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--gold); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ─── MODALS ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--glass-border);
  border-radius: 28px 28px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 24px 20px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 92vh;
  overflow-y: auto;
}

/* ─── LOGIN SCREEN ───────────────────────────── */
#loginScreen {
  background: radial-gradient(ellipse at 30% 20%, rgba(245,200,66,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(124,58,237,0.06) 0%, transparent 60%),
              #0d0d0d;
}
[data-theme="light"] #loginScreen {
  background: radial-gradient(ellipse at 30% 20%, rgba(230,66,10,0.06) 0%, transparent 60%),
              #f0f0f8;
}

/* ─── PAGE SECTIONS ──────────────────────────── */
.page-section { animation: fadeSlideUp 0.4s ease both; }

/* ─── ANIMATIONS ─────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stagger animation pour listes */
.order-card:nth-child(1) { animation-delay: 0.05s; }
.order-card:nth-child(2) { animation-delay: 0.1s; }
.order-card:nth-child(3) { animation-delay: 0.15s; }
.order-card:nth-child(4) { animation-delay: 0.2s; }
.order-card:nth-child(5) { animation-delay: 0.25s; }
.product-card:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2) { animation-delay: 0.1s; }
.product-card:nth-child(3) { animation-delay: 0.15s; }

/* ─── CHART CONTAINERS ───────────────────────── */
canvas { max-width: 100%; }

/* ─── SAFE AREA (iPhone notch) ───────────────── */
.pb-safe { padding-bottom: env(safe-area-inset-bottom, 8px); }

/* ─── LIGHT MODE OVERRIDES ───────────────────── */
[data-theme="light"] .glass-card {
  background: rgba(255,255,255,0.75);
  border-color: rgba(0,0,0,0.07);
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}
[data-theme="light"] .modal-card { background: #fff; }
[data-theme="light"] body { background: #f0f0f8; color: #0d0d1a; }
[data-theme="light"] .nav-item.active { color: var(--gold); background: var(--gold-soft); }

/* ─── TOAST ──────────────────────────────────── */
#toast.show { display: flex !important; animation: fadeSlideUp 0.3s ease; }

/* ─── RESPONSIVE ─────────────────────────────── */
@media (min-width: 640px) {
  .modal-card { border-radius: 28px; margin: 20px; max-width: 480px; }
  .modal-overlay { align-items: center; }
}

@media (min-width: 1024px) {
  #mainContent { max-width: 680px; margin: 0 auto; }
}

/* ─── SPINNER ────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── LOW STOCK BADGE ────────────────────────── */
.badge-low-stock {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 6px;
  font-size: 10px;
  padding: 1px 6px;
  font-weight: 600;
}
