/* ==========================================================================
   Site Header v4 — آینده ما
   همهٔ کلاس‌ها با پیشوند sh- تا قوانین قدیمی app.css روی هدر اثر نگذارند.
   markup: laravel/resources/views/layouts/header.blade.php · رفتار: js/site-header.js
   ========================================================================== */

:root {
    --site-header-offset: 4.25rem;
}

.sh,
.sh-drawer,
.sh-notice {
    --sh-font: 'Mikhak-R', 'Vazirmatn', Tahoma, sans-serif;
    --sh-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #22d3ee 135%);
    --sh-bg: rgba(255, 255, 255, 0.84);
    --sh-bg-solid: #ffffff;
    --sh-ink: #1e1b4b;
    --sh-muted: #5d6189;
    --sh-faint: #8b8fb5;
    --sh-line: rgba(79, 70, 229, 0.12);
    --sh-hover: rgba(99, 102, 241, 0.08);
    --sh-active: rgba(99, 102, 241, 0.13);
    --sh-accent: #4f46e5;
    --sh-accent-2: #0891b2;
    --sh-field: rgba(99, 102, 241, 0.06);
    --sh-danger: #dc2626;
    --sh-shadow: 0 10px 30px rgba(30, 27, 75, 0.08);
    --sh-panel-shadow: 0 24px 60px rgba(30, 27, 75, 0.18), 0 2px 6px rgba(30, 27, 75, 0.06);
    --sh-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --sh-radius: 14px;
    font-family: var(--sh-font);
}

html[data-theme="dark"] .sh,
html[data-theme="dark"] .sh-drawer,
html[data-theme="dark"] html[data-theme="dark"] .sh-notice {
    --sh-bg: rgba(16, 14, 42, 0.84);
    --sh-bg-solid: #16133a;
    --sh-ink: #eef0ff;
    --sh-muted: #a7abd8;
    --sh-faint: #7c80ad;
    --sh-line: rgba(167, 139, 250, 0.16);
    --sh-hover: rgba(139, 92, 246, 0.14);
    --sh-active: rgba(139, 92, 246, 0.22);
    --sh-accent: #a78bfa;
    --sh-accent-2: #67e8f9;
    --sh-field: rgba(255, 255, 255, 0.06);
    --sh-danger: #f87171;
    --sh-shadow: 0 12px 36px rgba(4, 3, 20, 0.45);
    --sh-panel-shadow: 0 28px 70px rgba(4, 3, 20, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

/* ── نوار اعلان ایمیل موقت ── */
.sh-notice {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fcd34d;
    padding: 0.6rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.6;
}
.sh-notice a { color: #b45309; font-weight: 700; text-decoration: underline; }

/* ── پوستهٔ هدر ── */
header.modern-header.sh {
    position: sticky;
    top: 0;
    z-index: 12000;
    isolation: isolate;
    overflow: visible;
    background: var(--sh-bg);
    color: var(--sh-ink);
    border-bottom: 1px solid var(--sh-line);
    box-shadow: none;
    backdrop-filter: blur(18px) saturate(1.5);
    -webkit-backdrop-filter: blur(18px) saturate(1.5);
    transition: box-shadow 0.25s ease, background 0.25s ease;
}
header.modern-header.sh.is-scrolled { box-shadow: var(--sh-shadow); }

/* نوار نازک برند در لبهٔ پایین */
header.modern-header.sh::after {
    content: "";
    position: absolute;
    inset: auto 0 -1px 0;
    height: 2px;
    background: var(--sh-grad);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
header.modern-header.sh.is-scrolled::after { opacity: 0.9; }

.sh-inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    max-width: 1320px;
    margin: 0 auto;
    height: 4.25rem;
    padding: 0 clamp(0.85rem, 2.5vw, 1.5rem);
    transition: height 0.25s var(--sh-ease);
}
header.sh.is-scrolled .sh-inner { height: 3.75rem; }

.sh a { text-decoration: none; }
.sh button,
.sh-drawer button { font-family: inherit; }
.sh ul,
.sh-drawer ul { list-style: none; margin: 0; padding: 0; }

.sh :focus-visible,
.sh-drawer :focus-visible {
    outline: 2px solid var(--sh-accent);
    outline-offset: 2px;
    border-radius: 10px;
}

/* ── برند ── */
.sh-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--sh-ink);
    min-height: 2.75rem;
}
.sh-brand-mark {
    width: 2.5rem;
    height: 2.5rem;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--sh-grad);
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: transform 0.3s var(--sh-ease);
}
.sh-brand:hover .sh-brand-mark { transform: rotate(-8deg) scale(1.05); }
.sh-brand-text {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: -0.01em;
    white-space: nowrap;
    color: var(--sh-ink);
}

