/* --- HEADER (STICKY) --- */
.tdps-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--tdps-color-bg-surface);
    border-bottom: 1px solid var(--tdps-color-border);
    height: var(--tdps-header-height);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    will-change: transform;
    display: block;
    width: 100%;
}

/* Учет админ-бара WordPress */
.admin-bar .tdps-header {
    top: 32px;
}
@media (max-width: 782px) {
    .admin-bar .tdps-header {
        top: 46px;
    }
}

.tdps-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 20px;
    max-width: var(--tdps-container-width);
    margin: 0 auto;
    padding: 0 20px;
}

@media (min-width: 1024px) {
    .tdps-header__inner {
        padding: 0 24px;
    }
}
@media (max-width: 768px) {
    .tdps-header__inner {
        padding: 0 16px;
        gap: 12px;
    }
}

.tdps-logo {
    flex-shrink: 0;
    padding: 4px 0;
}
.tdps-logo img {
    height: 40px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    display: block;
}

/* Desktop Search */
.tdps-search-form {
    display: none;
    position: relative;
    width: 100%;
    max-width: 480px;
    margin-inline: auto;
    padding: 6px 0;
}

@media (min-width: 1024px) {
    .tdps-search-form {
        display: flex;
    }
    .tdps-mobile-actions {
        display: none !important;
    }
}

.tdps-search-input {
    width: 100%;
    padding: 8px 44px 8px 16px;
    border: 1px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-md);
    background: var(--tdps-color-bg-subtle);
    outline: none;
    transition: border-color 0.2s;
    height: 40px;
    font-size: 0.9375rem;
}

.tdps-search-input:focus {
    border-color: var(--tdps-color-primary);
    background: #fff;
}

.tdps-search-submit-desktop {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--tdps-color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.tdps-search-submit-desktop:hover {
    color: var(--tdps-color-primary);
}

/* ============================================================
   NAV (desktop) + MENU LIST
   ============================================================ */
.tdps-nav {
    display: none;
    align-items: center;
    gap: 20px;
}
@media (min-width: 1024px) {
    .tdps-nav {
        display: flex;
    }
}

/* Список пунктов меню — единая строка, без браузерных отступов. */
.tdps-nav__list {
    display: flex;
    align-items: center;
    gap: 22px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tdps-nav__list > li {
    margin: 0;
    padding: 0;
    display: block;
    position: relative;
}

.tdps-nav__list > li > a {
    display: inline-block;
    padding: 6px 2px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--tdps-color-text-main);
    text-decoration: none;
    line-height: 1.3;
    transition: color 0.15s ease;
    white-space: nowrap;
}

.tdps-nav__list > li > a:hover,
.tdps-nav__list > li > a:focus-visible {
    color: var(--tdps-color-primary);
    outline: none;
}

/* Активный пункт (WP ставит .current-menu-item) */
.tdps-nav__list > li.current-menu-item > a,
.tdps-nav__list > li.current_page_item > a {
    color: var(--tdps-color-primary);
    font-weight: 600;
}

/* Тонкая подсветка под активным пунктом — визуальная привязка. */
.tdps-nav__list > li.current-menu-item > a::after,
.tdps-nav__list > li.current_page_item > a::after {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    bottom: -2px;
    height: 2px;
    background: var(--tdps-color-primary);
    border-radius: 2px;
}

/* Подменю (второй уровень WP-меню) — выпадает под пунктом. */
.tdps-nav__list .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    margin: 6px 0 0;
    padding: 6px 0;
    list-style: none;
    background: var(--tdps-color-bg-surface);
    border: 1px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.tdps-nav__list > li:hover > .sub-menu,
.tdps-nav__list > li:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tdps-nav__list .sub-menu > li {
    margin: 0;
    padding: 0;
}

.tdps-nav__list .sub-menu > li > a {
    display: block;
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--tdps-color-text-main);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.tdps-nav__list .sub-menu > li > a:hover,
.tdps-nav__list .sub-menu > li > a:focus-visible {
    background: var(--tdps-color-bg-subtle);
    color: var(--tdps-color-primary);
    outline: none;
}

/* ============================================================
   ICONS (profile / cart)
   ============================================================ */
.tdps-cart-icon,
.tdps-mobile-cart-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--tdps-color-text-main);
}
.tdps-cart-icon {
    margin-left: 4px;
}

