/* =========================================================
   TRADINEX — Design Tokens
   Logical properties used throughout so [dir="rtl"] flips
   layout automatically without a separate RTL stylesheet.
   ========================================================= */

:root {
    /* Deep Navy / Dark Blue — dominant structural identity */
    --color-navy-deep: #050F1A;
    --color-blue-darker: #050F1A;
    --color-blue-dark: #0A2338;
    --color-blue: #0F3D5F;
    --color-navy-light: #16496E;

    /* Industrial Green — primary action / CTA color (replaces the retired orange) */
    --color-green: #1E8449;
    --color-green-dark: #146334;
    --color-green-light: #5CBE7E;

    /* Lime — sparing accent: glows, highlights, small decorative details only,
       never a fill color for large surfaces or primary buttons */
    --color-lime: #9ACD32;
    --color-lime-dark: #7CAA24;

    --color-white: #FFFFFF;
    --color-gray-light: #F3F5F7;
    --color-gray-mid: #9CA8B4;
    --color-gray-dark: #37424F;
    --color-black: #060A0E;

    /* Legacy aliases — kept so existing component CSS (topbar/header/footer
       written during Phase 2/3) continues to resolve correctly without a
       rewrite. --color-orange now maps to industrial green: every previous
       "CTA fill" reference automatically becomes the new action color. */
    --color-navy: var(--color-blue);
    --color-navy-dark: var(--color-blue-dark);
    --color-orange: var(--color-green);
    --color-orange-dark: var(--color-green-dark);

    --font-arabic: 'Cairo', 'IBM Plex Sans Arabic', 'Noto Sans Arabic', sans-serif;
    --font-latin: 'Inter', 'Manrope', sans-serif;

    --space-xs: 8px;
    --space-sm: 16px;
    --space-md: 24px;
    --space-lg: 40px;
    --space-xl: 64px;
    --space-2xl: 96px;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;

    --transition-fast: 150ms ease;
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    --shadow-card: 0 8px 28px rgba(5, 15, 26, 0.14);
    --shadow-card-hover: 0 20px 48px rgba(5, 15, 26, 0.22);
    --shadow-glow-green: 0 0 32px rgba(30, 132, 73, 0.35);

    /* Semantic status tokens. --color-error uses the exact hex value that
       was previously hardcoded in 6 places (layout.css, pages.css,
       admin.css) — zero visual change, just consolidated into one token.
       Success/Warning/Info had no prior dedicated hardcoded usage, so
       they reuse already-established palette colors rather than
       introducing new hues. */
    --color-error: #e5484d;
    --color-success: var(--color-green);
    --color-warning: var(--color-lime);
    --color-info: var(--color-blue);

    /* Hero gradient middle stop — previously hardcoded as #0C2C46 inline
       in the .hero background rule. Same exact value, now tokenized so
       it can be theme-managed without a mismatched, non-updating stop. */
    --color-hero-gradient-mid: #0C2C46;
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --transition-fast: 0ms;
        --transition-base: 0ms;
    }
}

/* Dark mode is the brand's natural home (industrial/night imagery),
   Navy/Green/Lime remain identical in both modes —
   only surface/background/text values change. */
[data-theme="dark"] {
    --color-bg: var(--color-navy-deep);
    --color-surface: #0C2A42;
    --color-surface-alt: #103450;
    --color-text: var(--color-white);
    --color-text-muted: var(--color-gray-mid);
    --color-border: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
    --color-bg: var(--color-white);
    --color-surface: var(--color-gray-light);
    --color-surface-alt: #E9EDF1;
    --color-text: var(--color-blue-dark);
    --color-text-muted: #5B6B7A;
    --color-border: rgba(6, 29, 49, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px; /* accessibility: never below 16px base */
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    margin: 0;
    background: var(--color-bg, var(--color-white));
    color: var(--color-text, var(--color-navy-dark));
    font-family: var(--font-latin);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden; /* safety net against any unforeseen narrow-viewport overflow */
}

html[lang="ar"] body {
    font-family: var(--font-arabic);
    line-height: 1.85; /* Arabic script needs more vertical room than Latin */
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.01em;
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3,
html[lang="ar"] h4 {
    line-height: 1.5;
    letter-spacing: 0; /* letter-spacing is a Latin-script concept, not applicable to Arabic */
    font-weight: 700; /* Cairo's 800 weight can look heavy at Arabic display sizes */
}

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

a {
    color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-lime);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-block: 12px;
    padding-inline: var(--space-md);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: 0.01em;
    min-height: 46px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-base), background-color var(--transition-fast), border-color var(--transition-fast), filter var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-blue), var(--color-blue-dark));
    color: var(--color-white);
    box-shadow: 0 4px 14px rgba(10, 35, 56, 0.28);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(10, 35, 56, 0.38);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-cta {
    background: linear-gradient(135deg, var(--color-green), var(--color-green-dark));
    color: var(--color-white);
    box-shadow: 0 4px 14px rgba(30, 132, 73, 0.32);
}

.btn-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(30, 132, 73, 0.42);
}

.btn-cta:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(30, 132, 73, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-white);
    border-color: rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(4px);
}

.btn-secondary:hover {
    border-color: var(--color-green-light);
    color: var(--color-green-light);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.btn-outline-green {
    background: transparent;
    color: var(--color-green);
    border-color: var(--color-green);
}

.btn-outline-green:hover {
    background: var(--color-green);
    color: var(--color-white);
    transform: translateY(-2px);
}

/* Text CTA: arrow + animated underline, no fill. Flips direction automatically in RTL. */
.btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 0;
    min-height: auto;
    color: var(--color-green);
    font-weight: 700;
    text-decoration: none;
    position: relative;
}

.btn-text::after {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    inset-block-end: -3px;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width var(--transition-base);
}

.btn-text:hover::after {
    width: 100%;
}

.btn-text .arrow {
    display: inline-block;
    transition: transform var(--transition-fast);
}

[dir="rtl"] .btn-text .arrow {
    transform: scaleX(-1);
}

.btn-text:hover .arrow {
    transform: translateX(4px);
}

[dir="rtl"] .btn-text:hover .arrow {
    transform: scaleX(-1) translateX(4px);
}

.btn:focus-visible {
    outline: 2px solid var(--color-lime);
    outline-offset: 2px;
}

/* Disabled state — applies uniformly across every button variant */
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

/* Ghost button — lowest visual weight, for tertiary/dismissive actions
   (e.g. "cancel", "skip"). No fill, no border, minimal presence. */
.btn-ghost {
    background: transparent;
    color: var(--color-text, var(--color-blue-dark));
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--color-surface, var(--color-gray-light));
}

[data-theme="dark"] .btn-ghost {
    color: var(--color-white);
}

[data-theme="dark"] .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Icon button — square, for standalone icon-only actions (scroll-top,
   close, etc.) with a mandatory accessible label via aria-label. */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
    background: var(--color-surface, var(--color-gray-light));
    color: var(--color-text, var(--color-blue-dark));
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.btn-icon:hover {
    transform: translateY(-2px);
    border-color: var(--color-green);
    color: var(--color-green);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.error-page {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    text-align: center;
    padding: var(--space-lg);
}

.error-page h1 {
    font-size: 4rem;
    margin: 0;
    color: var(--color-blue);
}
