/* ==========================================================================
   Mostashar Design Tokens — the single source of truth for colour and type.
   Every page, the admin panel and the loyalty site load this file and use the
   SEMANTIC tokens (section 4). Never hard-code a hex value in a component.

   Brand palette (Mostashar Brand Guidelines)
     Navy   #1F2D3D  header & sidebar background (the "chrome")
     Ivory  #F8F5F0  main text on navy · headings & button text
     Gray   #4B4B4B  secondary text
     Gold   #C8A951  icons & symbols (e.g. the scale)
     Sand   #D4B373  call-to-action buttons
     Yellow #EDC13D  illustrations / art
     Tajawal (Arabic) · Roboto (English)

   Accessibility: brand gold is 6.2:1 on navy but only 2.1:1 on ivory, so on
   light surfaces icons use --gold-700 (4.3:1) and gold text --gold-800 (6.2:1).
   Themes: light is the default; <html data-theme="dark"> switches every
   semantic token to the navy dark theme (see /theme.js).

   Flat UI: no gradients, glows or decorative shadows. Cards are a solid fill
   OR an outline, never both, and never lifted on hover. Gradient tokens are
   reserved for the homepage hero; --shadow-* only for floating overlays
   (menus, dialogs). Motion only shows state (spinner, typing, recording).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&family=Roboto:wght@400;500;700&display=swap');

:root {
  /* 1. Brand primitives — referenced only by the scales and semantic tokens */
  --mst-navy:   #1F2D3D;
  --mst-ivory:  #F8F5F0;
  --mst-gray:   #4B4B4B;
  --mst-gold:   #C8A951;
  --mst-sand:   #D4B373;
  --mst-yellow: #EDC13D;

  /* 2. Tonal scales derived from the brand colours */
  --navy-950: #0E151D;
  --navy-900: #141E29;
  --navy-850: #18242F;
  --navy-800: #1F2D3D;   /* brand navy */
  --navy-700: #283A4E;
  --navy-600: #34495F;
  --navy-500: #4A6078;
  --navy-400: #8494A6;
  --navy-300: #AEB9C6;
  --navy-200: #C9D1DA;
  --navy-100: #E6EAEF;

  --ivory-0:   #FFFFFF;
  --ivory-50:  #FCFAF7;
  --ivory-100: #F8F5F0;  /* brand ivory */
  --ivory-200: #F1ECE3;
  --ivory-300: #E6DFD2;
  --ivory-400: #D3C9B7;

  --gray-800: #333333;
  --gray-700: #4B4B4B;   /* brand gray */
  --gray-600: #5F5F5F;
  --gray-500: #767676;
  --gray-400: #9A9A9A;

  --gold-800: #6F5820;   /* gold text on light surfaces */
  --gold-700: #8C7029;   /* gold icons on light surfaces */
  --gold-600: #AE8F3C;
  --gold-500: #C8A951;   /* brand gold */
  --gold-400: #D4B373;   /* brand sand (CTA) */
  --gold-300: #E3CD9D;
  --gold-200: #EFE3C6;
  --gold-100: #F8F1E1;
  --yellow-500: #EDC13D; /* brand art yellow */

  --green-700: #22694B;  --green-500: #3C9A6E;  --green-100: #E2F2E9;
  --red-700:   #A93226;  --red-500:   #E06A5E;  --red-100:   #FBE6E3;
  --amber-700: #8A5A0F;  --amber-500: #D9A13B;  --amber-100: #FAEFD9;
  --blue-700:  #2C5F86;  --blue-500:  #6FA3CC;  --blue-100:  #E2EDF6;

  /* 3. Typography, shape, motion */
  --font-ar:   'Tajawal', 'SF Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-en:   'Roboto', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  /* Roboto has no Arabic glyphs, so Latin text and digits render in Roboto and Arabic in Tajawal */
  --font-sans: 'Roboto', 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Roboto Mono', monospace;   /* document metadata, clause numbers */

  --radius-xs: 6px;  --radius-sm: 10px;  --radius-md: 14px;
  --radius-lg: 20px; --radius-xl: 28px;  --radius-pill: 999px;

  --ease: cubic-bezier(.2, .7, .2, 1);

  /* 4. SEMANTIC TOKENS — light theme (default) */
  --color-bg:             var(--ivory-100);   /* page background */
  --color-surface:        var(--ivory-0);     /* cards, panels, dialogs */
  --color-surface-2:      var(--ivory-200);   /* inputs, chips, hover fills */
  --color-surface-3:      var(--ivory-300);   /* pressed / selected fills */
  --color-border:         var(--ivory-300);
  --color-border-strong:  var(--ivory-400);
  --color-text:           var(--navy-800);    /* body & headings */
  --color-text-muted:     var(--gray-700);    /* secondary text (brand gray) */
  --color-text-subtle:    var(--gray-500);    /* hints, captions, placeholders */
  --color-icon:           var(--gold-700);    /* icons & symbols */
  --color-accent:         var(--gold-800);    /* gold text, links, highlights */
  --color-accent-bg:      var(--gold-100);    /* gold-tinted fill behind tags, banners */
  --color-art:            var(--yellow-500);  /* illustrations, chart highlights */

  /* Brand chrome: header, sidebar, hero & feature cards — navy in every theme */
  --color-chrome:           var(--navy-800);
  --color-chrome-2:         var(--navy-700);  /* hover / raised on chrome */
  --color-chrome-3:         var(--navy-600);  /* selected on chrome */
  --color-chrome-border:    rgba(248, 245, 240, .12);
  --color-on-chrome:        var(--ivory-100);
  --color-on-chrome-muted:  rgba(248, 245, 240, .70);
  --color-on-chrome-subtle: rgba(248, 245, 240, .48);
  --color-on-chrome-icon:   var(--gold-500);

  /* Call-to-action — buttons are solid --color-cta; --gradient-* are homepage-hero only */
  --color-cta:        var(--gold-400);
  --color-cta-hover:  #C9A662;
  --color-on-cta:     var(--navy-800);
  --gradient-cta:     linear-gradient(135deg, var(--gold-500), var(--gold-400));
  --gradient-chrome:  radial-gradient(620px 300px at 85% 0%, rgba(237, 193, 61, .14), transparent 70%),
                      radial-gradient(520px 260px at 0% 100%, rgba(200, 169, 81, .12), transparent 70%);
  /* faint diagonal light bands for large chrome areas (homepage hero) */
  /* soft warm glow behind the chat workspace in light mode (the other exception to flat) */
  --gradient-glow:    radial-gradient(55% 50% at 50% 42%, rgba(237, 193, 61, .13), rgba(237, 193, 61, .04) 55%, transparent 75%);
  --gradient-sheen:   linear-gradient(122deg, transparent 0 30%, rgba(248, 245, 240, .035) 30% 52%, transparent 52%),
                      linear-gradient(122deg, transparent 0 66%, rgba(248, 245, 240, .028) 66% 84%, transparent 84%);

  /* Inverse (e.g. a solid dark button on a light surface) */
  --color-inverse:    var(--navy-800);
  --color-on-inverse: var(--ivory-100);

  /* Status */
  --color-success:    var(--green-700);  --color-success-bg: var(--green-100);
  --color-danger:     var(--red-700);    --color-danger-bg:  var(--red-100);
  --color-warning:    var(--amber-700);  --color-warning-bg: var(--amber-100);
  --color-info:       var(--blue-700);   --color-info-bg:    var(--blue-100);

  --color-focus:      rgba(200, 169, 81, .45);
  --color-overlay:    rgba(14, 21, 29, .55);
  --shadow-sm: 0 1px 2px rgba(31, 45, 61, .06);
  --shadow-md: 0 8px 24px rgba(31, 45, 61, .10);
  --shadow-lg: 0 24px 60px rgba(31, 45, 61, .18);

  color-scheme: light;
}

