/* ═══════════════════════════════════════════════════════════════════
   CEF Brand — Design Tokens + Core Components
   Used by all Batch 3 pages. Safe to edit via admin theme customizer.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Brand palette */
  --brand-primary:       #2d6a33;    /* CEF green */
  --brand-primary-dark:  #1f4d24;
  --brand-primary-light: #3d8a43;
  --brand-accent:        #d4a574;    /* warm gold */
  --brand-accent-dark:   #b88a5a;

  /* Neutrals */
  --color-bg:            #fafaf9;
  --color-surface:       #ffffff;
  --color-surface-alt:   #f5f5f4;
  --color-text:          #1f2937;
  --color-text-muted:    #6b7280;
  --color-text-subtle:   #9ca3af;
  --color-border:        #e5e7eb;
  --color-border-strong: #d1d5db;

  /* Semantic */
  --color-success:       #16a34a;
  --color-warning:       #f59e0b;
  --color-error:         #dc2626;
  --color-info:          #0ea5e9;

  /* Typography */
  --font-serif:  Georgia, "Times New Roman", serif;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-arabic: "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;

  /* Spacing scale (4px base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

  /* Radius */
  --rad-sm: 4px; --rad-md: 8px; --rad-lg: 12px; --rad-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.10), 0 4px 6px -4px rgba(0,0,0,0.08);

  /* Layout */
  --max-w:          1280px;
  --header-h:       72px;
  --nav-h:          48px;
  --transition:     180ms ease;
}

/* RTL overrides — applied when <html dir="rtl"> */
html[dir="rtl"] { font-family: var(--font-arabic); }
html[dir="rtl"] body { direction: rtl; text-align: right; }

/* ── Reset + base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 700; margin: 0 0 var(--sp-4); }
h1 { font-size: 2rem; line-height: 1.2; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.25rem; line-height: 1.35; }
button { font-family: inherit; cursor: pointer; }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}
@media (min-width: 768px) { .container { padding: 0 var(--sp-6); } }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--rad-md);
  border: 1px solid transparent;
  font-size: 0.95rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary  { background: var(--brand-primary); color: #fff; }
.btn-primary:hover  { background: var(--brand-primary-dark); text-decoration: none; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-alt); text-decoration: none; }
.btn-accent   { background: var(--brand-accent); color: #fff; }
.btn-accent:hover   { background: var(--brand-accent-dark); text-decoration: none; }
.btn-ghost    { background: transparent; color: var(--color-text); }
.btn-ghost:hover    { background: var(--color-surface-alt); text-decoration: none; }
.btn-lg       { padding: var(--sp-4) var(--sp-8); font-size: 1rem; }
.btn-sm       { padding: var(--sp-2) var(--sp-4); font-size: 0.875rem; }
.btn-block    { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Header ─────────────────────────────────────────────────── */
.cef-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-h);
}
.cef-header-inner {
  height: 100%;
  display: flex; align-items: center; gap: var(--sp-6);
}
.cef-logo {
  font-family: var(--font-serif); font-size: 1.4rem; font-weight: 700;
  color: var(--brand-primary);
}
.cef-search {
  flex: 1; max-width: 500px;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-surface-alt);
  border-radius: var(--rad-md);
  border: 1px solid var(--color-border);
}
.cef-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 0.95rem; color: var(--color-text);
  font-family: inherit;
}
.cef-header-actions { display: flex; align-items: center; gap: var(--sp-3); margin-inline-start: auto; }
.cef-icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--rad-md); border: none;
  background: transparent; color: var(--color-text);
  cursor: pointer; position: relative;
}
.cef-icon-btn:hover { background: var(--color-surface-alt); }
.cef-icon-badge {
  position: absolute; top: 4px; inset-inline-end: 4px;
  background: var(--brand-primary); color: #fff;
  min-width: 18px; height: 18px; border-radius: 9px;
  font-size: 0.7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 var(--sp-1);
}

/* Language toggle */
.cef-lang-toggle {
  display: inline-flex;
  background: var(--color-surface-alt);
  border-radius: var(--rad-md);
  padding: 2px;
}
.cef-lang-btn {
  padding: 4px 10px;
  border: none; background: transparent;
  border-radius: var(--rad-sm);
  font-size: 0.8rem; font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
}
.cef-lang-btn.active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

/* ── Nav ─────────────────────────────────────────────────────── */
.cef-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--nav-h);
}
.cef-nav-inner { height: 100%; display: flex; align-items: center; gap: var(--sp-5); overflow-x: auto; }
.cef-nav-link {
  color: var(--color-text); font-size: 0.9rem; font-weight: 500;
  white-space: nowrap;
}
.cef-nav-link:hover { color: var(--brand-primary); text-decoration: none; }

