/**
 * MAYMOUNA DESIGN SYSTEM
 * Burgundy velvet, embroidered gold, rose and emerald thread on pearl cream,
 * taken from the Maymouna logo. High contrast and large touch targets for
 * comfortable reading. Full Arabic RTL & English LTR compatibility.
 */

@import url('https://fonts.googleapis.com/css2?family=Alexandria:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,400&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Pearl cream canvas */
  --bg-canvas: #FBF6EE;
  --bg-surface: #FFFDF9;
  --bg-surface-elevated: #F6EDE1;
  --bg-surface-sunken: #EFE4D5;

  /* Legacy variable mappings kept for older markup */
  --navy-950: #FBF6EE;
  --navy-900: #FFFDF9;
  --navy-850: #FFFDF9;
  --navy-800: #F6EDE1;
  --navy-750: #EFE4D5;
  --navy-700: #E3D4C1;

  /* Burgundy velvet (primary ink, buttons, header and footer).
     The --navy-* names are historical; they now hold burgundy. */
  --navy-primary: #5C0F22;
  --navy-secondary: #741A2F;
  --navy-accent: #8E2A40;
  --navy-muted: #5E4347;
  --navy-soft: #F7E9E6;
  --velvet-deep: #3A0713;
  --velvet: #5C0F22;

  /* Embroidered gold */
  --gold-50: #FDF9F1;
  --gold-100: #F8EFDD;
  --gold-200: #EEDDB8;
  --gold-300: #E1C487;
  --gold-400: #D2AC62;
  --gold-500: #B8893E;
  --gold-600: #8A6420;
  --gold-700: #6B4C16;

  /* Thread accents from the logo */
  --rose-200: #F3D5D1;
  --rose-400: #D9918C;
  --rose-600: #A8504F;
  --emerald-100: #E3EFE5;
  --emerald-600: #2D6440;
  --emerald-700: #224E31;
  --pearl: #F4ECE0;

  /* Hairlines, borders and shadows */
  --border-light: #EADDCB;
  --border-medium: #D8C4AA;
  --border-gold-subtle: rgba(184, 137, 62, 0.35);
  --border-gold-focus: #B8893E;
  --shadow-sm: 0 2px 8px rgba(58, 7, 19, 0.05);
  --shadow-card: 0 6px 22px rgba(58, 7, 19, 0.08);
  --shadow-elevated: 0 12px 36px rgba(58, 7, 19, 0.12);
  --shadow-modal: 0 24px 64px rgba(58, 7, 19, 0.22);

  /* Status colors */
  --success: #2D6440;
  --success-bg: #E3EFE5;
  --danger: #A61B29;
  --danger-bg: #FBE4E4;

  /* High contrast typography */
  --text-primary: #2A1015;
  --text-secondary: #5A3D40;
  --text-muted: #7A6062;
  --text-inverse: #FFFDF9;

  /* Fonts */
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ar: 'Alexandria', 'Cairo', -apple-system, sans-serif;

  --font-body: var(--font-sans);
  --font-heading: var(--font-serif);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #170A0D;
  --bg-surface: #221013;
  --bg-surface-elevated: #2E171B;
  --bg-surface-sunken: #1C0D10;
  --navy-950: #170A0D;
  --navy-900: #221013;
  --navy-850: #221013;
  --navy-800: #2E171B;
  --navy-750: #3A2024;
  --navy-700: #4A2B30;
  --navy-primary: #F6EBDD;
  --navy-secondary: #E6D6C4;
  --navy-accent: #DCC6AE;
  --navy-muted: #C2AFA6;
  --navy-soft: #331B20;
  --velvet-deep: #12070A;
  --velvet: #3A0A16;
  --gold-50: #2A1E14;
  --gold-100: #352717;
  --gold-200: #4D3920;
  --gold-300: #9A7A45;
  --gold-400: #DDB872;
  --gold-500: #DDB872;
  --gold-600: #E8C887;
  --gold-700: #F2DAA4;
  --rose-200: #4A2427;
  --rose-400: #E3A39E;
  --rose-600: #EBB2AD;
  --emerald-100: #1D3324;
  --emerald-600: #7FC096;
  --emerald-700: #9BD3AE;
  --pearl: #3A2A28;
  --border-light: #3F2529;
  --border-medium: #573A3F;
  --border-gold-subtle: rgba(221, 184, 114, 0.38);
  --border-gold-focus: #DDB872;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 12px 36px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.55);
  --success: #7FC096;
  --success-bg: #1D3324;
  --danger: #F19A9F;
  --danger-bg: #3D1519;
  --text-primary: #F6EBDD;
  --text-secondary: #DDCBBF;
  --text-muted: #B9A39C;
  --text-inverse: #170A0D;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-gold-subtle);
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font: 600 0.82rem/1.2 var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}