/* ── ناوبری اصلی ── */
.sh-nav { justify-self: center; min-width: 0; }
.sh-nav-list { display: flex; align-items: center; gap: 0.25rem; }
.sh-nav-list > li { position: relative; }

.sh-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.75rem;
    padding: 0 0.95rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--sh-muted);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.18s ease, background 0.18s ease;
}
.sh-link:hover,
.sh-dd.is-open > .sh-link { color: var(--sh-ink); background: var(--sh-hover); }
.sh-link.is-active { color: var(--sh-accent); }
.sh-link.is-active::after {
    content: "";
    position: absolute;
    inset: auto 0.95rem 0.35rem 0.95rem;
    height: 2px;
    border-radius: 2px;
    background: var(--sh-grad);
}
.sh-caret { font-size: 0.62rem; opacity: 0.7; transition: transform 0.22s var(--sh-ease); }
.sh-dd.is-open .sh-caret { transform: rotate(180deg); }

/* ── پنل‌های کشویی ── */
.sh-dd { position: relative; }
.sh-panel {
    position: absolute;
    top: calc(100% + 0.6rem);
    inset-inline-start: 0;
    z-index: 12100;
    min-width: 18rem;
    padding: 0.5rem;
    border-radius: 18px;
    background: var(--sh-bg-solid);
    border: 1px solid var(--sh-line);
    box-shadow: var(--sh-panel-shadow);
    color: var(--sh-ink);
    transform-origin: top center;
    animation: shPanelIn 0.2s var(--sh-ease);
}
.sh-panel[hidden] { display: none; }
.sh-panel--wide { min-width: 34rem; padding: 0.85rem; }
.sh-panel--menu { inset-inline-start: auto; inset-inline-end: 0; min-width: 17rem; max-height: min(75vh, calc(100dvh - 5rem)); overflow-y: auto; overscroll-behavior: contain; }

@keyframes shPanelIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.sh-panel-title {
    margin: 0 0.35rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--sh-faint);
}
.sh-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem; }
.sh-tiles--single { grid-template-columns: 1fr; }

.sh-tile {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.75rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--sh-ink);
    text-align: start;
    cursor: pointer;
    transition: background 0.16s ease;
}
.sh-tile:hover { background: var(--sh-hover); }
.sh-tile.is-active { background: var(--sh-active); }
.sh-tile-icon {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--sh-field);
    color: var(--sh-accent);
    font-size: 1rem;
    transition: background 0.16s ease, color 0.16s ease;
}
.sh-tile:hover .sh-tile-icon { background: var(--sh-grad); color: #fff; }
.sh-tile-copy { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.sh-tile-copy strong { font-size: 0.92rem; font-weight: 800; display: inline-flex; align-items: center; gap: 0.4rem; }
.sh-tile-copy small { font-size: 0.78rem; color: var(--sh-muted); line-height: 1.5; }

.sh-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.05rem 0.45rem;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 800;
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.12);
}
html[data-theme="dark"] .sh-tag { color: #c4b5fd; background: rgba(167, 139, 250, 0.18); }

.sh-panel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.6rem;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    background: var(--sh-field);
    color: var(--sh-accent);
    font-size: 0.86rem;
    font-weight: 800;
}
.sh-panel-foot:hover { background: var(--sh-active); }

