/* Fallback без :has() — старые WebView в PWA на Android */
body.storefront-with-inbox {
    padding-top: var(--storefront-header-offset, calc(var(--header-height, 58px) + env(safe-area-inset-top, 0px) + 8px));
}

body.page-categories.storefront-with-inbox,
body.page-favorites.storefront-with-inbox,
body.page-promo.storefront-with-inbox,
body.page-share.storefront-with-inbox {
    padding-top: var(--storefront-header-offset, calc(var(--header-height, 58px) + env(safe-area-inset-top, 0px) + 8px));
}

body.storefront-with-inbox #vpnWarning {
    top: calc(
        env(safe-area-inset-top, 0px) +
        var(--storefront-header-row-height, 48px) +
        var(--storefront-header-pad-bottom, 10px)
    ) !important;
}

/* WB-style: белая шапка = status bar + поиск, без разделительной полосы */
body.storefront-with-inbox .search-header {
    min-height: 0 !important;
    height: auto !important;
    background: var(--storefront-header-backdrop-bg, var(--accent-surface-bg)) !important;
    box-shadow: none !important;
    border: none !important;
    border-bottom: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    align-items: flex-end !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    padding-bottom: var(--storefront-header-pad-bottom, 10px) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
}

body.storefront-with-inbox .search-header::before {
    content: "" !important;
    position: absolute !important;
    top: -12px !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    background: inherit !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

body.storefront-with-inbox .search-header__row {
    width: 100%;
    max-width: none !important;
    gap: 8px !important;
    margin: 0 !important;
    align-items: center;
    background: var(--storefront-header-bg, #ffffff) !important;
    border-radius: 0 0 var(--storefront-header-radius, 16px) var(--storefront-header-radius, 16px) !important;
    box-sizing: border-box !important;
    padding: var(--storefront-header-row-pad-y, 8px)
        max(var(--storefront-header-row-pad-x, 8px), env(safe-area-inset-right, 0px))
        var(--storefront-header-row-pad-y, 8px)
        max(var(--storefront-header-row-pad-x, 8px), env(safe-area-inset-left, 0px)) !important;
}

body.storefront-with-inbox .search-container {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    width: auto !important;
    margin: 0 !important;
}

body.storefront-with-inbox .search-input {
    width: 100% !important;
    height: var(--storefront-header-control-height, 48px);
    background: var(--accent-surface-bg) !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 800 !important;
    caret-color: var(--accent-color, #9400D3) !important;
}

body.storefront-with-inbox .search-input::placeholder,
body.storefront-with-inbox .search-input::-webkit-input-placeholder,
body.storefront-with-inbox .search-input::-moz-placeholder {
    color: var(--accent-color, #9400D3) !important;
    opacity: 1 !important;
}

body.storefront-with-inbox .header-notify {
    flex: 0 0 auto;
    margin: 0 !important;
    padding: 0 !important;
}

@media (display-mode: standalone) {
    #vpnWarning {
        top: calc(
            env(safe-area-inset-top, 0px) +
            var(--storefront-header-row-height, 48px) +
            var(--storefront-header-pad-bottom, 10px)
        ) !important;
    }
}

.search-header:has(.header-inbox-link) {
    min-height: 0 !important;
    height: auto !important;
    background: var(--storefront-header-backdrop-bg, var(--accent-surface-bg)) !important;
    box-shadow: none !important;
    border: none !important;
    border-bottom: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    align-items: flex-end !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    padding-bottom: var(--storefront-header-pad-bottom, 10px) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
}

.search-header:has(.header-inbox-link)::before {
    content: "" !important;
    position: absolute !important;
    top: -12px !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(env(safe-area-inset-top, 0px) + 12px) !important;
    background: inherit !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

.search-header:has(.header-inbox-link) .search-header__row {
    width: 100%;
    max-width: none !important;
    gap: 8px !important;
    margin: 0 !important;
    align-items: center;
    background: var(--storefront-header-bg, #ffffff) !important;
    border-radius: 0 0 var(--storefront-header-radius, 16px) var(--storefront-header-radius, 16px) !important;
    box-sizing: border-box !important;
    padding: var(--storefront-header-row-pad-y, 8px)
        max(var(--storefront-header-row-pad-x, 8px), env(safe-area-inset-right, 0px))
        var(--storefront-header-row-pad-y, 8px)
        max(var(--storefront-header-row-pad-x, 8px), env(safe-area-inset-left, 0px)) !important;
}

.search-header:has(.header-inbox-link) .search-container {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    width: auto !important;
    margin: 0 !important;
}

.search-header:has(.header-inbox-link) .search-input {
    width: 100% !important;
    height: var(--storefront-header-control-height, 48px);
    background: var(--accent-surface-bg) !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 800 !important;
    caret-color: var(--accent-color, #9400D3) !important;
}

.search-header:has(.header-inbox-link) .search-input::placeholder,
.search-header:has(.header-inbox-link) .search-input::-webkit-input-placeholder,
.search-header:has(.header-inbox-link) .search-input::-moz-placeholder {
    color: var(--accent-color, #9400D3) !important;
    opacity: 1 !important;
}

.search-header:has(.header-inbox-link) .header-notify {
    flex: 0 0 auto;
    margin: 0 !important;
    padding: 0 !important;
}

body:has(.search-header .header-inbox-link) {
    padding-top: var(--storefront-header-offset, calc(var(--header-height, 58px) + env(safe-area-inset-top, 0px) + 8px));
}

body.page-categories:has(.search-header .header-inbox-link),
body.page-favorites:has(.search-header .header-inbox-link),
body.page-promo:has(.search-header .header-inbox-link),
body.page-share:has(.search-header .header-inbox-link) {
    padding-top: var(--storefront-header-offset, calc(var(--header-height, 58px) + env(safe-area-inset-top, 0px) + 8px));
}

:root[data-theme="dark"] body.storefront-with-inbox .search-header,
:root[data-theme="dark"] .search-header:has(.header-inbox-link) {
    background: var(--storefront-header-backdrop-bg, var(--accent-surface-bg)) !important;
}

:root[data-theme="dark"] body.storefront-with-inbox .search-header__row,
:root[data-theme="dark"] .search-header:has(.header-inbox-link) .search-header__row {
    background: var(--header-bg, #1a1a24) !important;
}

@media (prefers-color-scheme: dark) {
    :root:is(:not([data-theme]), [data-theme="system"]) body.storefront-with-inbox .search-header,
    :root:is(:not([data-theme]), [data-theme="system"]) .search-header:has(.header-inbox-link) {
        background: var(--storefront-header-backdrop-bg, var(--accent-surface-bg)) !important;
    }

    :root:is(:not([data-theme]), [data-theme="system"]) body.storefront-with-inbox .search-header__row,
    :root:is(:not([data-theme]), [data-theme="system"]) .search-header:has(.header-inbox-link) .search-header__row {
        background: var(--header-bg, #1a1a24) !important;
    }
}

/* Постоянное свечение как у .bottom-nav-item:active / .active */
.header-inbox-link.header-bell {
    width: calc(var(--storefront-header-control-height, 48px) + 6px) !important;
    height: var(--storefront-header-control-height, 48px) !important;
    background: var(--accent-surface-bg) !important;
    border-radius: 14px !important;
    box-shadow: 0 1px 4px rgba(148, 0, 211, 0.1) !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.header-inbox-link.header-bell:active,
.header-inbox-link.header-bell.active {
    background: var(--accent-surface-bg-pressed) !important;
    box-shadow: 0 2px 8px rgba(148, 0, 211, 0.14) !important;
    opacity: 1 !important;
}

/* Главная: объёмная кнопка чата в шапке */
body.page-home .header-inbox-link.header-bell {
    background: var(--volume-chat-bg, linear-gradient(180deg, #faf4ff 0%, #f0e4fa 100%)) !important;
    border: 1px solid var(--volume-chat-border, rgba(148, 0, 211, 0.18)) !important;
    box-shadow: var(--volume-chat-shadow, 0 4px 14px rgba(148, 0, 211, 0.2)) !important;
}

body.page-home .header-inbox-link.header-bell:active,
body.page-home .header-inbox-link.header-bell.active {
    background: var(--volume-chat-bg-active, linear-gradient(180deg, #efe4f8 0%, #e5d4f2 100%)) !important;
    box-shadow: var(--volume-chat-shadow-active, 0 2px 5px rgba(148, 0, 211, 0.12) inset) !important;
}

/* Главная: объёмное поле поиска */
body.page-home.storefront-with-inbox .search-input {
    background: var(--volume-stepper-bg, linear-gradient(180deg, #faf4ff 0%, #f0e4fa 100%)) !important;
    border: 1px solid var(--volume-stepper-border, rgba(148, 0, 211, 0.2)) !important;
    box-shadow: var(--volume-stepper-shadow, 0 4px 14px rgba(148, 0, 211, 0.2)) !important;
    border-radius: 14px !important;
    transition: box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease !important;
}

body.page-home.storefront-with-inbox .search-input:focus {
    background: var(--volume-stepper-bg-active, linear-gradient(180deg, #efe4f8 0%, #e5d4f2 100%)) !important;
    border-color: rgba(148, 0, 211, 0.28) !important;
    box-shadow:
        var(--volume-stepper-shadow, 0 4px 14px rgba(148, 0, 211, 0.2)),
        0 0 0 2px rgba(148, 0, 211, 0.12) !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body.page-home.storefront-with-inbox .search-input {
        background: var(--volume-stepper-bg) !important;
        border-color: var(--volume-stepper-border) !important;
        box-shadow: var(--volume-stepper-shadow) !important;
    }

    :root:not([data-theme="light"]) body.page-home.storefront-with-inbox .search-input:focus {
        background: var(--volume-stepper-bg-active) !important;
        box-shadow:
            var(--volume-stepper-shadow),
            0 0 0 2px rgba(199, 125, 255, 0.16) !important;
    }
}

:root[data-theme="dark"] body.page-home.storefront-with-inbox .search-input {
    background: var(--volume-stepper-bg) !important;
    border-color: var(--volume-stepper-border) !important;
    box-shadow: var(--volume-stepper-shadow) !important;
}

:root[data-theme="dark"] body.page-home.storefront-with-inbox .search-input:focus {
    background: var(--volume-stepper-bg-active) !important;
    box-shadow:
        var(--volume-stepper-shadow),
        0 0 0 2px rgba(199, 125, 255, 0.16) !important;
}

.header-inbox-link .header-bell__icon.header-bell__icon--inbox {
    width: 36px !important;
    height: 30px !important;
    min-width: 36px !important;
    min-height: 30px !important;
    max-width: none !important;
    flex-shrink: 0 !important;
    color: var(--accent-color, #9400D3) !important;
    opacity: 1 !important;
}

.header-inbox-link .header-inbox-svg,
.header-inbox-link .header-bell__icon--inbox svg {
    width: 36px !important;
    height: 30px !important;
    min-width: 36px !important;
    min-height: 30px !important;
    display: block !important;
    color: var(--accent-color, #9400D3) !important;
}

.header-inbox-link .header-inbox-svg path,
.header-inbox-link .header-bell__icon--inbox svg path {
    stroke: currentColor !important;
    stroke-width: 1.9;
}

.header-inbox-link .header-inbox-svg circle,
.header-inbox-link .header-bell__icon--inbox svg circle {
    fill: currentColor !important;
    stroke: none !important;
}

.header-inbox-link:active .header-bell__icon.header-bell__icon--inbox,
.header-inbox-link.active .header-bell__icon.header-bell__icon--inbox,
.header-inbox-link:active .header-inbox-svg,
.header-inbox-link.active .header-inbox-svg {
    color: var(--primary-hover, #4a1a9e) !important;
    opacity: 1 !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .header-inbox-link.header-bell {
        box-shadow: 0 1px 6px rgba(155, 95, 255, 0.12) !important;
    }

    :root:not([data-theme="light"]) body.page-home .header-inbox-link.header-bell {
        background: var(--volume-chat-bg) !important;
        border: 1px solid var(--volume-chat-border) !important;
        box-shadow: var(--volume-chat-shadow) !important;
    }

    :root:not([data-theme="light"]) body.page-home .header-inbox-link.header-bell:active,
    :root:not([data-theme="light"]) body.page-home .header-inbox-link.header-bell.active {
        background: var(--volume-chat-bg-active) !important;
        box-shadow: var(--volume-chat-shadow-active) !important;
    }

    :root:not([data-theme="light"]) .header-inbox-link .header-bell__icon.header-bell__icon--inbox,
    :root:not([data-theme="light"]) .header-inbox-link .header-inbox-svg {
        color: var(--link-accent, #d8c4ff) !important;
    }
}

:root[data-theme="dark"] .header-inbox-link.header-bell {
    box-shadow: 0 1px 6px rgba(155, 95, 255, 0.12) !important;
}

:root[data-theme="dark"] body.page-home .header-inbox-link.header-bell {
    background: var(--volume-chat-bg) !important;
    border: 1px solid var(--volume-chat-border) !important;
    box-shadow: var(--volume-chat-shadow) !important;
}

:root[data-theme="dark"] body.page-home .header-inbox-link.header-bell:active,
:root[data-theme="dark"] body.page-home .header-inbox-link.header-bell.active {
    background: var(--volume-chat-bg-active) !important;
    box-shadow: var(--volume-chat-shadow-active) !important;
}

:root[data-theme="dark"] .header-inbox-link .header-bell__icon.header-bell__icon--inbox,
:root[data-theme="dark"] .header-inbox-link .header-inbox-svg {
    color: var(--link-accent, #d8c4ff) !important;
}

/* Единый фиксированный фон: шапка и нижняя панель прозрачные (каталог, категории, избранное) */
body.storefront-with-inbox:not(.page-cart):not(.page-promo):not(.page-account):not(.page-share) .search-header,
body.storefront-with-inbox:not(.page-cart):not(.page-promo):not(.page-account):not(.page-share) .search-header:has(.header-inbox-link),
:root[data-theme="dark"] body.storefront-with-inbox:not(.page-cart):not(.page-promo):not(.page-account):not(.page-share) .search-header,
:root[data-theme="dark"] body.storefront-with-inbox:not(.page-cart):not(.page-promo):not(.page-account):not(.page-share) .search-header:has(.header-inbox-link) {
    background: transparent !important;
}

@media (prefers-color-scheme: dark) {
    :root:is(:not([data-theme]), [data-theme="system"]) body.storefront-with-inbox:not(.page-cart):not(.page-promo):not(.page-account):not(.page-share) .search-header,
    :root:is(:not([data-theme]), [data-theme="system"]) body.storefront-with-inbox:not(.page-cart):not(.page-promo):not(.page-account):not(.page-share) .search-header:has(.header-inbox-link) {
        background: transparent !important;
    }
}
