/* ==========================================================================
   Foodia Hala — Design Tokens
   Single source of truth for color, spacing, radius, shadow and type scale.
   Light values are the default; dark values apply under [data-theme="dark"]
   or prefers-color-scheme: dark (when no explicit data-theme is set).
   ========================================================================== */

:root {
    /* Brand ramp */
    --primary-900: #09162F;
    --primary-800: #12365F;
    --primary-700: #1C4E92;
    --primary-600: #165AA5; /* brand */
    --primary-500: #2F6EBE;
    --primary-400: #5D92D8;
    --primary-300: #9FC2F1;
    --primary-200: #D8E8FB;
    --primary-100: #F3F8FF;

    --brand-gradient: linear-gradient(135deg, #09162F 0%, #165AA5 55%, #5D92D8 100%);

    /* Neutrals (light) */
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-surface-raised: #FFFFFF;
    --color-border: #E2E8F0;
    --color-divider: #CBD5E1;
    --color-text: #0F172A;
    --color-text-secondary: #64748B;
    --color-text-disabled: #94A3B8;

    /* Status */
    --success-600: #16A34A;
    --success-500: #22C55E;
    --success-100: #DCFCE7;
    --warning-600: #F59E0B;
    --warning-500: #FBBF24;
    --warning-100: #FEF3C7;
    --error-600: #DC2626;
    --error-500: #EF4444;
    --error-100: #FEE2E2;
    --info-600: #0EA5E9;
    --info-500: #38BDF8;
    --info-100: #E0F2FE;

    /* Sidebar */
    --sidebar-bg: #09162F;
    --sidebar-hover: #12365F;
    --sidebar-selected: #165AA5;
    --sidebar-icon: #FFFFFF;
    --sidebar-text: #E2E8F0;

    /* Buttons */
    --btn-primary-bg: #165AA5;
    --btn-primary-hover: #1C4E92;
    --btn-primary-pressed: #12365F;
    --btn-secondary-border: #165AA5;
    --btn-ghost-hover: #F3F8FF;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(9, 22, 47, .06);
    --shadow-md: 0 4px 12px rgba(9, 22, 47, .07);
    --shadow-lg: 0 8px 24px rgba(9, 22, 47, .08);
    --shadow-xl: 0 16px 40px rgba(9, 22, 47, .12);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 18px;
    --radius-pill: 999px;

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

    /* Typography */
    --font-sans: "Segoe UI", "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 16px;
    --text-lg: 18px;
    --text-xl: 22px;
    --text-2xl: 28px;
    --text-3xl: 34px;

    /* Motion */
    --ease-standard: cubic-bezier(.2, .8, .2, 1);
    --duration-fast: 120ms;
    --duration-base: 180ms;
    --duration-slow: 280ms;

    color-scheme: light;
}

/* Arabic UI font. Self-hosted variable font (one file per script, split by unicode-range), and only referenced under
   [lang="ar"] below, so the browser downloads nothing of it while the app is in English. */
@font-face {
    font-family: "Cairo";
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("../fonts/cairo-arabic.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: "Cairo";
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("../fonts/cairo-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Cairo";
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("../fonts/cairo-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root[lang="ar"] {
    --font-sans: "Cairo", "Segoe UI", "Tahoma", Arial, sans-serif;
}

/* Dark theme overrides — activated by explicit toggle (data-theme) or OS preference */
:root[data-theme="dark"] {
    --color-bg: #0B1220;
    --color-surface: #121B2E;
    --color-surface-raised: #16213A;
    --color-border: #23304A;
    --color-divider: #2C3B58;
    --color-text: #F1F5F9;
    --color-text-secondary: #94A3B8;
    --color-text-disabled: #5B6B85;

    --success-100: #123422;
    --warning-100: #3A2A0C;
    --error-100: #3B1616;
    --info-100: #0E2A3B;

    --btn-ghost-hover: #16213A;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .38);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, .42);
    --shadow-xl: 0 18px 44px rgba(0, 0, 0, .5);

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --color-bg: #0B1220;
        --color-surface: #121B2E;
        --color-surface-raised: #16213A;
        --color-border: #23304A;
        --color-divider: #2C3B58;
        --color-text: #F1F5F9;
        --color-text-secondary: #94A3B8;
        --color-text-disabled: #5B6B85;

        --success-100: #123422;
        --warning-100: #3A2A0C;
        --error-100: #3B1616;
        --info-100: #0E2A3B;

        --btn-ghost-hover: #16213A;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow-md: 0 4px 14px rgba(0, 0, 0, .38);
        --shadow-lg: 0 8px 28px rgba(0, 0, 0, .42);
        --shadow-xl: 0 18px 44px rgba(0, 0, 0, .5);

        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-text);
}

a { color: var(--primary-600); }

::selection {
    background: var(--primary-300);
    color: var(--primary-900);
}

/* Visible focus ring everywhere (WCAG) */
:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--color-divider);
    border-radius: var(--radius-pill);
    border: 2px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-text-disabled); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
