/* سبک‌های پایهٔ سایت (قبلاً درون‌خطی در templates/base.html): متغیرهای رنگ تیره و روشن، هدر، منو، داک موبایل. */
/* ===================================================
   🪐 IC PLANET COSMIC SPACE PROTOCOLS (v2.6) 🪐
   پالت رنگی کیهانی، سیاره‌ای و فضایی (بدون سیاهی مطلق و بدون سفیدی زننده)
   =================================================== */

:root {
    --primary: #00f0ff;
    --on-primary: #001018;   /* متن روی دکمهٔ اصلی */
    --success: #10b981;      /* موجود، تخفیف، پیام موفق */
    --primary-glow: rgba(0, 240, 255, 0.4);
    --primary-hover: #38bdf8;
    --cosmic-purple: #8b5cf6;
    --cosmic-purple-glow: rgba(139, 92, 246, 0.35);
    --cosmic-amber: #fbbf24;
    --cosmic-rose: #f43f5e;
    --bg-body: #0b0f19;
    --nav-bg: rgba(13, 19, 36, 0.92);
    --top-bar-bg: #090d18;
    --secondary-nav-bg: rgba(15, 23, 44, 0.96);
    --card-glass: rgba(20, 28, 52, 0.82);
    --card-inner: #151e36;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-glow: rgba(56, 189, 248, 0.16);
    --border-cosmic: rgba(139, 92, 246, 0.22);
    --input-bg: rgba(22, 32, 58, 0.7);
    --card-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.55), 0 0 20px -5px rgba(56, 189, 248, 0.08);
    --logo-color: #ffffff;
    --radius-md: 0.75rem;
    --radius-lg: 1.15rem;
    --sidebar-border: rgba(56, 189, 248, 0.14);
}

body.light-mode {
    --primary: #0369a1;
    --on-primary: #ffffff;
    --success: #047857;
    --primary-glow: rgba(2, 132, 199, 0.25);
    --primary-hover: #075985;
    --cosmic-purple: #7c3aed;
    --cosmic-purple-glow: rgba(124, 58, 237, 0.2);
    --cosmic-amber: #b45309;
    --cosmic-rose: #be123c;
    --bg-body: #f8fafc;
    --nav-bg: rgba(255, 255, 255, 0.96);
    --top-bar-bg: #f1f5f9;
    --secondary-nav-bg: #ffffff;
    --card-glass: #ffffff;
    --card-inner: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #475569;
    --border-glow: rgba(15, 23, 42, 0.1);
    --border-cosmic: rgba(124, 58, 237, 0.15);
    --input-bg: #f1f5f9;
    --card-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06);
    --logo-color: #0f172a;
    --sidebar-border: rgba(15, 23, 42, 0.1);
}

