/* ============================================================
   UNIFIED LAYOUT – یکپارچه‌سازی هدر و فوتر
   نسخه: 2.3 – با دکمه‌های آیکون-محور (ورود، ثبت‌نام، تماس، کاربر)
   ============================================================ */

/* ============================================================
   ۱. top-bar تک‌ردیفی
   ============================================================ */
.top-bar {
    background: var(--bg-card, #fff);
    border-bottom: 1px solid var(--border, #e8eef5);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .03);
}

html[data-theme="dark"] .top-bar {
    background: #131b2a;
    border-color: #1e2a3d;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .3);
}

.top-bar-inner {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    flex-wrap: nowrap !important;
    min-height: 68px;
    padding: 8px 0;
}

/* ============================================================
   ۲. گروه اول (برند + منو)
   ============================================================ */
.tb-start-group {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 1;
    min-width: 0;
    order: 1;
}

.tb-brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.tb-brand .brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--gold, #e0a82e), var(--gold-deep, #b8841a));
    color: #fff;
    border-radius: 50%;
    font-size: 1.15rem;
    box-shadow: 0 4px 12px rgba(224, 168, 46, .35);
    flex-shrink: 0;
}

.tb-brand .brand-name {
    font-size: .95rem;
    font-weight: 800;
    color: var(--text, #0f172a);
    letter-spacing: -.01em;
    white-space: nowrap;
}

/* ============================================================
   ۳. منوی اصلی تک‌ردیفی
   ============================================================ */
.tb-main-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    flex-wrap: nowrap;
}

.tb-main-nav > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--text-soft, #475569);
    text-decoration: none;
    font-size: .84rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all .25s cubic-bezier(.2, .9, .3, 1.2);
    position: relative;
}

