/**
 * WAQTUM design system — the single source of truth for tokens and primitives.
 *
 * Implements §2 (colour), §3 (typography), §6.3 (status badges), §7.1 (progress
 * steps), §8 (OTP inputs), §11.2 (RTL logical properties), §12 (components),
 * §13.3 (bottom sheet) and §14.2 (trust badges) of WAQTUM_UI_UX_Design_Guide.md.
 *
 * Before this file the palette was copy-pasted into four layouts and had drifted
 * apart: --waqtum-bg was #EEF2F7 in all of them against the guide's #F5F7FA,
 * --waqtum-border was #D1DCE8 against #DDE2E8, and layouts/superadmin.blade.php
 * declared no tokens at all. Each layout keeps its own <style> block for
 * layout-specific rules, but the tokens live here only.
 *
 * Loaded as a plain stylesheet, not through Vite: no layout references @vite
 * (vite.config.js builds app.css/app.js, which nothing includes), so a static
 * file under public/ deploys with a git pull and no build step.
 */

:root {
    /* ---- Primary: royal indigo (trust, authority, formality) ---- */
    --waqtum-primary: #1A3C5E;
    --waqtum-primary-light: #2A5F96;
    --waqtum-primary-dark: #0F2540;

    /* ---- Gold (value, Gulf character, distinction) ---- */
    --waqtum-gold: #C9A84C;
    --waqtum-gold-light: #E2C97A;
    --waqtum-gold-dark: #A07D2B;

    /* ---- Semantic ---- */
    --waqtum-success: #27AE60; /* approved */
    --waqtum-danger: #C0392B;  /* rejected */
    --waqtum-warning: #E67E22; /* pending */
    --waqtum-info: #2980B9;    /* for review */
    --waqtum-purple: #7B1FA2;  /* confidential / expired */

    /* ---- Neutrals ---- */
    --waqtum-bg: #F5F7FA;
    --waqtum-surface: #FFFFFF;
    --waqtum-border: #DDE2E8;

    /* ---- Text ----
     * The guide names a third tier #9AA3B0, but that is 2.6:1 on white and so
     * fails the guide's own 4.5:1 floor (§15.4). It is kept as --waqtum-text-subtle
     * for decorative captions only; --waqtum-text-muted, which existing views use
     * for real secondary copy, points at the accessible tier instead.
     */
    --waqtum-text-primary: #1A1A2E;
    --waqtum-text-secondary: #5A6478;
    --waqtum-text-subtle: #9AA3B0;

    /* ---- Shape and depth ---- */
    --waqtum-radius: 12px;
    --waqtum-radius-sm: 8px;
    --waqtum-radius-lg: 16px;
    --waqtum-shadow: 0 2px 16px rgba(26, 60, 94, 0.10);
    --waqtum-shadow-hover: 0 8px 30px rgba(26, 60, 94, 0.18);
    --waqtum-shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
    --waqtum-shadow-float: 0 4px 20px rgba(0, 0, 0, 0.08);

    /* ---- Layout metrics ---- */
    --waqtum-sidebar-width: 260px;
    --waqtum-sidebar-collapsed-width: 70px;
    --waqtum-navbar-height: 72px;

    /* ---- Aliases kept so existing views keep rendering ----
     * --waqtum-accent appears 23 times, --waqtum-text 11, --waqtum-primary-hover 6.
     */
    --waqtum-accent: var(--waqtum-gold);
    --waqtum-accent-light: var(--waqtum-gold-light);
    --waqtum-text: var(--waqtum-text-primary);
    --waqtum-text-muted: var(--waqtum-text-secondary);
    --waqtum-primary-hover: var(--waqtum-primary-light);
    --waqtum-pending: var(--waqtum-purple);

    /* ---- Type scale (§3), Arabic sizes; English overridden below ---- */
    --waqtum-fs-display: 48px;
    --waqtum-fs-h1: 36px;
    --waqtum-fs-h2: 28px;
    --waqtum-fs-h3: 22px;
    --waqtum-fs-h4: 18px;
    --waqtum-fs-body-lg: 17px;
    --waqtum-fs-body: 15px;
    --waqtum-fs-small: 13px;
    --waqtum-fs-caption: 11px;
}

