/* =========================================
   1. Header Flex Layout
========================================= */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    padding: 24px 0;

    /* تغییر مهم: حذف transparent و جایگزینی با متغیر رنگی */
    background-color: var(--bg-primary);

    /* اضافه کردن border ظریف برای تفکیک بهتر هدر از سکشن‌ها */
    /*border-bottom: 1px solid var(--border-color);*/

    transition: background-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    padding var(--transition-fast);
}

.main-header.theme-dark {
    box-shadow: var(--card-shadow);
    padding: 14px 0;
    background-color: var(--bg-primary);
}

.main-header.scrolled {
    background-color: var(--bg-primary);
    box-shadow: var(--card-shadow);
    padding: 14px 0;
}

.main-header .header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.main-header .header-right {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.main-header .header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-header .header-left {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
}

.main-header .header-logo img {
    height: 42px;
    width: auto;
    object-fit: contain;
}

/* =========================================
   2. Theme Switcher & Buttons
========================================= */
.main-header .ui-switch {
    /* switch variables */
    --switch-bg: rgb(135, 150, 165);
    --switch-width: 48px;
    --switch-height: 20px;
    /* circle variables */
    --circle-diameter: 32px;
    --circle-bg: rgb(0, 56, 146);
    --circle-inset: calc((var(--circle-diameter) - var(--switch-height)) / 2);

    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-header .ui-switch .slider {
    width: var(--switch-width);
    height: var(--switch-height);
    background: var(--switch-bg);
    border-radius: 999px;
    position: relative;
    cursor: pointer;
}

.main-header .ui-switch .slider .circle {
    top: calc(var(--circle-inset) * -1);
    left: 0;
    width: var(--circle-diameter);
    height: var(--circle-diameter);
    position: absolute;
    background: var(--circle-bg);
    border-radius: inherit;
    /* عکس خورشید (حالت لایت) */
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHdpZHRoPSIyMCIgdmlld0JveD0iMCAwIDIwIDIwIj4KICAgIDxwYXRoIGZpbGw9IiNmZmYiCiAgICAgICAgZD0iTTkuMzA1IDEuNjY3VjMuNzVoMS4zODlWMS42NjdoLTEuMzl6bS00LjcwNyAxLjk1bC0uOTgyLjk4Mkw1LjA5IDYuMDcybC45ODItLjk4Mi0xLjQ3My0xLjQ3M3ptMTAuODAyIDBMMTMuOTI3IDUuMDlsLjk4Mi45ODIgMS40NzMtMS40NzMtLjk4Mi0uOTgyek0xMCA1LjEzOWE0Ljg3MiA0Ljg3MiAwIDAwLTQuODYyIDQuODZBNC44NzIgNC44NzIgMCAwMDEwIDE0Ljg2MiA0Ljg3MiA0Ljg3MiAwIDAwMTQuODYgMTAgNC44NzIgNC44NzIgMCAwMDEwIDUuMTM5em0wIDEuMzg5QTMuNDYyIDMuNDYyIDAgMDExMy40NzEgMTBhMy40NjIgMy40NjIgMCAwMS0zLjQ3MyAzLjQ3MkEzLjQ2MiAzLjQ2MiAwIDAxNi41MjcgMTAgMy40NjIgMy40NjIgMCAwMTEwIDYuNTI4ek0xLjY2NSA5LjMwNXYxLjM5aDIuMDgzdi0xLjM5SDEuNjY2em0xNC41ODMgMHYxLjM5aDIuMDg0di0xLjM5aC0yLjA4NHpNNS4wOSAxMy45MjhMMy42MTYgMTUuNGwuOTgyLjk4MiAxLjQ3My0xLjQ3My0uOTgyLS45ODJ6bTkuODIgMGwtLjk4Mi45ODIgMS40NzMgMS40NzMuOTgyLS45ODItMS40NzMtMS40NzN6TTkuMzA1IDE2LjI1djIuMDgzaDEuMzg5VjE2LjI1aC0xLjM5eiIgLz4KPC9zdmc+");
    background-repeat: no-repeat;
    background-position: center center;
    transition: left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
}

.main-header .ui-switch .slider .circle::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.75);
    border-radius: inherit;
    transition: all 500ms;
    opacity: 0;
}