.tb-main-nav > a:hover {
    background: var(--gold-soft, rgba(224, 168, 46, .1));
    color: var(--gold-deep, #b8841a);
}

.tb-main-nav > a.active {
    background: linear-gradient(135deg, var(--gold, #e0a82e), var(--gold-deep, #b8841a));
    color: #fff;
    box-shadow: 0 4px 12px rgba(224, 168, 46, .35);
}

.tb-main-nav > a.active .tb-nav-icon {
    filter: brightness(1.2);
}

/* ---- آیکون فقط (صفحه اصلی 🏠 و تماس با ما 📞) ---- */
.tb-main-nav > a.tb-nav-icon-only {
    padding: 8px 10px;
    gap: 0;
    min-width: 40px;
    justify-content: center;
}

.tb-main-nav > a.tb-nav-icon-only .tb-nav-icon {
    font-size: 1.1rem;
}

.tb-nav-icon {
    font-size: .95rem;
    line-height: 1;
    flex-shrink: 0;
}

.tb-nav-text {
    line-height: 1;
}

.tb-back-link {
    background: rgba(59, 130, 246, .1) !important;
    color: #3b82f6 !important;
}

.tb-back-link:hover {
    background: rgba(59, 130, 246, .2) !important;
    color: #2563eb !important;
}

/* ============================================================
   ⚡ بریک‌پوینت‌های منوی افقی – جلوگیری از سرریز
   ============================================================ */

/* ---- بزرگ (۱۴۰۱px+): نمایش کامل متن + آیکون ---- */
@media screen and (min-width: 1401px) {
    .tb-main-nav > a .tb-nav-text {
        display: inline-block;
    }
}

/* ---- میانی بزرگ (۱۲۵۱px تا ۱۴۰۰px): کاهش padding ---- */
@media screen and (min-width: 1251px) and (max-width: 1400px) {
    .tb-main-nav {
        gap: 0;
    }
    .tb-main-nav > a {
        padding: 8px 9px;
        font-size: .8rem;
    }
    .tb-main-nav > a .tb-nav-text {
        display: inline-block;
    }
    .tb-start-group {
        gap: 14px;
    }
}

/* ---- میانی (۱۰۲۵px تا ۱۲۵۰px): فقط آیکون (بدون متن) ---- */
@media screen and (min-width: 1025px) and (max-width: 1250px) {
    .tb-main-nav {
        gap: 2px;
    }
    .tb-main-nav > a {
        padding: 8px 10px;
        min-width: 42px;
        justify-content: center;
        gap: 0;
    }
    .tb-main-nav > a .tb-nav-text {
        display: none;
    }
    .tb-main-nav .tb-nav-icon {
        font-size: 1.1rem;
    }
    .tb-main-nav > a.tb-nav-icon-only {
        padding: 8px 10px;
    }
    .tb-start-group {
        gap: 10px;
    }
}

/* ============================================================
   ۴. گروه دوم (ابزارها + ورود/ثبت‌نام)
   ============================================================ */
.tb-end-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-inline-start: auto;
    order: 2;
}

/* ============================================================
   ۵. سرچ جمع‌شو
   ============================================================ */
.tb-search-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 40px;
    border-radius: 20px;
    background: var(--bg-alt, #f4f7fb);
    border: 1.5px solid transparent;
    transition: all .35s cubic-bezier(.2, .9, .3, 1.2);
    overflow: hidden;
}

html[data-theme="dark"] .tb-search-wrap {
    background: rgba(255, 255, 255, .06);
}

.tb-search-wrap.expanded {
    width: 240px;
    border-color: var(--gold, #e0a82e);
    background: var(--bg-card, #fff);
    box-shadow: 0 6px 18px rgba(224, 168, 46, .2);
}

html[data-theme="dark"] .tb-search-wrap.expanded {
    background: #1e2a3d;
}

.tb-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-soft, #475569);
    cursor: pointer;
    flex-shrink: 0;
    transition: color .25s;
}

.tb-search-toggle:hover {
    color: var(--gold, #e0a82e);
}

.tb-search-wrap.expanded .tb-search-toggle {
    display: none;
}

.tb-search-form {
    display: none;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 0 4px 0 12px;
}

html[dir="rtl"] .tb-search-form {
    padding: 0 12px 0 4px;
}

.tb-search-wrap.expanded .tb-search-form {
    display: flex;
}

.tb-search-form input {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: .82rem;
    color: var(--text, #0f172a);
    min-width: 0;
}

.tb-search-form input::placeholder {
    color: var(--text-mute, #94a3b8);
}

.tb-search-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: linear-gradient(135deg, var(--gold, #e0a82e), var(--gold-deep, #b8841a));
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .25s;
}

.tb-search-form button:hover {
    transform: scale(1.1);
}

/* ============================================================
   ۶. زبان جمع‌شو
   ============================================================ */
.tb-lang-dropdown {
    position: relative;
}

.tb-lang-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--bg-alt, #f4f7fb);
    border: 1.5px solid transparent;
    border-radius: 50%;
    color: var(--text-soft, #475569);
    cursor: pointer;
    font-size: 1.05rem;
    transition: all .25s;
}

html[data-theme="dark"] .tb-lang-toggle {
    background: rgba(255, 255, 255, .06);
}

.tb-lang-toggle:hover {
    border-color: var(--gold, #e0a82e);
    background: var(--gold-soft, rgba(224, 168, 46, .1));
    transform: translateY(-2px);
}

.tb-lang-flag {
    line-height: 1;
    font-size: 1.15rem;
}

.tb-lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    min-width: 160px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e8eef5);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all .25s;
    z-index: 9999;
}

html[data-theme="dark"] .tb-lang-menu {
    background: #1e2a3d;
    border-color: #2a3a52;
}

.tb-lang-dropdown.open .tb-lang-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.tb-lang-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text, #0f172a);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 600;
    transition: all .2s;
}

.tb-lang-menu a:hover {
    background: var(--gold-soft, rgba(224, 168, 46, .1));
    color: var(--gold-deep, #b8841a);
}

.tb-lang-menu a.active {
    background: linear-gradient(135deg, var(--gold, #e0a82e), var(--gold-deep, #b8841a));
    color: #fff;
}

.tb-lang-menu a span:first-child {
    font-size: 1.1rem;
    line-height: 1;
}

/* ============================================================
   ۷. دکمه تم
   ============================================================ */
.qt-theme-toggle {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    background: linear-gradient(135deg, rgba(240, 201, 80, .15), rgba(240, 201, 80, .08));
    border: 1.5px solid rgba(240, 201, 80, .35);
    border-radius: 50%;
    cursor: pointer;
    font-family: inherit;
    color: #b8841a;
    transition: all .3s cubic-bezier(.2, .9, .3, 1.3);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.qt-theme-toggle:hover {
    border-color: #f0c950;
    background: linear-gradient(135deg, rgba(240, 201, 80, .3), rgba(240, 201, 80, .15));
    transform: translateY(-2px) scale(1.05);
    box-shadow:
        0 8px 20px rgba(240, 201, 80, .45),
        inset 0 1px 0 rgba(255, 255, 255, .4);
}

.qt-theme-toggle:active {
    transform: translateY(0) scale(.95);
}

.qt-theme-toggle .qt-icon {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    transition: transform .5s cubic-bezier(.2, .9, .3, 1.4);
    pointer-events: none;
}

.qt-theme-toggle .qt-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================================================
   ۸. دکمه‌های ورود/ثبت‌نام – فقط آیکون (فشرده)
   ============================================================ */
.qt-auth-buttons {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.qt-btn-login,
.qt-btn-register {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: all .3s cubic-bezier(.2, .9, .3, 1.3);
    flex-shrink: 0;
    position: relative;
    border: none;
}

.qt-btn-login svg,
.qt-btn-register svg {
    width: 17px;
    height: 17px;
    display: block;
}

/* ---- ورود: دایره شفاف با بردر ---- */
.qt-btn-login {
    background: var(--bg-alt, #f4f7fb);
    color: var(--text-soft, #475569);
    border: 1.5px solid var(--border, #e8eef5);
}

html[data-theme="dark"] .qt-btn-login {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .1);
}

.qt-btn-login:hover {
    color: var(--gold-deep, #b8841a);
    border-color: var(--gold, #e0a82e);
    background: var(--gold-soft, rgba(224, 168, 46, .15));
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(224, 168, 46, .25);
}

/* ---- ثبت‌نام: دایره گرادیان طلایی ---- */
.qt-btn-register {
    background: linear-gradient(135deg, #fcd34d 0%, #f0c950 40%, #e8b93e 100%);
    color: #fff;
    box-shadow:
        0 6px 16px rgba(240, 201, 80, .4),
        inset 0 1px 0 rgba(255, 255, 255, .5);
}

.qt-btn-register:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow:
        0 10px 24px rgba(240, 201, 80, .55),
        inset 0 1px 0 rgba(255, 255, 255, .6);
}

/* ============================================================
   ۹. منوی کاربر فشرده (فقط آواتار)
   ============================================================ */
.user-dropdown {
    position: relative;
    flex-shrink: 0;
}

.user-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 4px;
    background: var(--bg-alt, #f4f7fb);
    border: 1.5px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: .82rem;
    color: var(--text, #0f172a);
    transition: all .3s;
}

html[dir="rtl"] .user-toggle {
    padding: 4px 4px 4px 8px;
}

html[data-theme="dark"] .user-toggle {
    background: rgba(255, 255, 255, .06);
}

.user-toggle:hover {
    border-color: var(--gold, #e0a82e);
    background: var(--gold-soft, rgba(224, 168, 46, .1));
    transform: translateY(-2px);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold, #e0a82e), var(--gold-deep, #b8841a));
    color: #fff;
    font-size: .85rem;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(224, 168, 46, .35);
}

.user-caret {
    font-size: .65rem;
    opacity: .6;
    flex-shrink: 0;
}

/* ============================================================
   ۱۰. دکمه همبرگری
   ============================================================ */
.qt-hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 42px;
    height: 42px;
    padding: 11px 9px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    flex-shrink: 0;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    transition: background .25s;
}

.qt-hamburger:hover {
    background: var(--gold-soft, rgba(224, 168, 46, .1));
}

.qt-hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text, #0f172a);
    border-radius: 2px;
    transition: all .3s cubic-bezier(.2, .9, .3, 1.2);
    pointer-events: none;
}

html[data-theme="dark"] .qt-hamburger span {
    background: #e8e6e0;
}

.qt-hamburger.active {
    background: var(--gold, #e0a82e);
}

.qt-hamburger.active span {
    background: #fff;
}

.qt-hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.qt-hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.qt-hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   ۱۱. ریسپانسیو – موبایل و تبلت
   ============================================================ */

/* تبلت: مخفی کردن منوی افقی + نمایش همبرگر */
@media (max-width: 1024px) {
    .tb-main-nav {
        display: none !important;
    }

    .tb-search-wrap,
    .tb-lang-dropdown {
        display: none !important;
    }

    .qt-hamburger {
        display: flex !important;
    }

    .tb-start-group {
        gap: 12px;
    }
}

/* موبایل: کوچک‌تر کردن همه چیز */
@media (max-width: 700px) {
    .top-bar-inner {
        min-height: 60px;
        padding: 6px 0;
    }

    .tb-brand .brand-name {
        font-size: .82rem;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .tb-brand .brand-logo {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .qt-btn-login,
    .qt-btn-register {
        width: 38px;
        height: 38px;
    }

    .qt-btn-login svg,
    .qt-btn-register svg {
        width: 15px;
        height: 15px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: .8rem;
    }

    .user-toggle {
        padding: 4px 6px 4px 4px;
    }

    .qt-theme-toggle {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 420px) {
    .tb-brand .brand-name {
        display: none;
    }

    .qt-auth-buttons {
        gap: 4px;
    }

    .qt-btn-login,
    .qt-btn-register {
        width: 36px;
        height: 36px;
    }
}

/* ============================================================
   ۱۲. منوی موبایل (کشویی)
   ============================================================ */
.qt-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border, #e8eef5);
    background: linear-gradient(135deg, var(--gold-soft, rgba(224, 168, 46, .1)), transparent);
}

.qt-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    color: var(--text, #0f172a);
}

.qt-mobile-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-alt, #f4f7fb);
    color: var(--text-soft, #475569);
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .25s;
    font-family: inherit;
    line-height: 1;
}

.qt-mobile-close:hover {
    background: var(--gold, #e0a82e);
    color: #fff;
    transform: rotate(90deg);
}

.qt-mobile-nav {
    padding: 12px;
    flex: 1;
}

.qt-mobile-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    color: var(--text, #0f172a);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: .95rem;
    margin-bottom: 4px;
    transition: all .25s;
}

.qt-mobile-nav a:hover,
.qt-mobile-nav a.active {
    background: var(--gold-soft, rgba(224, 168, 46, .1));
    color: var(--gold-deep, #b8841a);
}

.qt-nav-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.qt-mobile-footer {
    padding: 16px 16px 20px;
    border-top: 1px solid var(--border, #e8eef5);
    margin-top: 12px;
    background: var(--bg-soft, #fbfcfe);
}

.qt-mobile-search {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.qt-mobile-search input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border, #e8eef5);
    border-radius: 24px;
    background: var(--bg-card, #fff);
    color: var(--text, #0f172a);
    font-family: inherit;
    font-size: .9rem;
    min-width: 0;
}

.qt-mobile-search button {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #f5cd5a, #e0a82e);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
}

.qt-mobile-theme {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border, #e8eef5);
    margin-bottom: 12px;
}

.qt-mobile-label {
    color: var(--text-soft, #475569);
    font-size: .85rem;
    font-weight: 700;
}

.qt-mobile-theme-btns {
    display: flex;
    gap: 6px;
}

.qt-mobile-theme-btns button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-alt, #f4f7fb);
    border: 2px solid var(--border, #e8eef5);
    color: var(--text, #0f172a);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qt-mobile-theme-btns button.active {
    background: var(--gold, #e0a82e);
    color: #fff;
    border-color: var(--gold, #e0a82e);
}

.qt-mobile-langs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.qt-mobile-langs a {
    flex: 1;
    min-width: 80px;
    padding: 10px 12px;
    background: var(--bg-alt, #f4f7fb);
    color: var(--text-soft, #475569);
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 600;
}

.qt-mobile-langs a.active {
    background: var(--gold, #e0a82e);
    color: #fff;
}

.qt-mobile-auth {
    display: flex;
    gap: 8px;
}

.qt-mobile-login,
.qt-mobile-register,
.qt-mobile-user,
.qt-mobile-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 24px;
    text-decoration: none;
    font-weight: 700;
    font-size: .9rem;
}

.qt-mobile-login {
    flex: 1;
    background: var(--bg-alt, #f4f7fb);
    color: var(--text-soft, #475569);
    border: 1px solid var(--border, #e8eef5);
}

.qt-mobile-register {
    flex: 1;
    background: linear-gradient(135deg, #f5cd5a, #e0a82e);
    color: #fff;
}

.qt-mobile-user {
    background: var(--gold-soft, rgba(224, 168, 46, .1));
    color: var(--gold-deep, #b8841a);
    margin-bottom: 8px;
}

.qt-mobile-logout {
    background: rgba(244, 63, 94, .1);
    color: #f43f5e;
}

/* ============================================================
   ۱۳. فوتر ساده admin/account
   ============================================================ */
.qt-panel-footer {
    background: var(--bg-alt, #f4f7fb);
    border-top: 1px solid var(--border, #e8eef5);
    padding: 24px 0;
    margin-top: auto;
}

.qt-panel-footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: .85rem;
    color: var(--text-mute, #94a3b8);
}

.qt-panel-footer-sep {
    opacity: .5;
}

html[data-theme="dark"] .qt-panel-footer {
    background: #0d1520;
    border-color: #1e2a3d;
}

.qt-panel-content {
    min-height: calc(100vh - 200px);
    padding: 30px 0 50px;
}