html,
body {
    overflow-x: hidden !important;
    max-width: 100vw;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    background-image:
        radial-gradient(circle at 12% 15%, rgba(0, 240, 255, 0.08) 0%, transparent 42%),
        radial-gradient(circle at 88% 25%, rgba(139, 92, 246, 0.09) 0%, transparent 48%),
        radial-gradient(circle at 50% 85%, rgba(14, 165, 233, 0.06) 0%, transparent 52%),
        radial-gradient(1px 1px at 30px 40px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(1.5px 1.5px at 140px 90px, rgba(56, 189, 248, 0.45), transparent),
        radial-gradient(1px 1px at 260px 170px, rgba(168, 85, 247, 0.4), transparent);
    background-size: 100% 100%, 100% 100%, 100% 100%, 260px 260px, 320px 320px, 290px 290px;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Vazirmatn', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

body.light-mode {
    background-image:
        radial-gradient(circle at 15% 15%, rgba(2, 132, 199, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 85% 25%, rgba(124, 58, 237, 0.04) 0%, transparent 45%),
        radial-gradient(circle at 50% 85%, #f8fafc 0%, #edf2f7 100%);
    background-size: 100% 100%;
}

/* تطبیق اجزای عمومی در تم روشن برای جلوگیری از زنندگی رنگ‌ها */
body.light-mode .text-white {
    color: #0f172a !important;
}

body.light-mode .text-slate-300,
body.light-mode .text-slate-400 {
    color: #475569 !important;
}

body.light-mode .bg-white\/5,
body.light-mode .bg-white\/10 {
    background-color: rgba(15, 23, 42, 0.04) !important;
}

body.light-mode .border-white\/5,
body.light-mode .border-white\/10 {
    border-color: rgba(15, 23, 42, 0.08) !important;
}

body.light-mode footer .bg-black\/40 {
    background-color: rgba(15, 23, 42, 0.04) !important;
}

body.light-mode #cosmic-starfield-canvas {
    opacity: 0.12;
}

@media (max-width: 767px) {
    body {
        padding-bottom: 90px !important;
    }
}

.master-header-v2 {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
}

/* نوار نازک فوقانی هدر (Top Info Strip) */
.top-info-strip {
    background: var(--top-bar-bg);
    border-bottom: 1px solid var(--border-glow);
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 0.45rem 1rem;
}

/* سوییچر تم کیهانی ماه و خورشید (Sun/Moon Cosmic Theme Switcher) */
.theme-toggle-btn-v2 {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glow);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    padding: 0;
    flex-shrink: 0;
}

.theme-toggle-btn-v2:hover {
    border-color: rgba(0, 240, 255, 0.5);
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 15px -2px rgba(0, 240, 255, 0.3);
}

.theme-icon-wrapper-v2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.theme-icon-box-v2 {
    width: 100%;
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.light-mode .theme-icon-wrapper-v2 {
    transform: translateY(0);
}

body:not(.light-mode) .theme-icon-wrapper-v2 {
    transform: translateY(-50%);
}

body.light-mode .theme-toggle-btn-v2 {
    background: #f1f5f9;
    border-color: rgba(15, 23, 42, 0.15);
}

/* نوار ناوبری اصلی هدر */
.main-navbar-v2 {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border-glow);
    backdrop-filter: blur(16px);
    padding: 0.75rem 1rem;
}

/* نوار منوی ثانویه (دسته‌بندی و خدمات سریع) */
.secondary-navbar-v2 {
    background: var(--secondary-nav-bg);
    border-bottom: 1px solid var(--border-glow);
    padding: 0.35rem 1rem;
}

.nav-link-v2 {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.65rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-link-v2:hover {
    color: var(--primary);
    background: rgba(6, 182, 212, 0.08);
}

.nav-link-v2.active {
    color: var(--primary);
    background: rgba(6, 182, 212, 0.12);
}

/* اینپوت سرچ مرکزی بزرگ */
.search-container-v2 {
    position: relative;
    width: 100%;
}

.search-box-v2 {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1.5px solid var(--border-glow);
    border-radius: 0.85rem;
    overflow: hidden;
    transition: all 0.25s ease;
    height: 44px;
}

.search-box-v2:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 20px -2px rgba(0, 240, 255, 0.35);
    background: rgba(0, 240, 255, 0.04);
}

.search-input-v2 {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0 1rem;
    font-size: 0.85rem;
    color: var(--text-main);
    direction: rtl;
}

.search-btn-v2 {
    background: linear-gradient(135deg, #00f0ff 0%, #0284c7 100%);
    color: #030d1a;
    border: none;
    padding: 0 1.35rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 900;
    font-size: 0.82rem;
    transition: all 0.2s ease;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.search-btn-v2:hover {
    background: linear-gradient(135deg, #38bdf8 0%, #0369a1 100%);
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.5);
}

/* دکمه‌های اکشن هدر */
.header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-radius: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-glow);
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 44px;
}

.header-action-btn:hover {
    border-color: var(--primary);
    background: rgba(0, 240, 255, 0.1);
    color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
}

/* دراپ‌دان حساب کاربری */
.user-dropdown-v2 {
    position: absolute;
    top: 110%;
    left: 0;
    width: 260px;
    background: var(--nav-bg);
    border: 1px solid var(--border-glow);
    border-radius: 1rem;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(25px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s ease;
    z-index: 1002;
    overflow: hidden;
}

.user-menu-parent-v2:hover .user-dropdown-v2 {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-drop-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    border-bottom: 1px solid var(--border-glow);
}

.user-drop-item:last-child {
    border-bottom: none;
}

.user-drop-item:hover {
    background: rgba(6, 182, 212, 0.08);
    color: var(--primary);
}

/* پاپ‌آپ نتایج لایو سرچ */
.search-results-floating-v2 {
    position: absolute;
    top: 105%;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    border: 1px solid var(--border-glow);
    border-radius: 1rem;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(25px);
    z-index: 1005;
    display: none;
    max-height: 420px;
    overflow-y: auto;
}

/* سایدبار کشویی */
#side-menu-overlay-v2 {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#side-menu-overlay-v2.active {
    opacity: 1;
    visibility: visible;
}

#side-menu-drawer-v2 {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: var(--nav-bg);
    border-left: 1px solid var(--border-glow);
    z-index: 9999;
    transform: translateX(100%);
    /* بسته: visibility پنهان تا پیوندهای منو در ترتیب Tab نباشند (بعد از پایان انیمیشن بستن) */
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.35s;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.6);
}

#side-menu-drawer-v2.active {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
}

/* ساختار درختی کاتالوگ در منوی کشویی */
.tree-node-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

