/* ==========================================================================
   SMART-SAN.RU — MAIN STYLES
   Структурированный и организованный CSS файл
   ========================================================================== */

/* ==========================================================================
   1. RESET & ГЛОБАЛЬНЫЕ СТИЛИ
   ========================================================================== */

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: #f8fafc;
    color: #0f172a;
    line-height: 1.5;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================================================
   2. HEADER TOP (Уровень 1) — Контактная информация
   ========================================================================== */

.header-top {
    background-color: #0f2b3d;
    color: #e2e8f0;
    font-size: 0.85rem;
    padding: 8px 0;
    border-bottom: 1px solid #1e4a6e;
}

.header-top__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.header-top__row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.header-top__legal-row {
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-phone {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.contact-phone:hover {
    color: #38bdf8;
}

.contact-separator {
    color: #5b8cae;
}

.company-badge {
    background-color: #1e4a6e;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.legal-details {
    color: #94a3b8;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
    text-align: center;
}

.no-link {
    text-decoration: none !important;
    color: #94a3b8 !important;
    pointer-events: none;
}

/* ==========================================================================
   3. HEADER MAIN (Уровень 2) — Логотип, поиск, меню, корзина
   ========================================================================== */

.header-main {
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 16px 0;
    top: 0;
    z-index: 100;
}

.header-main__inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
}

/* ----- Логотип ----- */
.logo a {
    display: inline-block;
    line-height: 0;
}

.logo-img {
    max-height: 50px;
    width: auto;
}

/* ----- Поиск ----- */
.search-wrapper {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.search-form {
    display: flex;
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 60px;
    overflow: hidden;
    background: white;
    transition: box-shadow 0.2s;
}

.search-form:focus-within {
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.3);
    border-color: #38bdf8;
}

.search-form input {
    flex: 1;
    border: none;
    padding: 12px 18px;
    font-size: 1rem;
    outline: none;
}

.search-form button {
    background: none;
    border: none;
    padding: 0 20px;
    cursor: pointer;
    color: #1e293b;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.search-form button:hover {
    color: #0284c7;
}

/* ----- Правая колонка (меню + корзина + бургер) ----- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-end;
}

/* Корзина */
.cart-icon a {
    position: relative;
    display: inline-block;
    color: #0f172a;
    font-size: 1.5rem;
    text-decoration: none;
}

.cart-count {
    position: absolute;
    top: -10px;
    right: -12px;
    background-color: #e11d48;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Кнопка бургер-меню (мобильные) */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #0f172a;
}

/* Десктопное меню */
.secondary-nav {
    display: block;
}

.secondary-nav ul {
    display: flex;
    gap: 24px;
    list-style: none;
}

.secondary-nav a {
    text-decoration: none;
    color: #1e293b;
    font-weight: 500;
    transition: color 0.2s;
}

.secondary-nav a:hover {
    color: #0284c7;
}

/* ==========================================================================
   4. HEADER CATEGORIES (Уровень 3) — Металлическая панель категорий
   ========================================================================== */

.header-categories {
    background: url('https://smart-san.ru/source/foto/fon/pro-fon77.webp');
    background-repeat: repeat;
    background-size: 1000px 720px;
    padding: 20px 0;
    border-bottom: 1px solid #d0d0d0;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Псевдоэлементы для металлического эффекта */
.header-categories::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
                rgba(220, 220, 230, 0.7) 0%,
                rgba(180, 180, 190, 0.5) 50%,
                rgba(200, 200, 210, 0.6) 100%);
    pointer-events: none;
    z-index: 1;
}

.header-categories::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 30% 20%, 
                rgba(255, 255, 255, 0.25) 0%,
                rgba(255, 255, 255, 0) 40%,
                rgba(0, 0, 0, 0.1) 80%,
                rgba(0, 0, 0, 0.2) 100%);
    pointer-events: none;
    z-index: 2;
}