/* Latin text runs one step smaller at the same optical weight */
[lang="en"] {
    --waqtum-fs-display: 44px;
    --waqtum-fs-h1: 34px;
    --waqtum-fs-h2: 26px;
    --waqtum-fs-h3: 20px;
    --waqtum-fs-h4: 17px;
    --waqtum-fs-body-lg: 16px;
    --waqtum-fs-body: 14px;
    --waqtum-fs-small: 12px;
}

/* ──────────────── Typography ──────────────── */

[dir="rtl"],
[lang="ar"] {
    font-family: 'Tajawal', 'Tahoma', sans-serif;
}

[dir="ltr"],
[lang="en"] {
    font-family: 'Poppins', 'Arial', sans-serif;
}

.signature-typed {
    font-family: 'Dancing Script', cursive;
    font-weight: 700;
}

.waqtum-display {
    font-size: var(--waqtum-fs-display);
    font-weight: 800;
    line-height: 1.2;
}

.waqtum-h1 { font-size: var(--waqtum-fs-h1); font-weight: 700; line-height: 1.25; }
.waqtum-h2 { font-size: var(--waqtum-fs-h2); font-weight: 700; line-height: 1.3; }
.waqtum-h3 { font-size: var(--waqtum-fs-h3); font-weight: 600; line-height: 1.35; }
.waqtum-h4 { font-size: var(--waqtum-fs-h4); font-weight: 600; line-height: 1.4; }

.waqtum-body-lg { font-size: var(--waqtum-fs-body-lg); font-weight: 400; line-height: 1.7; }
.waqtum-body { font-size: var(--waqtum-fs-body); font-weight: 400; line-height: 1.65; }
.waqtum-small { font-size: var(--waqtum-fs-small); font-weight: 400; }
.waqtum-caption { font-size: var(--waqtum-fs-caption); color: var(--waqtum-text-subtle); }

/* ──────────────── RTL: logical properties (§11.2) ──────────────── */

.waqtum-ms-1 { margin-inline-start: 0.25rem; }
.waqtum-ms-2 { margin-inline-start: 0.5rem; }
.waqtum-ms-3 { margin-inline-start: 1rem; }
.waqtum-me-1 { margin-inline-end: 0.25rem; }
.waqtum-me-2 { margin-inline-end: 0.5rem; }
.waqtum-me-3 { margin-inline-end: 1rem; }

/* An icon sits after the text in LTR and before it in RTL without extra markup */
.icon-before { margin-inline-end: 8px; }
.icon-after { margin-inline-start: 8px; }

/* Directional glyphs must mirror; symmetric ones must not */
[dir="rtl"] .arrow-flip { transform: scaleX(-1); }

[dir="rtl"] table { text-align: right; }
[dir="ltr"] table { text-align: left; }

/* ──────────────── Buttons (§12.2) ──────────────── */

.btn-waqtum-primary,
.btn-waqtum-secondary,
.btn-waqtum-gold,
.btn-waqtum-success,
.btn-waqtum-danger,
.btn-waqtum-ghost {
    border-radius: var(--waqtum-radius-sm);
    font-weight: 600;
    border: 1.5px solid transparent;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease,
        box-shadow 0.18s ease;
}

.btn-waqtum-primary {
    background-color: var(--waqtum-primary);
    border-color: var(--waqtum-primary);
    color: #fff;
}

.btn-waqtum-primary:hover,
.btn-waqtum-primary:focus {
    background-color: var(--waqtum-primary-light);
    border-color: var(--waqtum-primary-light);
    color: #fff;
}

.btn-waqtum-secondary {
    background-color: var(--waqtum-surface);
    border-color: var(--waqtum-primary);
    color: var(--waqtum-primary);
}

.btn-waqtum-secondary:hover,
.btn-waqtum-secondary:focus {
    background-color: var(--waqtum-primary);
    color: #fff;
}

/* The primary call to action — gold on indigo, per the colour usage table (§2) */
.btn-waqtum-gold {
    background-color: var(--waqtum-gold);
    border-color: var(--waqtum-gold);
    color: var(--waqtum-primary);
    font-weight: 700;
}

.btn-waqtum-gold:hover,
.btn-waqtum-gold:focus {
    background-color: var(--waqtum-gold-light);
    border-color: var(--waqtum-gold-light);
    color: var(--waqtum-primary);
}