/* ── Product card ───────────────────────────────────────────── */
.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--rad-md);
  overflow: hidden;
  transition: var(--transition);
  display: flex; flex-direction: column;
}
.product-card:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-md); }
.product-card-img {
  aspect-ratio: 1 / 1;
  background: var(--color-surface-alt);
  overflow: hidden;
  position: relative;
}
.product-card-img img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 300ms ease;
}
.product-card:hover .product-card-img img { transform: scale(1.04); }
.product-card-body { padding: var(--sp-3) var(--sp-4) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; }
.product-card-provider { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-subtle); }
.product-card-name { font-size: 0.95rem; font-weight: 500; line-height: 1.35; color: var(--color-text); margin: 0; min-height: 2.6em; }
.product-card-price { font-size: 1.05rem; font-weight: 700; color: var(--color-text); }
.product-card-price-old { text-decoration: line-through; color: var(--color-text-subtle); font-weight: 400; font-size: 0.85rem; margin-inline-start: var(--sp-2); }
.product-badge {
  position: absolute; top: var(--sp-2); inset-inline-start: var(--sp-2);
  background: var(--brand-accent); color: #fff;
  padding: 2px 8px; border-radius: var(--rad-sm);
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Product grid ───────────────────────────────────────────── */
.product-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px)  { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(4, 1fr); } }

/* ── Footer ─────────────────────────────────────────────────── */
.cef-footer {
  background: var(--brand-primary-dark); color: #fff;
  padding: var(--sp-12) 0 var(--sp-6);
  margin-top: var(--sp-16);
}
.cef-footer a { color: #fff; opacity: 0.85; }
.cef-footer a:hover { opacity: 1; }
.cef-footer-cols {
  display: grid; gap: var(--sp-8);
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .cef-footer-cols { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.cef-footer h4 { color: #fff; font-size: 0.95rem; margin-bottom: var(--sp-3); }
.cef-footer-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.cef-footer-links a { font-size: 0.9rem; }
.cef-footer-bottom {
  margin-top: var(--sp-10); padding-top: var(--sp-5);
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--sp-3);
  font-size: 0.85rem; opacity: 0.8;
}

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #fff;
  padding: var(--sp-16) 0;
  text-align: center;
}
.hero h1 { color: #fff; font-size: 2.5rem; margin-bottom: var(--sp-4); }
.hero p { font-size: 1.1rem; opacity: 0.9; margin-bottom: var(--sp-6); }

/* ── Category tile ───────────────────────────────────────────── */
.cat-grid {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px)  { .cat-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .cat-grid { grid-template-columns: repeat(6, 1fr); } }
.cat-tile {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--rad-md);
  padding: var(--sp-3);
  text-align: center;
  font-size: 0.85rem; font-weight: 600; color: var(--color-text);
  transition: var(--transition);
}
.cat-tile:hover { border-color: var(--brand-primary); color: var(--brand-primary); text-decoration: none; }
.cat-tile-icon { font-size: 2rem; margin-bottom: var(--sp-2); }

/* ── Variant picker ─────────────────────────────────────────── */
.variant-group { margin-bottom: var(--sp-5); }
.variant-group-label { display: flex; justify-content: space-between; margin-bottom: var(--sp-2); }
.variant-group-label .label-name { font-weight: 600; font-size: 0.9rem; }
.variant-group-label .label-value { color: var(--color-text-muted); font-size: 0.9rem; }
.variant-options { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.variant-opt {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--rad-md);
  background: var(--color-surface); color: var(--color-text);
  cursor: pointer; font-size: 0.875rem;
  transition: var(--transition);
}
.variant-opt:hover  { border-color: var(--brand-primary); }
.variant-opt.selected { border-color: var(--brand-primary); background: var(--brand-primary); color: #fff; }
.variant-opt.swatch { padding: 0; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; position: relative; }
.variant-opt.swatch.selected { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.variant-opt.disabled { opacity: 0.4; cursor: not-allowed; text-decoration: line-through; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-4); }
.form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: var(--sp-1); color: var(--color-text); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--rad-md);
  font-family: inherit; font-size: 0.95rem;
  background: var(--color-surface); color: var(--color-text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(45,106,51,0.1);
}

/* ── Utilities ──────────────────────────────────────────────── */
.row { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.col { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.text-muted { color: var(--color-text-muted); }
.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.75rem; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.py-8 { padding: var(--sp-8) 0; }
.py-12 { padding: var(--sp-12) 0; }

/* ── Loading state ──────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-alt) 0%, #e5e7eb 50%, var(--color-surface-alt) 100%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.4s ease-in-out infinite;
  border-radius: var(--rad-md);
}
@keyframes skeleton-shine { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Toast ──────────────────────────────────────────────────── */
.cef-toast {
  position: fixed; bottom: var(--sp-6); inset-inline-start: 50%;
  transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--color-text); color: #fff;
  padding: var(--sp-3) var(--sp-5); border-radius: var(--rad-md);
  font-size: 0.9rem; z-index: 100;
  transition: all 250ms ease;
  pointer-events: none;
}
html[dir="rtl"] .cef-toast { transform: translateX(50%) translateY(20px); }
.cef-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
html[dir="rtl"] .cef-toast.show { transform: translateX(50%) translateY(0); }
.cef-toast.success { background: var(--color-success); }
.cef-toast.error { background: var(--color-error); }
