/* ==========================================================================
   arHSEman — Shared Design Tokens & Base Styles
   Single source of truth for colors, spacing and base resets.
   Linked from every page: <link rel="stylesheet" href="assets/css/theme.css">
   (adjust the relative path per folder depth: "../assets/css/theme.css" from
   /modules or /apps, "assets/css/theme.css" from the project root)

   Palette is derived from the arHSEman logo: navy (shield/"A") + green (leaf).
   Variable NAMES are unchanged from the original inline stylesheets so this
   file can be dropped in without touching any page's markup or JS logic —
   only the <style> block that declared these tokens is removed from each
   page and replaced with a <link> to this file.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100;300;400;500;600;700;900&display=swap');

/* ============================================
   THEME VARIABLES — DARK (default)
============================================ */
:root {
    --bg-deep: #0a0a0b;
    --bg-surface: #141416;
    --bg-elevated: #1c1c1f;
    --bg-hover: #242428;
    --border-subtle: rgba(63, 145, 66, 0.12);
    --border-soft: rgba(255, 255, 255, 0.06);

    /* Primary brand accent (from logo) */
    --gold: #3f9142;
    --gold-soft: #8ed08f;
    --gold-deep: #2f6b31;
    --gold-glow: rgba(63, 145, 66, 0.25);

    --text-primary: #f5f5f0;
    --text-secondary: #a0a0a5;
    --text-muted: #6b6b70;

    /* Module accent colors */
    --health: #10b981;
    --chemical: #2a4f97;
    --training: #fbbf24;
    --risk: #f472b6;
    --assistant: #3b82f6;
    --pricing: #ec4899;
    --software: #06b6d4;

    --body-bg-radial-1: rgba(63, 145, 66, 0.08);
    --body-bg-radial-2: rgba(42, 79, 151, 0.05);
    --card-bg: linear-gradient(180deg, #141416 0%, #0a0a0b 100%);
    --shadow-color: rgba(0, 0, 0, 0.4);

    /* Glass navbar */
    --navbar-bg: rgba(10, 10, 11, 0.75);
    --navbar-border: rgba(63, 145, 66, 0.15);
    --navbar-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --nav-item-bg: transparent;
    --nav-item-hover-bg: rgba(255, 255, 255, 0.05);
    --nav-item-active-bg: linear-gradient(135deg, rgba(63, 145, 66, 0.15), rgba(63, 145, 66, 0.05));
    --nav-item-active-border: rgba(63, 145, 66, 0.3);
    --nav-icon-bg: rgba(255, 255, 255, 0.05);
    --nav-icon-active-bg: linear-gradient(135deg, rgba(63, 145, 66, 0.2), rgba(63, 145, 66, 0.05));
    --logo-bg: rgba(255, 255, 255, 0.05);
    --logo-border: rgba(63, 145, 66, 0.2);
    --mobile-menu-bg: rgba(10, 10, 11, 0.95);
    --mobile-menu-border: rgba(63, 145, 66, 0.15);
    --hamburger-color: var(--gold-soft);
    --danger: #ef4444;

    /* Standardized spacing / radius / shadow scale (new — additive, for
       any new component work; existing pages are unaffected). */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
    --shadow-soft-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-soft-md: 0 12px 32px rgba(0, 0, 0, 0.30);
    --shadow-soft-lg: 0 20px 48px rgba(0, 0, 0, 0.35);
}

/* ============================================
   THEME VARIABLES — LIGHT
============================================ */
[data-theme="light"] {
    --bg-deep: #f8fafc;
    --bg-surface: #ffffff;
    --bg-elevated: #f1f5f9;
    --bg-hover: #e2e8f0;
    --border-subtle: rgba(63, 145, 66, 0.3);
    --border-soft: rgba(0, 0, 0, 0.08);

    --gold: #2a4f97;
    --gold-soft: #1c3d78;
    --gold-deep: #16305f;
    --gold-glow: rgba(42, 79, 151, 0.2);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --health: #059669;
    --chemical: #1c3d78;
    --training: #d97706;
    --risk: #db2777;
    --assistant: #2563eb;
    --pricing: #be185d;
    --software: #0891b2;

    --body-bg-radial-1: rgba(42, 79, 151, 0.06);
    --body-bg-radial-2: rgba(28, 61, 120, 0.04);
    --card-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    --shadow-color: rgba(0, 0, 0, 0.08);

    --navbar-bg: rgba(255, 255, 255, 0.8);
    --navbar-border: rgba(63, 145, 66, 0.25);
    --navbar-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --nav-item-bg: transparent;
    --nav-item-hover-bg: rgba(0, 0, 0, 0.03);
    --nav-item-active-bg: linear-gradient(135deg, rgba(42, 79, 151, 0.12), rgba(42, 79, 151, 0.04));
    --nav-item-active-border: rgba(42, 79, 151, 0.4);
    --nav-icon-bg: rgba(0, 0, 0, 0.04);
    --nav-icon-active-bg: linear-gradient(135deg, rgba(42, 79, 151, 0.15), rgba(42, 79, 151, 0.05));
    --logo-bg: rgba(0, 0, 0, 0.03);
    --logo-border: rgba(42, 79, 151, 0.3);
    --mobile-menu-bg: rgba(255, 255, 255, 0.98);
    --mobile-menu-border: rgba(63, 145, 66, 0.2);
    --hamburger-color: var(--gold-soft);
    --danger: #dc2626;

    --shadow-soft-sm: 0 2px 8px rgba(15, 34, 71, 0.06);
    --shadow-soft-md: 0 12px 32px rgba(15, 34, 71, 0.10);
    --shadow-soft-lg: 0 20px 48px rgba(15, 34, 71, 0.14);
}

/* ============================================
   BASE RESET
============================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
    transition: background 0.5s ease, color 0.5s ease;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 20% 0%, var(--body-bg-radial-1), transparent 50%),
                radial-gradient(ellipse 60% 50% at 80% 100%, var(--body-bg-radial-2), transparent 50%);
    pointer-events: none;
    z-index: 0;
    transition: background 0.5s ease;
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

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

/* ==========================================================================
   📱 PWA / NATIVE-APP FEEL — shared across every page
   (install FAB, bottom sheet, responsive tables, chip multi-select,
   iOS/Android native scroll & touch behaviors)
   ========================================================================== */

/* لبه‌های صفحه (Notch / نوار حرکتی) روی گوشی‌های جدید */
html { overscroll-behavior: contain; }
body { overscroll-behavior-y: contain; }

/* جلوگیری از زوم خودکار iOS روی فرم‌ها هنگام فوکوس (باید حداقل ۱۶px باشد) */
@media (max-width: 768px) {
    input, select, textarea { font-size: 16px !important; }
}

/* هایلایت لمسی مرورگر روی دکمه/آیکون غیرفعال، ولی متن قابل انتخاب بماند */
button, a, .nav-item, .bottom-nav-item, .tab-bar-item, [role="button"] {
    -webkit-user-select: none;
    user-select: none;
}
input, textarea, [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
}

/* ============================================
   🟢 دکمه شناور «نصب اپلیکیشن»
   فقط زمانی نمایش داده می‌شود که مرورگر رویداد beforeinstallprompt را
   ارسال کند (توسط assets/js/theme.js مدیریت می‌شود).
============================================ */
.pwa-install-fab {
    position: fixed;
    left: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    z-index: 1200;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--nav-item-active-border);
    border-radius: 999px;
    background: linear-gradient(135deg, var(--gold-soft), var(--gold));
    color: var(--bg-deep);
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 10px 24px var(--gold-glow), 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: pwaFabIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.pwa-install-fab.is-visible { display: inline-flex; }
.pwa-install-fab:active { transform: scale(0.96); }
.pwa-install-fab .pwa-fab-icon { font-size: 16px; }
.pwa-install-fab .pwa-fab-close {
    margin-right: 2px;
    margin-left: -4px;
    opacity: 0.7;
    font-size: 14px;
    padding: 2px 4px;
}
@keyframes pwaFabIn {
    from { opacity: 0; transform: translateY(12px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (min-width: 1025px) {
    .pwa-install-fab { bottom: 24px; left: 24px; }
}

/* ============================================
   🗂️ Bottom Sheet عمومی («بیشتر» و هر پنل کشویی دیگر)
============================================ */
.app-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.app-sheet-overlay.is-open { opacity: 1; pointer-events: auto; }

.app-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1401;
    max-height: 78vh;
    overflow-y: auto;
    background: var(--mobile-menu-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--mobile-menu-border);
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.4);
    padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
.app-sheet.is-open { transform: translateY(0); }

.app-sheet-handle {
    width: 40px; height: 4px;
    border-radius: 4px;
    background: var(--border-soft);
    margin: 6px auto 14px;
}
.app-sheet-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin: 0 4px 12px;
}
.app-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.app-sheet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 6px;
    border-radius: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}
.app-sheet-item:active { transform: scale(0.95); }
.app-sheet-item.active {
    background: var(--nav-item-active-bg);
    border-color: var(--nav-item-active-border);
    color: var(--text-primary);
}
.app-sheet-item .asi-icon { font-size: 22px; }
.app-sheet-item.danger { color: var(--danger); }

.app-sheet-divider {
    height: 1px;
    background: var(--border-soft);
    margin: 14px 2px;
}

/* ============================================
   📋 جدول‌های واکنش‌گرا → کارت در موبایل
   assets/js/theme.js برچسب‌های data-label را از thead می‌سازد.
============================================ */
@media (max-width: 640px) {
    table.rt-cards { border: none !important; }
    table.rt-cards thead { display: none; }
    table.rt-cards, table.rt-cards tbody, table.rt-cards tr, table.rt-cards td {
        display: block;
        width: 100% !important;
    }
    table.rt-cards tr {
        margin-bottom: 12px;
        padding: 10px 12px;
        border-radius: 14px;
        background: var(--bg-elevated);
        border: 1px solid var(--border-soft);
    }
    table.rt-cards td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: 7px 2px !important;
        border: none !important;
        text-align: right !important;
        font-size: 13px;
    }
    table.rt-cards td:not(:last-child) {
        border-bottom: 1px dashed var(--border-soft) !important;
    }
    table.rt-cards td::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 11px;
    }
    table.rt-cards td[data-label=""]::before,
    table.rt-cards td:not([data-label])::before { content: none; }
}

/* ============================================
   🔘 گروه چیپ برای انتخاب چندگانه (جایگزین select multiple)
============================================ */
.chip-select-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chip-select-option {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: all 0.2s ease;
}
.chip-select-option.selected {
    background: var(--nav-item-active-bg);
    border-color: var(--nav-item-active-border);
    color: var(--text-primary);
    font-weight: 600;
}
.chip-select-option:active { transform: scale(0.96); }