.tree-children-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    padding-right: 10px;
    margin-right: 14px;
    border-right: 1.5px dashed rgba(56, 189, 248, 0.25);
    position: relative;
}

.tree-node-container.is-opened>.tree-children-wrapper {
    max-height: 2500px;
}

.tree-row-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    border-radius: 12px;
    color: var(--text-main);
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
    margin: 2px 0;
    box-sizing: border-box;
    text-decoration: none !important;
    font-size: 0.8rem;
}

.tree-row-link:hover {
    background: rgba(0, 240, 255, 0.08);
    color: var(--primary);
    border-color: rgba(0, 240, 255, 0.2);
    transform: translateX(-3px);
}

.tree-node-container.is-opened>.tree-row-link {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.25);
    color: #c084fc;
}

.tree-arrow-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    transition: transform 0.3s ease;
}

.tree-node-container.is-opened>.tree-row-link .tree-arrow-trigger {
    transform: rotate(90deg);
    background: var(--primary);
    color: #000 !important;
}

/* داک ناوبری همراه (Mobile Dock) */
@media (max-width: 767px) {
    .ic-mobile-dock-v2 {
        position: fixed;
        bottom: 14px;
        left: 14px;
        right: 14px;
        height: 64px;
        background: var(--nav-bg);
        border: 1px solid var(--border-glow);
        border-radius: 1.25rem;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(20px);
        z-index: 9990;
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding: 0 0.5rem;
    }

    .dock-btn-v2 {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.65rem;
        font-weight: 700;
        gap: 0.2rem;
        transition: color 0.2s ease;
        background: none;
        border: none;
        cursor: pointer;
    }

    .dock-btn-v2.active,
    .dock-btn-v2:hover {
        color: var(--primary);
    }
}

/* کنتراست متن در تم روشن (WCAG AA، حداقل ۴٫۵ به ۱): رنگ‌های روشن ۳۰۰ تا ۵۰۰ که برای پس‌زمینهٔ تیره
   انتخاب شده‌اند روی سفید خوانا نیستند (فیروزه‌ای ۴۰۰ روی سفید حدود ۱٫۵ به ۱). تست: tests/test_contrast.py */
body.light-mode .text-cyan-300, body.light-mode .text-cyan-400, body.light-mode .text-cyan-500, body.light-mode .\!text-cyan-400,
body.light-mode .text-sky-400, body.light-mode .text-blue-400, body.light-mode .text-teal-300, body.light-mode .text-teal-400 { color: #0e7490 !important; }
body.light-mode .text-emerald-300, body.light-mode .text-emerald-400, body.light-mode .text-emerald-500,
body.light-mode .text-green-400, body.light-mode .text-green-500 { color: #047857 !important; }
body.light-mode .text-amber-300, body.light-mode .text-amber-400, body.light-mode .text-amber-500 { color: #b45309 !important; }
body.light-mode .text-rose-300, body.light-mode .text-rose-400, body.light-mode .text-rose-500,
body.light-mode .text-red-300, body.light-mode .text-red-400, body.light-mode .text-red-500 { color: #be123c !important; }
body.light-mode .text-purple-300, body.light-mode .text-purple-400, body.light-mode .text-purple-500 { color: #6d28d9 !important; }
/* روی دکمه و نشان رنگی پررنگ، متن سفید بماند (قانون .text-white بالا آن را تیره می‌کرد) */
body.light-mode [class*="bg-rose-6"].text-white, body.light-mode [class*="bg-red-6"].text-white,
body.light-mode [class*="bg-emerald-6"].text-white, body.light-mode [class*="bg-cyan-6"].text-white,
body.light-mode [class*="bg-sky-6"].text-white, body.light-mode [class*="bg-purple-6"].text-white,
body.light-mode [class*="bg-indigo-6"].text-white, body.light-mode [class*="bg-blue-6"].text-white { color: #fff !important; }

/* کیبورد: حلقهٔ فوکوس روشن برای همه (فقط وقتی با کیبورد پیمایش می‌شود) و پیوند «پرش به محتوا» */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.skip-link {
    position: fixed;
    top: .5rem;
    right: .5rem;
    z-index: 10000;
    padding: .6rem 1rem;
    border-radius: .6rem;
    background: var(--primary);
    color: var(--on-primary, #001018);
    font-weight: 800;
    text-decoration: none;
    transform: translateY(-200%);
}
.skip-link:focus {
    transform: none;
}

/* شمار اعلان‌های خوانده‌نشدهٔ انجمن در منوی حساب */
.forum-unread { display: inline-flex; min-width: 1.2rem; justify-content: center; margin-inline-start: .3rem; padding: 0 .3rem;
    border-radius: 9999px; background: var(--cosmic-rose); color: #fff; font-size: .68rem; font-weight: 800; }
