/* ====== Хедер v3 — светлый стиль ====== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');
@import url('/css/strela-brand-font.css');

/* Высота fixed-хедера (для padding-top контента; JS может переопределить по getBoundingClientRect) */
:root {
    --strela-safe-top: env(safe-area-inset-top, 0px);
    --strela-header-base-h: 56px;
    --strela-header-h: calc(var(--strela-header-base-h) + var(--strela-safe-top));
    --strela-toast-gap: 10px;
    --strela-toast-top: calc(var(--strela-header-h) + var(--strela-toast-gap));
}
@media (max-width: 768px) {
    :root {
        --strela-header-base-h: 52px;
        --strela-header-h: calc(var(--strela-header-base-h) + var(--strela-safe-top));
    }
}

.custom-header,
.dropdown-menu,
.dropdown-menu .nav-menu,
.dropdown-menu .nav-menu a,
.menu-button,
.menu-controls-row {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

.custom-header {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 14px 0;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2000;
    box-sizing: border-box;
    transform: none;
    overflow: hidden;
}

/* Apple-style vibrancy: жёсткий blur на слое ::before (кнопки поверх без размытия) */
.custom-header::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: rgba(13, 21, 32, 0.58);
    backdrop-filter: saturate(220%) blur(48px);
    -webkit-backdrop-filter: saturate(220%) blur(48px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: background 0.3s ease, box-shadow 0.3s ease, backdrop-filter 0.3s ease;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.custom-header > * {
    position: relative;
    z-index: 1;
}

.custom-header * { box-sizing: border-box; margin: 0; padding: 0; }

.custom-header.scrolled::before {
    background: rgba(13, 21, 32, 0.68);
    backdrop-filter: saturate(240%) blur(52px);
    -webkit-backdrop-filter: saturate(240%) blur(52px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 4px 24px rgba(0, 0, 0, 0.18);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .custom-header::before {
        background: rgba(13, 21, 32, 0.94);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    [data-theme="light"] .custom-header::before {
        background: rgba(255, 255, 255, 0.94);
    }
}

/* ====== Бренд-блок ====== */
.hdr-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.hh-brand,
.messenger .hdr-brand,
[data-strela-logo-refresh] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

.hdr-brand.hdr-brand--refresh-hold .hdr-logo-icon,
.hh-brand.hdr-brand--refresh-hold .hh-icon {
    transform: scale(0.9);
    transition: transform 0.15s ease;
}

.hdr-brand.hdr-brand--refresh-hold,
.hh-brand.hdr-brand--refresh-hold {
    opacity: 0.88;
}

.hdr-logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e8a920;
    flex-shrink: 0;
    /* без фона и бордера — чистый логотип */
}

.hdr-logo-icon svg {
    width: 38px;
    height: auto;
    display: block;
    /* SVG масштабируется векторно, качество не теряется */
}

/* Две фигуры лого: в тёмной теме — светлый бежево-серый #e6e6e6 */
.hdr-logo-icon .hdr-logo-part--upper,
.hdr-logo-icon .hdr-logo-part--lower {
    fill: #e6e6e6;
}

[data-theme="light"] .hdr-logo-icon .hdr-logo-part--upper {
    fill: #000000;
}

[data-theme="light"] .hdr-logo-icon .hdr-logo-part--lower {
    fill: #2c3e50;
}

.hdr-brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.hdr-brand-name {
    font-size: 14px;
    color: #f8fafc;
    letter-spacing: 0.06em;
    line-height: 1.05;
    text-transform: uppercase;
}

/* Подзаголовок: по умолчанию "ЭКОСИСТЕМА СПЕЦТЕХНИКИ".
   На конкретной странице можно переопределить JS-ом:
   document.querySelector('.hdr-page-subtitle').textContent = 'СИСТЕМА ДОВЕРИЯ'; */
.hdr-page-subtitle {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 9px;
    font-weight: 500;
    color: #4d5e7a;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    line-height: 1.15;
    margin-top: 1px;
}

/* ====== Кнопки действий ====== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.hdr-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    text-decoration: none;
    color: #8292b0;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.18s, color 0.18s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.hdr-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f0f4ff;
}
.hdr-back-btn i {
    font-size: 12px;
}
[data-theme="light"] .hdr-back-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #64748b;
}
[data-theme="light"] .hdr-back-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #0f172a;
}

.header-action-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #8292b0;
    transition: background 0.18s, color 0.18s;
    cursor: pointer;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

/* iOS/touch: см. глобальное правило в touch-optimization.css */

.header-action-btn svg {
    width: 20px; height: 20px;
    min-width: 20px; min-height: 20px;
    fill: currentColor;
    display: block;
}

.header-action-btn svg path,
.header-action-btn svg g,
.header-action-btn svg circle,
.header-action-btn svg rect { fill: currentColor; }

.header-action-btn:hover { background: rgba(255,255,255,0.1); color: #f0f4ff; }
.header-action-btn.active-page { background: rgba(255,255,255,0.09); color: #f0f4ff; }

/* Роль-кнопка */
.header-role-btn {
    background: rgba(232, 169, 32, 0.08);
    border: 1px solid rgba(232, 169, 32, 0.18) !important;
    color: #e8a920;
}
.header-role-btn:hover { background: rgba(232,169,32,0.14); color: #e8a920; }
.header-role-btn.active-page { background: rgba(232,169,32,0.15); border-color: rgba(232,169,32,0.35) !important; color: #e8a920; }

.ha-role-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: inherit; }
.ha-role-icon svg {
    width: 20px;
    height: 20px;
    /* override hardcoded attributes in SVG files */
    min-width: 20px;
    min-height: 20px;
    fill: currentColor !important;
    color: inherit;
    display: block;
}
.ha-role-icon svg *,
.ha-role-icon svg path,
.ha-role-icon svg g,
.ha-role-icon svg circle,
.ha-role-icon svg rect,
.ha-role-icon svg polygon,
.ha-role-icon svg polyline,
.ha-role-icon svg line,
.ha-role-icon svg ellipse,
.ha-role-icon svg use { fill: currentColor !important; }

/* Бейдж */
.ha-badge {
    position: absolute;
    top: -3px; right: -3px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: #ef4444;
    color: #fff;
    font-size: 9px; font-weight: 700;
    border-radius: 99px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(13,21,32,0.9);
    line-height: 1;
}

/* ====== Бургер ====== */
.menu-button {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    color: #8292b0;
    cursor: pointer; z-index: 2001;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: background 0.18s, color 0.18s;
    mix-blend-mode: normal; filter: none;
    -webkit-tap-highlight-color: transparent;
}
.menu-button svg { width: 20px; height: 20px; fill: currentColor; }
.menu-button svg path, .menu-button svg g { fill: currentColor; }
.menu-button:hover { background: rgba(255,255,255,0.1); color: #f0f4ff; }
.menu-button.is-dark { color: #2c3e50 !important; background: rgba(0,0,0,0.06) !important; }

/* ====== Старый логотип (совместимость) ====== */
.logo-svg-adaptive { display: block; height: 38px; width: auto; color: #f0f4ff; fill: currentColor; }
.logo-svg-adaptive path, .logo-svg-adaptive g { fill: currentColor !important; }
.logo-svg-adaptive.is-dark { color: #2c3e50 !important; }

/* ====== Dropdown ====== */
.dropdown-menu {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100vh;
    height: 100dvh;
    background: rgba(13, 21, 32, 0.99);
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    opacity: 0; visibility: hidden;
    transform: translateY(-100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100050;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    padding-top: calc(var(--strela-header-h, 56px) + 16px);
    padding-bottom: max(32px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}
.dropdown-menu.active { opacity: 1; visibility: visible; transform: translateY(0); }

.nav-menu { list-style: none; text-align: center; width: 100%; max-width: 360px; padding: 0 20px 80px; margin: 0; display: none; }
.nav-menu li { margin: 14px 0; }
.nav-menu li a { text-decoration: none; color: white; font-size: 24px; font-weight: 500; transition: color 0.3s ease; }
.nav-menu li a:hover { color: #e8a920; }

.close-button {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: max(16px, env(safe-area-inset-right, 0px));
    z-index: 100053;
    font-size: 0;
    color: #e8edf5; cursor: pointer;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.08);
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
}
.close-button i {
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
}
.close-button:hover { color: #fff; background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2); }
[data-theme="light"] .close-button {
    color: #92400e;
    background: #fff;
    border: 1px solid rgba(146, 64, 14, 0.22);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}
[data-theme="light"] .close-button:hover {
    color: #7c2d12;
    background: #fffbeb;
    border-color: rgba(217, 119, 6, 0.35);
}

/* ====== Адаптивность ====== */
@media (max-width: 768px) {
    .custom-header {
        height: calc(52px + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) 12px 0;
    }
    .hdr-brand-name { font-size: 13px; }
    .hdr-page-subtitle { font-size: 8px; }
    .dropdown-menu { padding-top: calc(var(--strela-header-h, 52px) + 12px); }
}

/* ====== Светлая тема ====== */
[data-theme="light"] .custom-header::before {
    background: rgba(255, 255, 255, 0.68);
    backdrop-filter: saturate(220%) blur(48px);
    -webkit-backdrop-filter: saturate(220%) blur(48px);
    border-bottom-color: rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

[data-theme="light"] .custom-header.scrolled::before {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: saturate(240%) blur(52px);
    -webkit-backdrop-filter: saturate(240%) blur(52px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.85),
        0 4px 20px rgba(15, 23, 42, 0.08);
}

/* Тёмная тема — стеклянный blur (как в базовом .custom-header::before) */
[data-theme="dark"] .custom-header::before,
html:not([data-theme="light"]) .custom-header::before {
    background: rgba(13, 21, 32, 0.58);
    border-bottom-color: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: saturate(220%) blur(48px);
    -webkit-backdrop-filter: saturate(220%) blur(48px);
}
[data-theme="dark"] .custom-header.scrolled::before,
html:not([data-theme="light"]) .custom-header.scrolled::before {
    background: rgba(13, 21, 32, 0.68);
    backdrop-filter: saturate(240%) blur(52px);
    -webkit-backdrop-filter: saturate(240%) blur(52px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 4px 24px rgba(0, 0, 0, 0.18);
}
[data-theme="dark"] .dropdown-menu,
html:not([data-theme="light"]) .dropdown-menu {
    background: rgba(13, 21, 32, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* WebView: усиленный blur; при слабом GPU — плотный фон из @supports в базовых правилах */
html.strela-native-app .custom-header::before,
html.strela-native-app .hh::before {
    backdrop-filter: saturate(250%) blur(56px) !important;
    -webkit-backdrop-filter: saturate(250%) blur(56px) !important;
}
html.strela-native-app:not([data-theme="light"]) .custom-header::before,
html.strela-native-app:not([data-theme="light"]) .hh::before {
    background: rgba(13, 21, 32, 0.62) !important;
}
html.strela-native-app[data-theme="light"] .custom-header::before,
html.strela-native-app[data-theme="light"] .hh::before {
    background: rgba(255, 255, 255, 0.72) !important;
}

[data-theme="light"] .hdr-brand-name { color: #0f172a; }
[data-theme="light"] .hdr-page-subtitle { color: #94a3b8; }
[data-theme="light"] .header-action-btn { background: rgba(0,0,0,0.05); color: #64748b; }
[data-theme="light"] .header-action-btn:hover { background: rgba(0,0,0,0.09); color: #1e293b; }
[data-theme="light"] .menu-button { background: rgba(0,0,0,0.05); color: #64748b; }
[data-theme="light"] .menu-button:hover { background: rgba(0,0,0,0.09); color: #1e293b; }
[data-theme="light"] .dropdown-menu { background: rgba(248,250,252,0.99); }
[data-theme="light"] .ha-badge { border-color: rgba(255,255,255,0.9); }

/* Меню хедера поверх магазинного/мобильного футера (shop-bottom-bar z-index ~99007) */
body.strela-header-menu-open {
    overflow: hidden;
}
body.strela-header-menu-open .custom-header {
    z-index: 100051;
}
body.strela-header-menu-open .dropdown-menu {
    z-index: 100052;
}
body.strela-header-menu-open .dropdown-menu.active {
    visibility: visible;
}
body.strela-header-menu-open .mobile-footer,
body.strela-header-menu-open .shop-bottom-bar,
body.strela-header-menu-open #shopBottomBar {
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transform: translateX(-50%) translateY(120%) !important;
    transition: opacity 0.2s ease, transform 0.25s ease, visibility 0.2s;
}
body.strela-header-menu-open .strela-ios-tg-banner {
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

/* Вспомогательные */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
@media (min-width: 1025px) {
  .container {
    max-width: 40%;
  }
}
.admin-link { position: fixed; bottom: 10px; right: 10px; opacity: 0.35; font-size: 12px; z-index: 9999; }
.admin-link a { color: #999; text-decoration: none; }
button:focus, a:focus { outline: none !important; }
a, button, svg { -webkit-tap-highlight-color: transparent; }