/* === БЕЙДЖ КОРЗИНЫ === */
.tdps-cart-count {
    position: absolute;
    background: var(--tdps-color-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

/* Десктоп (>1024px) */
@media (min-width: 1025px) {
    .tdps-cart-count {
        top: -8px;
        right: -9px;
        transform: none;
    }
}

/* Планшеты (768–1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .tdps-cart-count {
        top: 3px;
        right: 0px;
        transform: none;
        font-size: 10px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
    }
}

/* Мобильные (<768px) */
@media (max-width: 768px) {
    .tdps-cart-count {
        top: 3px;
        right: 0px;
        transform: none;
        font-size: 8px;
        min-width: 14px;
        height: 14px;
        padding: 0 3px;
    }
}

/* Mobile Actions */
.tdps-mobile-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.tdps-mobile-actions button,
.tdps-mobile-actions a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    background: none;
    border: none;
    color: var(--tdps-color-text-main);
    text-decoration: none;
    position: relative;
}

/* Профиль в мобильной панели — снимаем скругления/паддинги
   от .tdps-profile-icon, оставляем общий тап-таргет 44x44. */
.tdps-mobile-actions .tdps-mobile-profile-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border-radius: 0;
    margin: 0;
    color: var(--tdps-color-text-main);
}

.tdps-mobile-actions .tdps-mobile-profile-trigger:hover {
    color: var(--tdps-color-primary);
}

.tdps-mobile-actions .tdps-mobile-profile-trigger svg {
    display: block;
}

/* Dialogs */
dialog.tdps-overlay {
    border: none;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}
dialog.tdps-overlay[open] {
    display: flex;
    flex-direction: column;
}
dialog.tdps-overlay::backdrop {
    background: transparent;
}
.tdps-overlay__content {
    background: var(--tdps-color-bg-surface);
    padding: 24px;
    margin-top: var(--tdps-header-height);
    animation: slideDown 0.2s ease;
}
.tdps-overlay__content nav {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.tdps-overlay__content nav a {
    font-size: 1.25rem;
    font-weight: 600;
}
.tdps-overlay__content form {
    display: flex;
    gap: 8px;
    width: 100%;
}
.tdps-overlay__content .tdps-search-submit {
    background: var(--tdps-color-primary);
    color: #fff;
    border: none;
    padding: 0 20px;
    border-radius: var(--tdps-radius-md);
    font-weight: 600;
    cursor: pointer;
}
.tdps-close-btn {
    background: none;
    border: 1px solid var(--tdps-color-border);
    padding: 8px 16px;
    border-radius: var(--tdps-radius-md);
    cursor: pointer;
    width: 100%;
}

/* Мобильное меню: ul + li на случай, если WP выведет список. */
.tdps-mobile-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tdps-mobile-menu > li {
    margin: 0;
    padding: 0;
}
.tdps-mobile-menu > li > a {
    display: block;
    padding: 10px 4px;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--tdps-color-text-main);
    text-decoration: none;
    border-radius: var(--tdps-radius-md);
    transition: background 0.15s ease, color 0.15s ease;
}
.tdps-mobile-menu > li > a:hover,
.tdps-mobile-menu > li > a:focus-visible {
    background: var(--tdps-color-bg-subtle);
    color: var(--tdps-color-primary);
    outline: none;
}
.tdps-mobile-menu .sub-menu {
    list-style: none;
    margin: 4px 0 0;
    padding: 0 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.tdps-mobile-menu .sub-menu > li > a {
    display: block;
    padding: 8px 4px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--tdps-color-text-muted);
    text-decoration: none;
}
.tdps-mobile-menu .sub-menu > li > a:hover {
    color: var(--tdps-color-primary);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- FOOTER --- */
.tdps-footer {
    margin-top: auto;
    border-top: 1px solid var(--tdps-color-border);
    background: var(--tdps-color-bg-subtle);
    padding-block: 48px 24px;
    width: 100%;
}
.tdps-footer__grid {
    display: grid;
    gap: 32px;
    grid-template-columns: 1fr;
}
@media (min-width: 768px) {
    .tdps-footer__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
.tdps-footer-block h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--tdps-color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.tdps-footer-block ul li {
    margin-bottom: 8px;
}
.tdps-sbp-icon {
    width: 48px;
    height: auto;
    margin-top: 8px;
}
.tdps-copyright {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--tdps-color-border);
    text-align: center;
    font-size: 0.875rem;
    color: var(--tdps-color-text-muted);
}

/* --- MODAL (Оптовые скидки) --- */
.tdps-modal {
    border: none;
    border-radius: var(--tdps-radius-lg);
    padding: 0;
    max-width: 520px;
    width: 92%;
    background: var(--tdps-color-bg-surface);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
}
.tdps-modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}
.tdps-modal__content {
    padding: 32px 28px;
    position: relative;
}
.tdps-modal__close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--tdps-color-text-muted);
    transition: color 0.2s ease;
    line-height: 1;
}
.tdps-modal__close:hover {
    color: var(--tdps-color-text-main);
}
.tdps-modal h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.25rem;
    font-weight: 700;
}
.tdps-opt-table {
    width: 100%;
    border-collapse: collapse;
}
.tdps-opt-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--tdps-color-border);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--tdps-color-text-muted);
}
.tdps-opt-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--tdps-color-border);
    font-size: 0.9375rem;
}
.tdps-opt-table tr:last-child td {
    border-bottom: none;
}