/* افکت کلیک */
.main-header .ui-switch:active .slider .circle::before {
    transition: 0s;
    opacity: 1;
    width: 0;
    height: 0;
}

/* --- منطق وصل شده به جاوااسکریپت شما (دارک مود) --- */
.main-header.theme-dark .ui-switch .slider .circle {
    left: calc(100% - var(--circle-diameter));
    /* عکس ماه (حالت دارک) */
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjAiIHdpZHRoPSIyMCIgdmlld0JveD0iMCAwIDIwIDIwIj4KICAgIDxwYXRoIGZpbGw9IiNmZmYiCiAgICAgICAgZD0iTTQuMiAyLjVsLS43IDEuOC0xLjguNyAxLjguNy43IDEuOC42LTEuOEw2LjcgNWwtMS45LS43LS42LTEuOHptMTUgOC4zYTYuNyA2LjcgMCAxMS02LjYtNi42IDUuOCA1LjggMCAwMDYuNiA2LjZ6IiAvPgo8L3N2Zz4=");
}

/* استایل دکمه‌های هدر (این بخش دست‌نخورده باقی می‌ماند) */
.main-header .header-left .btn-outline {
    background-color: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--text-primary);
    border-radius: 30px;
    padding: 10px 24px;
    font-weight: bold;
    transition: all var(--transition-fast);
}

.main-header .header-left .btn-outline:hover {
    background-color: var(--accent-primary);
    color: #fff;
}

.main-header.theme-dark .header-left .btn-outline {
    border-color: rgba(255, 255, 255, 0.2);
}

.main-header.theme-dark .header-left .btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.main-header .desktop-nav-links {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 40px;
}

.main-header .desktop-nav-links a {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    position: relative;
    padding: 10px 0;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
}

.main-header .desktop-nav-links a:hover {
    color: var(--accent-primary);
}

.main-header .mobile-menu-toggle {
    background: var(--color-navy);
    border: none;
    color: #ffffff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
}

.main-header.theme-dark .mobile-menu-toggle {
    background: #121212;
    border: 1px solid #2a2a2a;
}

/* =========================================
   3. Offcanvas Base & Overlay Backdrop
========================================= */
.dm-offcanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0.4s ease;
}

.dm-offcanvas.active {
    visibility: visible;
    pointer-events: auto;
}

.dm-offcanvas .offcanvas-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
}

.dm-offcanvas.theme-dark .offcanvas-backdrop {
    background: rgba(6, 17, 33, 0.7);
}

.dm-offcanvas.active .offcanvas-backdrop {
    opacity: 1;
}

.dm-offcanvas .offcanvas-content {
    position: absolute;
    top: 0;
    height: 100%;
    background-color: var(--bg-primary);
    box-shadow: -6px 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* راز حل مشکل لگ: پنهان بودن پیش‌فرض + تاخیر 0.4 ثانیه‌ای برای پنهان شدن (تا انیمیشن تمام شود) */
    visibility: hidden;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.4s;
}

/* =========================================
   4. Primary Panel (Layer 1)
========================================= */
.dm-offcanvas .primary-panel {
    right: 0;
    width: 100%;
    max-width: 460px;
    z-index: 10;
    transform: translateX(100%);
    border-left: 1px solid var(--border-color);
}

.dm-offcanvas.active .primary-panel {
    transform: translateX(0);
    visibility: visible;
    /* هنگام باز شدن: مرئی شدن آنی و بدون تاخیر (0s) */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0s;
}

/* بستن آنی و بدون لگ کل آف‌کانواس */
.dm-offcanvas:not(.active) .primary-panel,
.dm-offcanvas:not(.active) .secondary-panel {
    transform: translateX(100%) !important;
    visibility: hidden !important;
    transition: none !important;
}

.dm-offcanvas .offcanvas-header {
    padding: 30px 30px 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
}

.dm-offcanvas .offcanvas-brand {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dm-offcanvas .offcanvas-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
}

.dm-offcanvas .offcanvas-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-primary);
    opacity: 0.8;
}