.btn-waqtum-success {
    background-color: var(--waqtum-success);
    border-color: var(--waqtum-success);
    color: #fff;
}

.btn-waqtum-success:hover,
.btn-waqtum-success:focus {
    background-color: #1f8f4e;
    border-color: #1f8f4e;
    color: #fff;
}

/* Rejection reads as an outline, not a filled button: destructive but not primary */
.btn-waqtum-danger {
    background-color: var(--waqtum-surface);
    border-color: var(--waqtum-danger);
    border-width: 2px;
    color: var(--waqtum-danger);
}

.btn-waqtum-danger:hover,
.btn-waqtum-danger:focus {
    background-color: var(--waqtum-danger);
    color: #fff;
}

.btn-waqtum-ghost {
    background-color: var(--waqtum-surface);
    border-color: var(--waqtum-border);
    color: var(--waqtum-text-secondary);
}

.btn-waqtum-ghost:hover,
.btn-waqtum-ghost:focus {
    background-color: var(--waqtum-bg);
    color: var(--waqtum-text-primary);
}

.btn-waqtum-sm { padding: 7px 16px; font-size: var(--waqtum-fs-small); }
.btn-waqtum-md { padding: 11px 24px; font-size: var(--waqtum-fs-body); }
.btn-waqtum-lg { padding: 16px 40px; font-size: 18px; border-radius: var(--waqtum-radius-sm); }

/* Keyboard focus must stay visible on every variant (§15.4) */
.btn-waqtum-primary:focus-visible,
.btn-waqtum-secondary:focus-visible,
.btn-waqtum-gold:focus-visible,
.btn-waqtum-success:focus-visible,
.btn-waqtum-danger:focus-visible,
.btn-waqtum-ghost:focus-visible {
    outline: 3px solid var(--waqtum-gold);
    outline-offset: 2px;
}

/* ──────────────── Language toggle (§4.1) ──────────────── */

.waqtum-lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: var(--waqtum-fs-small);
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.waqtum-lang-toggle.on-dark {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.waqtum-lang-toggle.on-dark:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
}

.waqtum-lang-toggle.on-light {
    color: var(--waqtum-primary);
    border: 1px solid var(--waqtum-border);
}

.waqtum-lang-toggle.on-light:hover {
    background: var(--waqtum-bg);
    border-color: var(--waqtum-primary);
    color: var(--waqtum-primary);
}

/* ──────────────── Sticky navbar (§4.1) ──────────────── */

.waqtum-navbar {
    height: var(--waqtum-navbar-height);
    background: var(--waqtum-primary);
    position: sticky;
    top: 0;
    z-index: 1030;
    transition: box-shadow 0.2s ease;
}

.waqtum-navbar.scrolled {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.waqtum-navbar .nav-link {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}

.waqtum-navbar .nav-link:hover,
.waqtum-navbar .nav-link:focus,
.waqtum-navbar .nav-link.active {
    color: #fff;
}

/* ──────────────── Status badges (§6.3) ──────────────── */

.waqtum-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: var(--waqtum-fs-small);
    font-weight: 600;
    white-space: nowrap;
}