/* --- PROFILE ICON --- */
.tdps-profile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--tdps-color-text-main);
    transition: color 0.2s ease;
    padding: 4px;
    border-radius: 50%;
}

.tdps-profile-icon:hover {
    color: var(--tdps-color-primary);
}

.tdps-profile-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* Расстояние между профилем и корзиной */
.tdps-nav .tdps-profile-icon {
    margin-right: 4px;
}

/* Адаптив для планшетов */
@media (min-width: 769px) and (max-width: 1024px) {
    .tdps-nav .tdps-profile-icon {
        margin-right: 2px;
    }
    .tdps-profile-icon svg {
        width: 22px;
        height: 22px;
    }
}

/* ============================================================
   ЯКОРНЫЕ ССЫЛКИ В МЕНЮ
   ------------------------------------------------------------
   WP ставит current-menu-item на все ссылки с `#`, если
   пользователь на главной. Для якорей это ложная подсветка —
   глушим её через `[href*="#"]` + убираем зелёный + полосу.
   Реальную подсветку даёт JS: добавляет .tdps-anchor-current
   только для той секции, что сейчас в фокусе.
   ============================================================ */

/* Убираем автоматическую подсветку от WP у ссылок с hash. */
.tdps-nav__list > li.current-menu-item > a[href*="#"],
.tdps-nav__list > li.current_page_item > a[href*="#"] {
    color: var(--tdps-color-text-main);
    font-weight: 500;
}

.tdps-nav__list > li.current-menu-item > a[href*="#"]::after,
.tdps-nav__list > li.current_page_item > a[href*="#"]::after {
    display: none;
}

/* Реальная подсветка активного якоря — от JS. */
.tdps-nav__list > li.tdps-anchor-current > a {
    color: var(--tdps-color-primary);
    font-weight: 600;
}

.tdps-nav__list > li.tdps-anchor-current > a::after {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    bottom: -2px;
    height: 2px;
    background: var(--tdps-color-primary);
    border-radius: 2px;
}