.dm-offcanvas .offcanvas-close {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.dm-offcanvas .offcanvas-close span {
    margin-top: 5px;
}

.dm-offcanvas .offcanvas-close:hover {
    background-color: var(--accent-primary);
    color: #ffffff;
}

.dm-offcanvas .offcanvas-body {
    flex: 1;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 30px 0;
}

.dm-offcanvas .offcanvas-footer {
    padding: 30px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: auto;
}

.dm-offcanvas .offcanvas-contact-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dm-offcanvas .contact-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.dm-offcanvas .contact-phone {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-primary);
    font-family: 'dana', sans-serif;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: color var(--transition-fast);
}

.dm-offcanvas .contact-phone i {
    color: var(--accent-secondary);
    font-size: 20px;
}

.dm-offcanvas .contact-phone:hover {
    color: var(--accent-primary);
}

.dm-offcanvas .offcanvas-socials {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 10px;
}

.dm-offcanvas .offcanvas-socials a {
    color: var(--text-secondary);
    font-size: 22px;
    transition: color var(--transition-fast), transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.dm-offcanvas .offcanvas-socials a:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    transform: translateY(-4px);
}

.dm-offcanvas.theme-dark .offcanvas-socials a {
    background-color: rgba(255, 255, 255, 0.03);
}

.dm-offcanvas.theme-dark .offcanvas-socials a:hover {
    background-color: rgba(184, 115, 51, 0.1);
}

/* =========================================
   5. Secondary Panel (Golden Cascading Layer 2)
========================================= */
.dm-offcanvas .secondary-panel {
    /*background-color: var(--accent-secondary) !important;*/
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' version='1.1' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:svgjs='http://svgjs.dev/svgjs' width='1440' height='560' preserveAspectRatio='none' viewBox='0 0 1440 560'%3e%3cg mask='url(%26quot%3b%23SvgjsMask1004%26quot%3b)' fill='none'%3e%3cpath d='M-231.31 153.49C-97.13 163.54-23.9 417.21 231.69 427.89 487.28 438.57 572.16 586.62 694.69 588.89' stroke='rgba(245%2c 214%2c 143%2c 1)' stroke-width='2'%3e%3c/path%3e%3cpath d='M-246.71 397.54C-133.37 397.75-22.76 467.54 201.2 467.54 425.16 467.54 422.59 397.15 649.11 397.54 875.63 397.93 973.87 598.63 1097.02 603.49' stroke='rgba(245%2c 214%2c 143%2c 1)' stroke-width='2'%3e%3c/path%3e%3cpath d='M-204.62 55.07C-78.05 56.14 6.53 166.78 285.01 183.87 563.49 200.96 617.57 565.05 774.64 590.36' stroke='rgba(245%2c 214%2c 143%2c 1)' stroke-width='2'%3e%3c/path%3e%3cpath d='M-277.72 287.32C-105.53 291.2 112.1 523.64 367.75 528.12 623.41 532.6 606.81 616.15 690.49 616.96' stroke='rgba(245%2c 214%2c 143%2c 1)' stroke-width='2'%3e%3c/path%3e%3cpath d='M-255.66 124.87C-66.03 125.28 187.98 238.31 492.78 248.07 797.58 257.83 740.99 575.48 867 601.96' stroke='rgba(245%2c 214%2c 143%2c 1)' stroke-width='2'%3e%3c/path%3e%3c/g%3e%3cdefs%3e%3cmask id='SvgjsMask1004'%3e%3crect width='1440' height='560' fill='white'%3e%3c/rect%3e%3c/mask%3e%3c/defs%3e%3c/svg%3e");
    background-position: bottom;
    background-repeat: no-repeat;
    border-left: none;
    box-shadow: none;
    border-radius: 50px 0 0 50px;
}

.dm-offcanvas .secondary-panel.active {
    visibility: visible;
    /* هنگام باز شدن: مرئی شدن آنی و بدون تاخیر (0s) */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0s;
}

.dm-offcanvas .secondary-panel .sub-panel-title,
.dm-offcanvas .secondary-panel .btn-panel-back {
    color: var(--text-primary) !important; /* رنگ سرمه‌ای برای خوانایی روی طلایی */
}

/* اصلاح رنگ لینک‌ها در پنل دوم برای تم دارک */
.dm-offcanvas .secondary-panel .sub-menu-links li a {
    background-color: rgba(255, 255, 255, 0.4);
    color: var(--text-primary) !important;
}