.theme-toggle:hover, .theme-toggle:focus-visible {
  border-color: var(--gold-500);
  outline: none;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .admin-layout,
html[data-theme="dark"] .metrics-row {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
}

html[data-theme="dark"] .luxury-header,
html[data-theme="dark"] .luxury-footer,
html[data-theme="dark"] .admin-topbar,
html[data-theme="dark"] .admin-nav-bar,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .product-card,
html[data-theme="dark"] .cart-items-card,
html[data-theme="dark"] .cart-summary-card,
html[data-theme="dark"] .checkout-section-box,
html[data-theme="dark"] .order-review-card,
html[data-theme="dark"] .confirm-dossier-card,
html[data-theme="dark"] .payment-details-panel,
html[data-theme="dark"] .payment-option-card,
html[data-theme="dark"] .data-table-wrap,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .pane-toolbar,
html[data-theme="dark"] .pane-table-box,
html[data-theme="dark"] .importer-drop-card,
html[data-theme="dark"] .luxury-modal,
html[data-theme="dark"] .luxury-modal-body,
html[data-theme="dark"] .dept-ribbon,
html[data-theme="dark"] .product-item,
html[data-theme="dark"] .bag-drawer,
html[data-theme="dark"] .bag-drawer-header {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

html[data-theme="dark"] .payment-option-card.selected,
html[data-theme="dark"] .payment-option-card:hover {
  background-color: var(--gold-100);
}

html[data-theme="dark"] .luxury-header,
html[data-theme="dark"] .luxury-header-tools,
html[data-theme="dark"] .admin-topbar,
html[data-theme="dark"] .admin-nav-bar,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .checkout-section-box,
html[data-theme="dark"] .order-review-card,
html[data-theme="dark"] .confirm-dossier-card {
  border-color: var(--border-light);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .luxury-input,
html[data-theme="dark"] .luxury-select,
html[data-theme="dark"] .luxury-textarea {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--text-muted);
}

html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .lang-btn {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

html[data-theme="dark"] [style*="background-color: #FFFFFF" i],
html[data-theme="dark"] [style*="background: #FFFFFF" i],
html[data-theme="dark"] [style*="background: white" i] {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary);
}

html[data-theme="dark"] .luxury-hero {
  background: radial-gradient(ellipse at 50% 0%, rgba(221, 184, 114, 0.12), transparent 65%), var(--bg-canvas);
}

html[data-theme="dark"] .bag-pill,
html[data-theme="dark"] .admin-tab.active .admin-tab-pill,
html[data-theme="dark"] .luxury-toast,
html[data-theme="dark"] .bag-drawer-footer {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

html[data-theme="dark"] .admin-table tbody tr:hover,
html[data-theme="dark"] .header-search-input:focus {
  background-color: var(--bg-surface-elevated);
}

html[data-theme="dark"] [style*="#0A1329" i] {
  color: var(--text-primary) !important;
}

html[data-theme="dark"] .btn-primary-gold,
html[data-theme="dark"] .btn-primary-gold:hover {
  background-color: var(--gold-500);
  border-color: var(--gold-500);
  color: #1C0B0F;
}

@media (max-width: 700px) {
  .theme-toggle { padding-inline: 0.5rem; font-size: 0.75rem; }
}

/* RTL Mode (Arabic) */
html[dir="rtl"], body.rtl-mode {
  --font-body: var(--font-ar);
  --font-heading: var(--font-ar);
  font-family: var(--font-ar);
  text-align: right;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Luxury Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--navy-primary);
  font-weight: 700;
  line-height: 1.25;
}

h1 { font-size: 2.75rem; letter-spacing: -0.01em; }
h2 { font-size: 2rem; letter-spacing: -0.01em; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }

html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3 {
  letter-spacing: 0;
  font-weight: 800;
}

p {
  color: var(--text-secondary);
  font-size: 1rem;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

/* Containers */
.luxury-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.luxury-container-narrow {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Refined Buttons */
.btn-primary-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background-color: var(--navy-primary);
  color: var(--text-inverse);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.85rem 1.8rem;
  min-height: 48px;
  border: 1px solid var(--navy-primary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(58, 7, 19, 0.18);
}

html[dir="rtl"] .btn-primary-gold {
  letter-spacing: 0;
  font-weight: 700;
}

.btn-primary-gold:hover {
  background-color: var(--gold-600);
  border-color: var(--gold-600);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(138, 100, 32, 0.28);
}

.btn-outline-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background-color: transparent;
  color: var(--navy-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.85rem 1.8rem;
  min-height: 48px;
  border: 1px solid var(--gold-500);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

html[dir="rtl"] .btn-outline-gold {
  letter-spacing: 0;
}

.btn-outline-gold:hover {
  border-color: var(--navy-primary);
  background-color: var(--gold-100);
  color: var(--navy-primary);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: var(--bg-surface-elevated);
  color: var(--navy-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  min-height: 42px;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: var(--gold-100);
  border-color: var(--navy-primary);
  color: var(--navy-primary);
}

.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--danger);
  border-radius: 4px;
  cursor: pointer;
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

/* Senior-Friendly Accessible Inputs */
.luxury-input, .luxury-select, .luxury-textarea {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--navy-primary);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  min-height: 48px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.luxury-input::placeholder, .luxury-textarea::placeholder {
  color: var(--text-muted);
}

.luxury-input:focus, .luxury-select:focus, .luxury-textarea:focus {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(184, 137, 62, 0.22);
}

.luxury-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--navy-primary);
  margin-bottom: 0.45rem;
}

html[dir="rtl"] .luxury-label {
  letter-spacing: 0;
}

.form-group {
  margin-bottom: 1.25rem;
}

/* Modals */
.luxury-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 6, 14, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.luxury-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.luxury-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}

.luxury-modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
}

.luxury-modal-header h3 {
  font-size: 1.35rem;
  margin: 0;
  color: var(--navy-primary);
}

.luxury-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

.luxury-modal-close:hover {
  color: var(--navy-primary);
}

.luxury-modal-body {
  padding: 2rem;
  background-color: var(--bg-surface);
}

.luxury-modal-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

/* Toast Notification */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

html[dir="rtl"] #toast-container {
  right: auto;
  left: 2rem;
}

.luxury-toast {
  background: var(--navy-primary);
  border: 1px solid var(--gold-500);
  padding: 1rem 1.5rem;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(58, 7, 19, 0.3);
  color: var(--text-inverse);
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 300px;
}

/* Grids */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: 2.1rem; }
}

.catalog-preview-banner { text-align: center; padding: 0.7rem 1rem; background: var(--gold-200); color: var(--velvet-deep); border-bottom: 1px solid var(--border-gold-subtle); font-size: 0.95rem; font-weight: 700; }
html[data-theme="dark"] .catalog-preview-banner { color: var(--gold-700); }