/* DARK THEME — navy surfaces, ivory text, brand gold accents */
:root[data-theme="dark"] {
  --color-bg:             var(--navy-900);
  --color-surface:        var(--navy-850);
  --color-surface-2:      var(--navy-700);
  --color-surface-3:      var(--navy-600);
  --color-border:         rgba(248, 245, 240, .10);
  --color-border-strong:  rgba(248, 245, 240, .20);
  --color-text:           var(--ivory-100);
  --color-text-muted:     var(--navy-300);
  --color-text-subtle:    var(--navy-400);
  --color-icon:           var(--gold-500);
  --color-accent:         var(--gold-400);
  --color-accent-bg:      rgba(200, 169, 81, .16);

  --color-inverse:        var(--ivory-100);
  --color-on-inverse:     var(--navy-800);

  --color-success:    var(--green-500);  --color-success-bg: rgba(60, 154, 110, .14);
  --color-danger:     var(--red-500);    --color-danger-bg:  rgba(224, 106, 94, .14);
  --color-warning:    var(--amber-500);  --color-warning-bg: rgba(217, 161, 59, .14);
  --color-info:       var(--blue-500);   --color-info-bg:    rgba(111, 163, 204, .14);

  --color-overlay:    rgba(6, 10, 15, .65);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, .35);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, .5);

  color-scheme: dark;
}

/* Base: brand typography everywhere */
html { font-family: var(--font-sans); }
body { font-family: var(--font-sans); }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
::selection { background: var(--gold-200); color: var(--navy-800); }

/* Theme-aware logo pair: <img class="logo-on-light" …><img class="logo-on-dark" …>
   logo-on-light = navy/gold artwork for light surfaces; logo-on-dark = white artwork for
   dark surfaces. On always-navy chrome use the dark (white) artwork alone. */
:root:not([data-theme="dark"]) .logo-on-dark, [data-theme="dark"] .logo-on-light { display: none !important; }
