/* ═══════════════════════════════════════════════════════════════
   Ameera in Korea – Admin Design Token System
   Single source of truth for all colours, surfaces, and typography.
   All templates reference these vars; never hardcode colours in templates.
   ═══════════════════════════════════════════════════════════════ */

/* ── Default (Dark Mode) – applied to :root so the page is correct
      before JS/server sets the data-theme attribute ── */
:root,
[data-theme="dark"] {
  /* Backgrounds */
  --bg-base:        #0d0818;      /* page canvas       */
  --bg-surface:     #1e103a;      /* cards, panels      */
  --bg-sidebar:     #100820;      /* sidebar            */
  --bg-input:       #160b2b;      /* form inputs        */
  --bg-overlay:     rgba(10,5,20,0.98);  /* mobile nav overlay */
  --bg-topbar:      rgba(14,7,28,0.97);  /* mobile top-bar     */
  --bg-footer:      rgba(14,7,28,0.85);  /* footer             */
  --bg-bottom-nav:  rgba(14,7,28,0.97);  /* bottom mobile nav  */
  --bg-gradient:    linear-gradient(135deg, #0d0818 0%, #160b2b 50%, #0d0818 100%);

  /* Accent colours */
  --accent-primary:    #E8579A;   /* pink CTA, active states  */
  --accent-hover:      #F07BC0;   /* lighter pink hover       */
  --accent-secondary:  #CA93FA;   /* lavender highlights      */
  --accent-tertiary:   #4C2A85;   /* deep purple accents      */
  --accent-muted:      rgba(202,147,250,0.18); /* subtle tint  */

  /* Text */
  --text-primary:   #e0d4ff;
  --text-secondary: #CA93FA;
  --text-muted:     rgba(202,147,250,0.55);
  --text-accent:    #E8579A;
  --text-link:      #c084fc;
  --text-orange:    #fdba74;
  --text-blue:      #93c5fd;

  /* Borders */
  --border:         rgba(165,85,200,0.30);
  --border-strong:  rgba(165,85,200,0.50);
  --border-accent:  rgba(202,147,250,0.45);

  /* Shadows */
  --shadow-card:    0 4px 24px rgba(13,8,24,0.5);
  --shadow-accent:  0 4px 16px rgba(232,87,154,0.25);

  /* Scrollbar */
  --scrollbar-track: rgba(120,40,140,0.12);
  --scrollbar-thumb: rgba(232,87,154,0.50);
  --scrollbar-hover: rgba(232,87,154,0.80);

  /* Status colours (adapted for dark) */
  --status-success-bg:   rgba(16,185,129,0.15);
  --status-success-text: #6ee7b7;
  --status-success-border: rgba(16,185,129,0.35);
  --status-error-bg:     rgba(220,38,38,0.15);
  --status-error-text:   #fca5a5;
  --status-error-border: rgba(220,38,38,0.35);
  --status-warn-bg:      rgba(245,158,11,0.15);
  --status-warn-text:    #fcd34d;
  --status-warn-border:  rgba(245,158,11,0.35);

  /* Nav */
  --nav-trigger-bg:      rgba(232,87,154,0.10);
  --nav-trigger-border:  rgba(165,85,200,0.35);
  --nav-trigger-text:    #f0e6ff;
  --nav-trigger-hover:   rgba(232,87,154,0.18);
  --nav-dropdown-bg:     #1e103a;
  --nav-link-text:       #d4b4ff;
  --nav-link-hover-text: #E8579A;
  --nav-section-text:    #c084fc;
  --bottom-nav-item:     rgba(192,132,252,0.80);
}

/* ── Light Mode ── */
[data-theme="light"] {
  /* Backgrounds */
  --bg-base:        #f8f0ff;      /* soft lavender page canvas  */
  --bg-surface:     #ffffff;      /* cards, panels              */
  --bg-sidebar:     #f3e8ff;      /* fully light sidebar        */
  --bg-input:       #ffffff;      /* form inputs                */
  --bg-overlay:     rgba(243,232,255,0.99);  /* mobile nav overlay */
  --bg-topbar:      rgba(243,232,255,0.97);  /* mobile top-bar     */
  --bg-footer:      rgba(243,232,255,0.95);  /* footer             */
  --bg-bottom-nav:  rgba(243,232,255,0.97);  /* bottom mobile nav  */
  --bg-gradient:    linear-gradient(135deg, #f8f0ff 0%, #ede8f8 50%, #f8f0ff 100%);

  /* Accent colours – unchanged across themes */
  --accent-primary:    #E8579A;
  --accent-hover:      #c9357a;
  --accent-secondary:  #4C2A85;
  --accent-tertiary:   #CA93FA;
  --accent-muted:      rgba(76,42,133,0.10);

  /* Text */
  --text-primary:   #1a0a2e;
  --text-secondary: #4C2A85;
  --text-muted:     rgba(76,42,133,0.55);
  --text-accent:    #E8579A;
  --text-link:      #4C2A85;
  --text-orange:    #c2641a;
  --text-blue:      #1d4ed8;

  /* Borders */
  --border:         rgba(76,42,133,0.20);
  --border-strong:  rgba(76,42,133,0.40);
  --border-accent:  rgba(232,87,154,0.45);

  /* Shadows */
  --shadow-card:    0 2px 16px rgba(76,42,133,0.10);
  --shadow-accent:  0 4px 16px rgba(232,87,154,0.20);

  /* Scrollbar */
  --scrollbar-track: rgba(76,42,133,0.08);
  --scrollbar-thumb: rgba(232,87,154,0.45);
  --scrollbar-hover: rgba(232,87,154,0.75);

  /* Status colours (light) */
  --status-success-bg:   #f0fdf4;
  --status-success-text: #166534;
  --status-success-border: rgba(22,163,74,0.40);
  --status-error-bg:     #fef2f2;
  --status-error-text:   #991b1b;
  --status-error-border: rgba(220,38,38,0.35);
  --status-warn-bg:      #fffbeb;
  --status-warn-text:    #92400e;
  --status-warn-border:  rgba(245,158,11,0.40);

  /* Nav */
  --nav-trigger-bg:      rgba(232,87,154,0.08);
  --nav-trigger-border:  rgba(76,42,133,0.25);
  --nav-trigger-text:    #1a0a2e;
  --nav-trigger-hover:   rgba(232,87,154,0.14);
  --nav-dropdown-bg:     #ede9f8;
  --nav-link-text:       #4C2A85;
  --nav-link-hover-text: #E8579A;
  --nav-section-text:    #6d28d9;
  --bottom-nav-item:     rgba(76,42,133,0.75);
}

/* ═══════════════════════════════════════════════════════════════
   Global Base Styles (using CSS vars)
   ═══════════════════════════════════════════════════════════════ */

body {
  background: var(--bg-gradient) !important;
  color: var(--text-primary) !important;
}

/* Applied to <body> via layout.html class */
.admin-body { font-family: 'Nunito', sans-serif; }

/* Theme toggle icon visibility – driven by data-theme on <html> */
.theme-icon-sun  { display: inline-flex; align-items: center; gap: 0.35rem; }
.theme-icon-moon { display: none; }
[data-theme="light"] .theme-icon-sun  { display: none; }
[data-theme="light"] .theme-icon-moon { display: inline-flex; align-items: center; gap: 0.35rem; }

/* Brand logo – white/transparent in dark mode, dark-purple tinted in light mode */
[data-theme="light"] img[src*="ameera_logo"] {
  filter: brightness(0) saturate(100%) invert(10%) sepia(75%) saturate(1600%) hue-rotate(272deg) brightness(85%);
  transition: filter 0.25s ease;
}

/* Smooth theme transition */
*, *::before, *::after {
  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    color 0.18s ease,
    box-shadow 0.25s ease;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ── Form elements ── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
select,
textarea {
  background-color: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
input::placeholder, textarea::placeholder { color: var(--text-muted) !important; }
select option { background-color: var(--bg-input); color: var(--text-primary); }

/* ── Override Tailwind light defaults so all pages inherit active theme ── */
.bg-white   { background-color: var(--bg-surface) !important; }
.bg-pink-50 { background-color: var(--bg-base) !important; }
.bg-rose-50 { background-color: var(--bg-base) !important; }
.bg-pink-100 { background-color: var(--accent-muted) !important; }
.bg-rose-100 { background-color: var(--accent-muted) !important; }
.bg-pink-200 { background-color: rgba(232,87,154,0.20) !important; }

.text-rose-900 { color: var(--text-primary) !important; }
.text-rose-800 { color: var(--text-primary) !important; }
.text-rose-700 { color: var(--text-secondary) !important; }
.text-rose-600 { color: var(--text-secondary) !important; }
.text-pink-800 { color: var(--text-primary) !important; }
.text-pink-700 { color: var(--text-secondary) !important; }
.text-pink-600 { color: var(--text-secondary) !important; }
.text-pink-500 { color: var(--text-muted) !important; }
.text-pink-400 { color: var(--text-muted) !important; }
.text-orange-700 { color: var(--text-orange) !important; }
.text-blue-700   { color: var(--text-blue) !important; }

.border-pink-100 { border-color: var(--border) !important; }
.border-pink-200 { border-color: var(--border) !important; }
.border-pink-300 { border-color: var(--border-strong) !important; }
.border-rose-200 { border-color: var(--border) !important; }
.border-rose-300 { border-color: var(--border-strong) !important; }

.hover\:bg-white:hover    { background-color: var(--accent-muted) !important; }
.hover\:bg-pink-50:hover  { background-color: var(--accent-muted) !important; }
.hover\:bg-pink-100:hover { background-color: var(--accent-muted) !important; }
.hover\:bg-rose-100:hover { background-color: var(--accent-muted) !important; }
.hover\:border-pink-400:hover { border-color: var(--border-accent) !important; }

/* Dividers */
.bg-pink-100.h-px,
.h-px.bg-pink-100 { background-color: var(--border) !important; }

/* ═══════════════════════════════════════════════════════════════
   Shared Admin Component Library
   Use these classes across all templates for consistency.
   ═══════════════════════════════════════════════════════════════ */

/* ── Layout shells (page-level wrappers) ── */
.admin-shell {
  border-radius: 2rem;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

/* ── Cards ── */
.admin-card {
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.admin-card-gradient {
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-base));
  padding: 1.25rem;
}

/* ── Stat / KPI cards ── */
.admin-stat-card {
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-base));
  padding: 1.25rem;
}
.admin-stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.admin-stat-card .stat-value {
  margin-top: 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Page header ── */
.admin-page-header { margin-bottom: 1.5rem; }
.admin-page-header .page-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  font-weight: 600;
}
.admin-page-header h1 {
  margin-top: 0.35rem;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.admin-page-header p {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Section title ── */
.admin-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ── Primary button ── */
.admin-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 1rem;
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.admin-btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-accent);
}

/* ── Secondary button ── */
.admin-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 1rem;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.admin-btn-secondary:hover {
  background: var(--accent-muted);
  border-color: var(--border-accent);
}

/* ── Badge / pill ── */
.admin-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.admin-badge-accent {
  background: rgba(232,87,154,0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(232,87,154,0.30);
}
.admin-badge-secondary {
  background: var(--accent-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ── Tables ── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.admin-table thead tr {
  background: var(--bg-base);
}
.admin-table thead th {
  padding: 0.625rem 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
}
.admin-table tbody tr {
  border-top: 1px solid var(--border);
  transition: background 0.15s ease;
}
.admin-table tbody tr:hover { background: var(--accent-muted); }
.admin-table tbody td { padding: 0.75rem 1rem; color: var(--text-primary); }

/* ── Form fields ── */
.admin-form-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.admin-form-field input,
.admin-form-field select,
.admin-form-field textarea {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  outline: none;
}
.admin-form-field input:focus,
.admin-form-field select:focus,
.admin-form-field textarea:focus {
  border-color: var(--accent-primary);
}

/* ── Alert / notification bars ── */
.admin-alert-success {
  border-radius: 1rem;
  border: 1px solid var(--status-success-border);
  background: var(--status-success-bg);
  color: var(--status-success-text);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
}
.admin-alert-error {
  border-radius: 1rem;
  border: 1px solid var(--status-error-border);
  background: var(--status-error-bg);
  color: var(--status-error-text);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
}
.admin-alert-warn {
  border-radius: 1rem;
  border: 1px solid var(--status-warn-border);
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
}

/* ── Theme toggle button ── */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 9999px;
  padding: 0.4rem 0.8rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
  background: var(--accent-muted);
  border-color: var(--border-accent);
  color: var(--accent-primary);
}

/* ═══════════════════════════════════════════════════════════════
   Navigation Component (layout.html)
   ═══════════════════════════════════════════════════════════════ */

/* Sidebar */
.sidebar-aside {
  background: var(--bg-sidebar) !important;
  border-color: var(--border) !important;
}

/* Nav trigger buttons */
.nav-trigger {
  background: var(--nav-trigger-bg) !important;
  color: var(--nav-trigger-text) !important;
  border-color: var(--nav-trigger-border) !important;
}
.nav-trigger:hover {
  background: var(--nav-trigger-hover) !important;
  color: var(--text-primary) !important;
}

/* Nav dropdowns */
.nav-dropdown { display: none; }
.nav-dropdown.active { display: block; }
.nav-dropdown {
  background: var(--nav-dropdown-bg) !important;
  border-color: var(--border) !important;
}
.nav-dropdown a {
  color: var(--nav-link-text) !important;
  border-color: var(--border) !important;
}
.nav-dropdown a:hover {
  background: var(--accent-muted) !important;
  color: var(--nav-link-hover-text) !important;
}
.nav-dropdown .text-pink-600,
.nav-dropdown .text-pink-400 { color: var(--nav-section-text) !important; }

/* Dropdown section dividers */
.nav-dropdown .h-px { background-color: var(--border) !important; }

/* Search bar */
#global-search {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
#global-search::placeholder { color: var(--text-muted) !important; }
#global-search-results {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
}
#global-search-results a:hover { background: var(--accent-muted) !important; }
#global-search-results a .text-pink-800 { color: var(--text-primary) !important; }
#global-search-results a .text-pink-400 { color: var(--text-muted) !important; }

/* Mobile top-bar */
.mobile-topbar {
  background: var(--bg-topbar);
  border-color: var(--border) !important;
}

/* Footer */
.admin-footer { background: var(--bg-footer) !important; border-color: var(--border) !important; }
.admin-footer a { color: var(--accent-primary) !important; }
.admin-footer a:hover { color: var(--accent-hover) !important; }
.admin-footer .text-pink-400 { color: var(--text-muted) !important; }
.admin-footer .text-pink-300 { color: var(--text-muted) !important; }

/* ── Mobile Navigation ── */
@media (max-width: 1023px) {
  body { padding-bottom: 80px; }

  .mobile-nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
  }
  .mobile-nav-overlay.active { opacity: 1; pointer-events: auto; }

  .bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 40;
    background: var(--bg-bottom-nav);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(232,87,154,0.3);
    padding: 0.5rem 0;
  }
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    text-decoration: none;
    color: var(--bottom-nav-item) !important;
    font-size: 0.625rem;
    font-weight: 500;
    transition: color 0.2s ease;
  }
  .bottom-nav-item:hover,
  .bottom-nav-item.active { color: var(--accent-primary) !important; }
  .bottom-nav-badge {
    position: absolute;
    top: 0.25rem; right: 0.5rem;
    background: var(--accent-primary);
    color: #fff;
    font-size: 0.625rem; font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    min-width: 1.25rem; text-align: center;
  }
}

/* ── Products card (legacy class used in products.html) ── */
.products-card { background-color: var(--bg-surface) !important; }

/* ═══════════════════════════════════════════════════════════════
   Print Media – restores clean white/black palette
   regardless of active theme.
   All print templates get this for free.
   ═══════════════════════════════════════════════════════════════ */
@media print {
  :root,
  [data-theme="dark"],
  [data-theme="light"] {
    --bg-base:       #ffffff;
    --bg-surface:    #ffffff;
    --bg-sidebar:    #ffffff;
    --bg-input:      #ffffff;
    --text-primary:  #000000;
    --text-secondary:#333333;
    --text-muted:    #555555;
    --border:        #cccccc;
    --border-strong: #999999;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
}