/* تنظیم دقیق‌تر برای دارک مود */
.dm-offcanvas.theme-dark .secondary-panel .sub-panel-title,
.dm-offcanvas.theme-dark .secondary-panel .btn-panel-back,
.dm-offcanvas.theme-dark .secondary-panel .sub-menu-links li a {
    color: var(--text-primary) !important; /* ثابت ماندن روی رنگ سرمه‌ای برای کنتراست */
}

.dm-offcanvas .golden-header {
    border-bottom: 1px solid var(--border-color);;
    display: flex;
    align-items: center;
    padding: 30px;
}

.dm-offcanvas .btn-panel-back {
    background: transparent;
    border: none;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    transition: transform var(--transition-fast);
}

.dm-offcanvas .btn-panel-back:hover {
    transform: translateX(4px);
}

.dm-offcanvas .secondary-panel .sub-menu-links li a {
    background-color: rgba(255, 255, 255, 0.4);
    color: var(--color-navy) !important;
}

.dm-offcanvas .secondary-panel .sub-menu-links li a:hover {
    background-color: var(--color-navy) !important;
    color: var(--accent-secondary) !important;
    transform: translateX(-6px);
}

/* مخفی کردن منوی پایه موبایل و دکمه‌های بازگشت آن در دسکتاپ */
@media (min-width: 993px) {
    .mobile-only-root,
    .btn-mobile-back {
        display: none !important;
    }
}

/* استایل دکمه بازگشت لایه ۲ به لایه ۱ در موبایل */
.btn-mobile-back {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 30px 16px 30px;
    margin-bottom: 16px;
    border-bottom: 1px dashed var(--border-color);
    width: 100%;
}

/* منطق آبشاری در دسکتاپ و موبایل */
@media (min-width: 993px) {
    .dm-offcanvas .secondary-panel {
        right: 460px;
        width: 380px;
        z-index: 5;
        transform: translateX(100%);
    }

    .dm-offcanvas .secondary-panel.active {
        transform: translateX(0);
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    }
}

@media (max-width: 992px) {
    .dm-offcanvas .secondary-panel {
        right: 0;
        width: 100%;
        max-width: 100%;
        z-index: 20;
        transform: translateX(100%);
        border-radius: 0;
    }

    .dm-offcanvas .secondary-panel.active {
        transform: translateX(0);
        width: 88%;
        border-radius: 50px 0 0 50px;
    }
}

/* =========================================
   6. Menu Lists, Content & Typography
========================================= */
.dm-offcanvas .mega-panel {
    position: relative;
    width: 100%;
    display: none;
}

.dm-offcanvas .mega-panel.active {
    display: block;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dm-offcanvas .mega-content-group {
    display: none;
}

.dm-offcanvas .mega-content-group.active {
    display: block;
}

.dm-offcanvas .drilldown-menu,
.dm-offcanvas .simple-mega-menu,
.dm-offcanvas .sub-menu-links {
    list-style: none;
    padding: 0 30px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dm-offcanvas .drilldown-menu li a,
.dm-offcanvas .simple-mega-menu li a,
.dm-offcanvas .sub-menu-links li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background-color: var(--bg-secondary);
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    text-decoration: none;
}

.dm-offcanvas .drilldown-menu li a:hover,
.dm-offcanvas .simple-mega-menu li a:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-primary);
    color: var(--accent-primary);
    transform: translateX(-6px);
}

.dm-offcanvas .sub-panel-title {
    font-size: 22px;
    margin: 0 30px 24px 30px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border-color);
}

/* =========================================
   7. Responsive Overrides (Mobile)
========================================= */
@media (max-width: 992px) {
    .main-header {
        padding: 16px 0;
    }

    /* جابجایی جایگاه لوگو و برگر منو در موبایل */
    .main-header .header-left {
        order: 1;
        justify-content: flex-start !important;
    }

    .main-header .header-right {
        order: 3;
        justify-content: flex-end !important;
    }

    .dm-offcanvas .primary-panel {
        width: 88%;
        border-radius: 50px 0 0 50px;
    }

    .dm-offcanvas .mega-content-group {
        margin-bottom: 24px;
    }

    .dm-offcanvas .mega-content-group:not(:last-child) {
        border-bottom: 1px dashed var(--border-color);
        padding-bottom: 16px;
    }
}