/* ── سمت چپ: جست‌وجو، دکمه‌ها، CTA ── */
.sh-actions { display: flex; align-items: center; gap: 0.5rem; justify-self: end; }

.sh-icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 auto;
    border: 1px solid var(--sh-line);
    border-radius: 12px;
    background: transparent;
    color: var(--sh-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.sh-icon-btn:hover,
.sh-icon-btn.is-active { color: var(--sh-accent); background: var(--sh-hover); border-color: transparent; }

.sh-badge {
    position: absolute;
    top: -0.3rem;
    inset-inline-start: -0.3rem;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.3rem;
    display: grid;
    place-items: center;
    border-radius: 99px;
    background: #ec4899;
    color: #fff;
    font: 800 0.68rem/1 var(--sh-font);
    box-shadow: 0 0 0 2px var(--sh-bg-solid);
}
.sh-badge--inline { position: static; box-shadow: none; margin-inline-start: auto; }

.sh-cta,
.sh-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0 1.1rem;
    border-radius: 12px;
    background: var(--sh-grad);
    background-size: 140% 100%;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: transform 0.18s var(--sh-ease), box-shadow 0.2s ease, background-position 0.4s ease;
}
.sh-cta:hover,
.sh-primary:hover { transform: translateY(-1px); background-position: 100% 0; box-shadow: 0 12px 28px rgba(139, 92, 246, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3); color: #fff; }
.sh-cta:active,
.sh-primary:active { transform: translateY(0) scale(0.98); }
.sh-cta.is-active { box-shadow: 0 0 0 2px var(--sh-bg-solid), 0 0 0 4px #8b5cf6; }

.sh-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0 1rem;
    border-radius: 12px;
    color: var(--sh-ink);
    font-size: 0.9rem;
    font-weight: 800;
    border: 1px solid var(--sh-line);
    transition: background 0.18s ease, border-color 0.18s ease;
}
.sh-ghost:hover { background: var(--sh-hover); border-color: transparent; color: var(--sh-ink); }

/* ── کاربر ── */
.sh-user-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.75rem;
    padding: 0.2rem 0.7rem 0.2rem 0.25rem;
    padding-inline: 0.25rem 0.7rem;
    border: 1px solid var(--sh-line);
    border-radius: 99px;
    background: transparent;
    color: var(--sh-ink);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.sh-user-btn:hover,
.sh-dd.is-open > .sh-user-btn { background: var(--sh-hover); border-color: transparent; }
.sh-user-name { max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sh-avatar {
    position: relative;
    width: 2.2rem;
    height: 2.2rem;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    overflow: hidden;
    background: var(--sh-grad);
    color: #fff;
    font-size: 0.85rem;
}
.sh-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sh-avatar--lg { width: 3rem; height: 3rem; font-size: 1.1rem; }
.sh-avatar--premium { box-shadow: 0 0 0 2px #f59e0b; }
.sh-avatar--platinum { box-shadow: 0 0 0 2px #a78bfa; }
.sh-avatar--admin { box-shadow: 0 0 0 2px #ec4899; }

.sh-me { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.6rem 0.8rem; min-width: 0; }
.sh-me-copy { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.sh-me-copy strong { font-size: 0.95rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--sh-ink); }
.sh-role {
    align-self: flex-start;
    padding: 0.08rem 0.55rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--sh-accent);
    background: var(--sh-active);
}
.sh-role--premium { color: #b45309; background: rgba(245, 158, 11, 0.16); }
.sh-role--platinum { color: #7c3aed; background: rgba(124, 58, 237, 0.14); }
.sh-role--admin { color: #be185d; background: rgba(236, 72, 153, 0.14); }
html[data-theme="dark"] .sh-role--premium { color: #fcd34d; }
html[data-theme="dark"] .sh-role--platinum { color: #c4b5fd; }
html[data-theme="dark"] .sh-role--admin { color: #f9a8d4; }

.sh-menu { display: grid; gap: 0.1rem; }
.sh-panel .sh-menu { padding-top: 0.4rem; border-top: 1px solid var(--sh-line); }
.sh-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0 0.75rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--sh-ink);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}
.sh-menu-item i { width: 1.1rem; text-align: center; color: var(--sh-faint); transition: color 0.16s ease; }
.sh-menu-item:hover { background: var(--sh-hover); color: var(--sh-ink); }
.sh-menu-item:hover i,
.sh-menu-item.is-active i { color: var(--sh-accent); }
.sh-menu-item.is-active { background: var(--sh-active); color: var(--sh-accent); font-weight: 800; }
.sh-menu-item .sh-tag { margin-inline-start: auto; }
.sh-menu-item--danger,
.sh-menu-item--danger i { color: var(--sh-danger) !important; }
.sh-menu-item--danger:hover { background: rgba(220, 38, 38, 0.08); }
.sh-menu-foot { margin: 0.4rem 0 0; padding-top: 0.4rem; border-top: 1px solid var(--sh-line); }

/* ── کشوی موبایل ── */
.sh-burger { display: none; }

.sh-scrim {
    position: fixed;
    inset: 0;
    z-index: 12990;
    background: rgba(10, 8, 30, 0.5);
    backdrop-filter: blur(3px);
    animation: shFade 0.2s ease;
}
.sh-scrim[hidden] { display: none; }

.sh-drawer {
    position: fixed;
    inset-block: 0;
    right: 0;
    z-index: 13000;
    width: min(88vw, 360px);
    display: flex;
    flex-direction: column;
    background: var(--sh-bg-solid);
    color: var(--sh-ink);
    border-inline-start: 1px solid var(--sh-line);
    box-shadow: -24px 0 60px rgba(10, 8, 30, 0.3);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform 0.3s var(--sh-ease), visibility 0.3s;
    direction: rtl;
}
.sh-drawer.is-open { transform: none; visibility: visible; }
.sh-drawer a { text-decoration: none; }

.sh-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: max(0.75rem, env(safe-area-inset-top)) 0.85rem 0.6rem;
    border-bottom: 1px solid var(--sh-line);
}
.sh-drawer-head .sh-me { padding: 0.25rem 0; }
.sh-drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0.85rem; display: flex; flex-direction: column; gap: 0.25rem; }
.sh-drawer-foot { padding: 0.6rem 0.85rem max(0.75rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--sh-line); display: grid; gap: 0.1rem; }
.sh-drawer-label { margin: 0.9rem 0.75rem 0.3rem; font-size: 0.75rem; font-weight: 800; color: var(--sh-faint); }
.sh-cta--block { width: 100%; min-height: 3rem; }
.sh-drawer-auth { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.5rem; }

@keyframes shFade { from { opacity: 0; } to { opacity: 1; } }

body.sh-locked { overflow: hidden !important; }
/* دکمهٔ شناور چت (z-index 13050) روی کشو نیفتد */
body.sh-locked > .advisor-widget { visibility: hidden; }

/* ── واکنش‌گرایی ── */
@media (max-width: 1080px) {
    .sh-user-name { display: none; }
    .sh-link { padding: 0 0.7rem; }
}

@media (max-width: 1023px) {
    .sh-inner { grid-template-columns: auto 1fr; height: 3.75rem; gap: 0.75rem; }
    header.sh.is-scrolled .sh-inner { height: 3.5rem; }
    .sh-nav,
    .sh-hide-mobile { display: none !important; }
    .sh-burger { display: inline-grid; }
    .sh-actions { gap: 0.4rem; }
    .sh-user { display: none; }
    .sh-brand-mark { width: 2.25rem; height: 2.25rem; }
    .sh-brand-text { font-size: 1.05rem; }
}

@media (min-width: 1024px) {
    .sh-scrim,
    .sh-drawer { display: none !important; }
}

@media (max-width: 380px) {
    .sh-brand-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sh *,
    .sh-drawer,
    .sh-panel { animation: none !important; transition: none !important; }
}

/* دکمهٔ «ایجاد برنامه‌ریزی» در ریل ناوبری (جای قبلی «بازه‌ها») */
.sh-cta--nav { margin-inline-end: 0.35rem; }