/* Панель с кнопками категорий */
.categories-panel {
    max-width: 900px;
    margin: 0 auto;
    background: linear-gradient(145deg, #c0c0c0 0%, #a8a8a8 100%);
    border-radius: 4px 4px 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    padding: 3px 3px 5px 3px;
    position: relative;
    z-index: 3;
    backdrop-filter: blur(0.5px);
}

.categories-list {
    display: flex;
    flex-direction: row;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2px;
}

.categories-list li {
    flex: 1;
    min-width: 0;
}

/* Базовые стили для кнопок/ссылок категорий */
.cat-link {
    display: block;
    padding: 12px 16px;
    background: linear-gradient(145deg, #d4d4d4 0%, #bcbcbc 100%);
    text-decoration: none;
    color: #1e293b;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    letter-spacing: 0.3px;
    white-space: nowrap;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* Блик на кнопках при наведении */
.cat-link::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 200%;
    height: 200%;
    background: linear-gradient(115deg, 
                rgba(255, 255, 255, 0) 0%, 
                rgba(255, 255, 255, 0) 40%,
                rgba(255, 255, 255, 0.3) 50%,
                rgba(255, 255, 255, 0) 60%,
                rgba(255, 255, 255, 0) 100%);
    transform: rotate(25deg);
    transition: left 0.5s ease;
    pointer-events: none;
}

.cat-link:hover::before {
    left: 60%;
}

/* Эффект углубления при наведении */
.cat-link:hover {
    background: linear-gradient(145deg, #c0c0c0 0%, #a8a8a8 100%);
    color: #0f172a;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Вертикальные разделители между кнопками */
.categories-list li:not(:last-child) .cat-link::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 15%;
    width: 1px;
    height: 70%;
    background: linear-gradient(180deg, transparent, #666, transparent);
}

/* Первая кнопка — левое скругление */
.categories-list li:first-child .cat-link {
    border-radius: 4px 0 0 8px;
}

/* Последняя кнопка — правое скругление */
.categories-list li:last-child .cat-link {
    border-radius: 0 4px 8px 0;
}

/* Активная кнопка */
.cat-link.active {
    background: linear-gradient(145deg, #b0b0b0 0%, #989898 100%);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15);
    color: #0f172a;
    font-weight: 700;
}

/* Стили для кнопок с data-category (унитазы, крышки, душевые, запчасти) */
.cat-link[data-category] {
    background: linear-gradient(145deg, #d4d4d4 0%, #bcbcbc 100%);
    border: none;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
}

/* Состояние "открыто" для кнопки */
.cat-link[data-category][aria-expanded="true"] {
    background: linear-gradient(145deg, #b0b0b0 0%, #989898 100%);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15);
    color: #0f172a;
    font-weight: 700;
}

/* Фокус для доступности */
.cat-link[data-category]:focus-visible {
    outline: 2px solid #0284c7;
    outline-offset: 2px;
    position: relative;
    z-index: 10;
}

/* Убираем дефолтные стили кнопки в Firefox */
.cat-link[data-category]::-moz-focus-inner {
    border: 0;
}

/* ==========================================================================
   5. ВЫДВИЖНЫЕ ПАНЕЛИ КАТЕГОРИЙ (DROPDOWN PANELS)
   ========================================================================== */

.dropdown-panels-container {
    position: relative;
    z-index: 50;
}

/* Основная панель */
.dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: url('https://smart-san.ru/source/foto/fon/pro-fon777.webp');
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid #e2e8f0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-panel.open {
    max-height: 450px;
    opacity: 1;
    visibility: visible;
}

/* Внутренний контейнер панели */
.dropdown-panel__inner {
    display: flex;
    gap: 40px;
    padding: 32px 20px;
}

/* Левая колонка — меню */
.dropdown-panel__left {
    flex: 1.2;
}

/* Правая колонка — карусель */
.dropdown-panel__right {
    flex: 0.8;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Меню выпадающей панели */
.dropdown-menu {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dropdown-menu__group {
    border-left: 3px solid #0284c7;
    padding-left: 16px;
}

.dropdown-menu__brand-link {
    display: inline-block;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    margin-bottom: 10px;
    transition: color 0.2s;
}

.dropdown-menu__brand-link:hover {
    color: #0284c7;
    transform: translateX(4px);
}

.dropdown-menu__models {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.9rem;
}

.dropdown-menu__models a {
    color: #475569;
    text-decoration: none;
    transition: all 0.2s;
    padding: 2px 0;
}

.dropdown-menu__models a:hover {
    color: #0284c7;
    transform: translateY(-4px) scale(1.2);
}

/* Карусель внутри панели */
.dropdown-carousel {
    width: 100%;
    max-width: 280px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    background: #f1f5f9;
}

.dropdown-carousel__slides {
    position: relative;
    height: 200px;
}

.dropdown-carousel__slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

.dropdown-carousel__slide.active {
    opacity: 1;
    z-index: 1;
}

.dropdown-carousel__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   6. MAIN CONTENT
   ========================================================================== */

.hero {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #e6f0fa 0%, #ffffff 100%);
    border-radius: 32px;
    margin: 40px 0;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: #0c4a6e;
}

.hero p {
    font-size: 1.2rem;
    color: #334155;
}

/* ==========================================================================
   7. FOOTER
   ========================================================================== */

.main-footer {
    background-color: #0f172a;
    color: #94a3b8;
    text-align: center;
    padding: 32px 0;
    margin-top: 60px;
}

/* ==========================================================================
   8. КЛОНИРОВАННЫЙ ХЕДЕР (ПРИ СКРОЛЛЕ)
   ========================================================================== */

.header-clone {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 16px 0;
    z-index: 200;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.header-clone.visible {
    transform: translateY(0);
    opacity: 1;
}

/* ==========================================================================
   9. SEO-ССЫЛКИ (невидимы для пользователя, видны для ботов)
   ========================================================================== */

.seo-link {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================================================
   10. АДАПТИВНЫЕ СТИЛИ (MEDIA QUERIES)
   ========================================================================== */

/* Планшеты и ниже (до 992px) */
@media (max-width: 992px) {
    .logo-img {
        max-height: 40px;
        width: auto;
    }
    
    .header-main__inner {
        gap: 16px;
    }
    
    .search-wrapper {
        max-width: 400px;
    }
}

/* Десктоп — скрываем кнопку закрытия меню */
@media (min-width: 768px) {
    .menu-close-btn {
        display: none;
    }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
    /* Header Top */
    .header-top__inner {
        flex-direction: column;
        gap: 6px;
    }
    
    /* Header Main */
    .header-main__inner {
        grid-template-columns: auto 1fr auto;
        gap: 12px;
    }
    
    .search-wrapper {
        max-width: 100%;
        margin: 0;
    }
    
    .search-form input {
        padding: 8px 12px;
        font-size: 0.7rem;
    }
    
    .search-form button {
        padding: 0 12px;
    }
    
    .header-actions {
        gap: 12px;
    }
    
    /* Категории */
    .categories-panel {
        max-width: 100%;
        border-radius: 4px 4px 8px 8px;
    }
    
    .cat-link {
        padding: 10px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    /* Мобильное меню — кнопка закрытия */
    .menu-close-btn {
        position: absolute;
        top: 20px;
        left: 20px;
        background: none;
        border: none;
        font-size: 1.8rem;
        cursor: pointer;
        color: #0f172a;
        z-index: 1002;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        transform: scale(0);
        transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }
    
    .secondary-nav.active .menu-close-btn {
        transform: scale(1);
    }
    
    /* Стили для "палочек" внутри кнопки закрытия */
    .menu-close-btn span {
        display: block;
        position: absolute;
        width: 24px;
        height: 3px;
        background-color: #0f172a;
        border-radius: 2px;
        transition: all 0.5s ease-in-out;
    }
    
    .menu-close-btn span:nth-child(1) {
        transform: translateY(8px) rotate(0deg);
        opacity: 0;
    }
    
    .menu-close-btn span:nth-child(2) {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    
    .menu-close-btn span:nth-child(3) {
        transform: translateY(-8px) rotate(0deg);
        opacity: 0;
    }
    
    .secondary-nav.active .menu-close-btn span:nth-child(1) {
        transform: translateY(0) rotate(45deg);
        opacity: 1;
    }
    
    .secondary-nav.active .menu-close-btn span:nth-child(2) {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    
    .secondary-nav.active .menu-close-btn span:nth-child(3) {
        transform: translateY(0) rotate(-45deg);
        opacity: 1;
    }
    
    .menu-close-btn:hover {
        background-color: rgba(0, 0, 0, 0.05);
        border-radius: 50%;
    }
    
    /* Мобильное меню */
    .secondary-nav {
        position: fixed;
        top: 0;
        right: -66%;
        width: 66%;
        height: 100vh;
        background-color: #ffffff;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2);
        padding: 80px 24px 32px;
        transition: right 0.3s ease-in-out;
        z-index: 1001;
        overflow-y: auto;
        display: block;
    }
    
    .secondary-nav.active {
        right: 0;
    }
    
    .secondary-nav ul {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }
    
    .secondary-nav a {
        font-size: 1.2rem;
    }
    
    .mobile-menu-toggle {
        display: block;
        z-index: 100;
        position: relative;
    }
    
    /* Затемнение фона */
    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 150;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }
    
    .menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Hero */
    .hero h1 {
        font-size: 1.8rem;
    }
    
    /* Выпадающие панели — адаптив */
    .dropdown-panel.open {
        max-height: 500px;
    }
    
    .dropdown-panel__inner {
        flex-direction: column;
        gap: 24px;
        padding: 24px 16px;
    }
    
    .dropdown-panel__right {
        display: none;
    }
    
    .dropdown-panel__left {
        flex: auto;
    }
    
    .dropdown-menu__models {
        gap: 6px;
    }
    
    .dropdown-menu__models a {
        font-size: 0.85rem;
    }
    
    /* Клон хедера — адаптив */
    .header-clone .logo-img {
        max-height: 40px;
    }
    
    .header-clone .search-form input {
        padding: 8px 12px;
        font-size: 0.7rem;
    }
    
    .header-clone .search-form button {
        padding: 0 12px;
    }
    
    .header-clone .header-actions {
        gap: 12px;
    }
    
    .header-clone .mobile-menu-toggle {
        display: block;
    }
    
    .header-clone .secondary-nav {
        position: fixed;
        top: 0;
        right: -66%;
        width: 66%;
        height: 100vh;
        background-color: #ffffff;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2);
        padding: 80px 24px 32px;
        transition: right 0.3s ease-in-out;
        z-index: 1001;
        overflow-y: auto;
    }
    
    .header-clone .secondary-nav.active {
        right: 0;
    }
    
    .header-clone .secondary-nav ul {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }
    
    .header-clone .menu-close-btn {
        display: flex;
    }
}

/* Очень узкие экраны (до 600px) */
@media (max-width: 600px) {
    .categories-panel {
        padding: 3px 3px 5px 3px;
    }
    
    .cat-link {
        padding: 8px 8px;
        font-size: 0.7rem;
        white-space: normal;
        word-break: keep-all;
    }
    
    .categories-list {
        gap: 1px;
    }
}

/* Маленькие мобильные устройства (до 480px) */
@media (max-width: 480px) {
    .logo-img {
        max-height: 30px;
        width: auto;
    }
    
    .header-top__row {
        gap: 6px;
    }
    
    .legal-details {
        font-size: 0.65rem;
    }
    
    .company-badge {
        font-size: 0.7rem;
    }
    
    .contact-phone {
        font-size: 0.8rem;
    }
    
    /* Выпадающие панели */
    .dropdown-panel.open {
        max-height: 450px;
    }
    
    .dropdown-menu__brand-link {
        font-size: 1rem;
    }
    
    .dropdown-menu__models {
        gap: 5px;
    }
    
    .dropdown-menu__models a {
        font-size: 0.75rem;
    }
    
    /* Клон хедера */
    .header-clone .logo-img {
        max-height: 30px;
    }
}