.waqtum-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.badge-pending { background: #FFF3E0; color: var(--waqtum-warning); border: 1px solid var(--waqtum-warning); }
.badge-approved { background: #E8F5E9; color: var(--waqtum-success); border: 1px solid var(--waqtum-success); }
.badge-rejected { background: #FFEBEE; color: var(--waqtum-danger); border: 1px solid var(--waqtum-danger); }
.badge-draft { background: #F3F4F6; color: var(--waqtum-text-secondary); border: 1px solid var(--waqtum-border); }
.badge-expired { background: #F3E5F5; color: var(--waqtum-purple); border: 1px solid var(--waqtum-purple); }
.badge-review { background: #E3F2FD; color: var(--waqtum-info); border: 1px solid var(--waqtum-info); }

/* ──────────────── Cards ──────────────── */

.waqtum-surface {
    background: var(--waqtum-surface);
    border: 1px solid var(--waqtum-border);
    border-radius: var(--waqtum-radius);
    box-shadow: var(--waqtum-shadow-card);
}

/* Stats card: a coloured rule along the top edge, DocuSign-style (§6.2) */
.waqtum-stat {
    background: var(--waqtum-surface);
    border-radius: var(--waqtum-radius);
    padding: 24px;
    box-shadow: var(--waqtum-shadow-card);
    border-top: 4px solid var(--waqtum-primary);
}

.waqtum-stat-total { border-top-color: var(--waqtum-primary); }
.waqtum-stat-pending { border-top-color: var(--waqtum-warning); }
.waqtum-stat-approved { border-top-color: var(--waqtum-success); }
.waqtum-stat-rejected { border-top-color: var(--waqtum-danger); }

.waqtum-stat-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--waqtum-text-primary);
}

.waqtum-stat-label {
    font-size: var(--waqtum-fs-small);
    color: var(--waqtum-text-secondary);
}

.waqtum-stat-delta { font-size: var(--waqtum-fs-small); font-weight: 600; }
.waqtum-stat-delta.up { color: var(--waqtum-success); }
.waqtum-stat-delta.down { color: var(--waqtum-danger); }
.waqtum-stat-delta.live { color: var(--waqtum-warning); }

/* ──────────────── Progress steps (§7.1) ──────────────── */

.waqtum-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.waqtum-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.waqtum-step-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--waqtum-fs-small);
    background: var(--waqtum-border);
    color: var(--waqtum-text-secondary);
    border: 2px solid var(--waqtum-border);
}

.waqtum-step.active .waqtum-step-dot {
    background: var(--waqtum-gold);
    border-color: var(--waqtum-gold);
    color: var(--waqtum-primary);
}

.waqtum-step.done .waqtum-step-dot {
    background: var(--waqtum-success);
    border-color: var(--waqtum-success);
    color: #fff;
}

.waqtum-step-label {
    font-size: var(--waqtum-fs-small);
    color: var(--waqtum-text-secondary);
}

.waqtum-step.active .waqtum-step-label {
    color: var(--waqtum-text-primary);
    font-weight: 600;
}

/* The connector is direction-agnostic, so it needs no RTL flip */
.waqtum-step-line {
    height: 2px;
    width: 56px;
    background: var(--waqtum-border);
    margin-bottom: 22px;
}

.waqtum-step-line.done { background: var(--waqtum-success); }

/* ──────────────── OTP inputs (§8) ──────────────── */

.otp-input {
    width: 56px;
    height: 64px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--waqtum-border);
    border-radius: 10px;
    margin: 0 6px;
    transition: all 0.2s ease;
}

.otp-input:focus {
    border-color: var(--waqtum-primary);
    box-shadow: 0 0 0 4px rgba(26, 60, 94, 0.12);
    outline: none;
}

.otp-input.filled {
    border-color: var(--waqtum-gold);
    background: rgba(201, 168, 76, 0.06);
}

.otp-input.error {
    border-color: var(--waqtum-danger);
    animation: waqtum-shake 0.4s ease;
}

@keyframes waqtum-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
    .otp-input.error { animation: none; }
}

@media (max-width: 576px) {
    .otp-input {
        width: 44px;
        height: 54px;
        font-size: 22px;
        margin: 0 3px;
    }
}

/* ──────────────── Trust badges (§14.2) ──────────────── */

.trust-badges {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.trust-badge {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    white-space: nowrap;
}

/* On a light surface the same badge needs the inverse treatment */
.trust-badge.on-light {
    color: var(--waqtum-text-secondary);
    border-color: var(--waqtum-border);
}

/* ──────────────── Bottom sheet for mobile tools (§13.3) ──────────────── */

.tools-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--waqtum-surface);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1045;
}

.tools-bottom-sheet.open { transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
    .tools-bottom-sheet { transition: none; }
}

/* ──────────────── Accessibility (§15.4) ──────────────── */

.waqtum-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reaching the main content without tabbing the whole sidebar */
.waqtum-skip-link {
    position: absolute;
    inset-inline-start: -9999px;
    top: 0;
    z-index: 2000;
    padding: 10px 18px;
    background: var(--waqtum-primary);
    color: #fff;
    border-end-end-radius: var(--waqtum-radius-sm);
}

.waqtum-skip-link:focus {
    inset-inline-start: 0;
    color: #fff;
}
