/* Общие стили старого каркаса (раньше — встроенный <style> в catalog/base.html, ~30 КБ в каждой странице).
   Вынесено в файл, чтобы браузер скачал его один раз и брал из кэша. Порядок подключения в base.html сохранён. */
.copyright {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.copyright-text {
    margin-left: 160px;
    flex: 1;
}

.payment-card-logo {
    display: flex;
    gap: 10px;
    align-items: center;
}

.floating-phone-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    background-color: var(--brand);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 999;
    cursor: pointer;
    transition: all 0.3s ease;
}

.floating-phone-button:hover {
    background-color: var(--brand-hover);
    transform: scale(1.1);
}

.floating-phone-button i {
    color: white;
    font-size: 20px;
}

/* Стили для модального окна с формой */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    animation: fadeIn 0.3s;
    order-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.callback-product-name{
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: block;
    text-align: center;
}
.callback-product-text{
    margin-bottom: 20px;
    display: block;
    font-size: 16px;
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

/* Стили для выпадающих меню */
.company-dropdown-content,
.contact-dropdown-content {
    display: none;
    position: absolute;
    background-color: #fff;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-radius: 4px;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid var(--line);
}

.company-dropdown-content.active,
.contact-dropdown-content.active {
    display: block;
}

.company-dropdown-content a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--ink);
    transition: background-color 0.3s;
}

.company-dropdown-content a:hover {
    background-color: var(--surface-raised);
}

.contact-dropdown-content .contact-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
}

.contact-dropdown-content .contact-item i {
    margin-right: 10px;
    width: 16px;
    text-align: center;
    color: var(--ink-muted);
}

.contact-dropdown-content .contact-item span a {
    color: var(--ink);
    text-decoration: none;
}

.contact-dropdown-content .contact-item span a:hover {
    text-decoration: underline;
}

.contact-dropdown-content .marketplace-links {
    margin-top: 15px;
    border-top: 1px solid var(--line);
    padding-top: 15px;
}

.contact-dropdown-content .marketplace-links span {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
}

.company-trigger, .contact-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.dropdown-arrow {
    margin-left: 5px;
    transition: transform 0.3s ease;
    font-size: 12px;
}

.company-trigger.active .dropdown-arrow,
.contact-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
}

.contact-dropdown-content {
    width: 300px;
    right: 0;
}

.contact-dropdown-content .contact-info {
    margin-bottom: 15px;
}

.working-hours span {
    display: block;
}

/* Стили для выпадающих меню */
.company-dropdown-content,
.contact-dropdown-content {
    display: none;
    position: absolute;
    background-color: #fff;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-radius: 4px;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid var(--line);
}

.company-dropdown-content.active,
.contact-dropdown-content.active {
    display: block;
}

/* ДОБАВЛЕНО: Исправления для меню категорий */
.categories-nav {
    position: relative; /* Важно для позиционирования выпадающего меню */
}

.categories-dropdown {
    position: absolute;
    top: 100%; /* Позиционируем ниже кнопки */
    left: 0;
    min-width: 250px;
    background-color: #fff;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-radius: 4px;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid var(--line);
    display: none; /* Скрыто по умолчанию */
}

.categories-dropdown.visible {
    display: block; /* Показываем при активации */
}

.categories-container {
    max-height: 400px;
    overflow-y: auto;
}

.categories-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Сетка с автоматическими колонками */
    gap: 10px; /* Расстояние между элементами */
}

.category-item {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--ink);
    transition: background-color 0.3s;
    border-radius: 4px;
    white-space: nowrap; /* Предотвращаем перенос текста */
}

.category-item:hover {
    background-color: var(--surface-raised);
}

/* Убрали лишние отступы */

.categories-table {
    padding-right: 0;
}

/* Остальные стили остаются без изменений */
.contact-dropdown-content {
    width: 300px;
    right: 0;
}

.categories-dropdown {
    max-height: 80vh; /* Ограничиваем высоту */
    overflow-y: auto; /* Включаем скролл */
    width: 100%;
}

/* Для меню машин */
.brands-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 250px;
    background-color: #fff;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-radius: 4px;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid var(--line);
    display: none;
    max-height: 80vh; /* Ограничиваем высоту */
    overflow-y: auto; /* Включаем скролл */
}

/* ===== Mega-menu для "Каталог" (desktop) ===== */
.catalog-nav {
    position: relative;
}

/* Меню JS-ом переносит в <body> и позиционирует абсолютно по вьюпорту. */
.catalog-mega-menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    width: calc(100vw - 20px);
    max-width: 1400px;
    display: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    overflow: hidden;
}

.catalog-mega-menu::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
}

.catalog-mega-menu.is-visible {
    display: flex;
}

.catalog-mega-left {
    flex: 0 0 auto;
    border-right: 1px solid var(--line);
    padding: 0;
    display: flex;
    flex-direction: column;
    min-width: 260px;
}

.catalog-mega-cat {
    border-bottom: 1px solid var(--line);
    padding: 12px 20px 12px 15px;
    transition: opacity 0.15s ease;
}

.catalog-mega-cat:last-child {
    border-bottom: none;
}

.catalog-mega-cat:not(.is-open) {
    opacity: 0.5;
}

.catalog-mega-cat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    line-height: 1.33;
}

.catalog-mega-cat-head .catalog-mega-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    object-fit: contain;
    color: var(--ink);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.catalog-mega-cat-head .catalog-mega-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.catalog-mega-cat.is-open .catalog-mega-icon {
    color: var(--brand-text);
}

.catalog-mega-subcats {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0 0 40px;
}

.catalog-mega-cat.is-open .catalog-mega-subcats {
    display: flex;
}

.catalog-mega-subcats a {
    color: var(--ink);
    font-size: 14px;
    line-height: 1.33;
    text-decoration: none;
}

.catalog-mega-subcats a:hover {
    text-decoration: underline;
}

.catalog-mega-right {
    flex: 1 1 auto;
    padding: 15px 10px 15px 25px;
    display: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 25px 40px;
    align-content: flex-start;
    overflow-y: auto;
    max-height: 479px;
}

.catalog-mega-right.is-active {
    display: grid;
}

.catalog-mega-brand {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.catalog-mega-brand-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    text-decoration: none;
    line-height: 1.33;
}

.catalog-mega-brand-name:hover {
    text-decoration: underline;
}

.catalog-mega-models {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.catalog-mega-models a {
    color: var(--ink);
    opacity: 0.6;
    font-size: 14px;
    line-height: 1.33;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.catalog-mega-models a:hover {
    opacity: 1;
    text-decoration: underline;
}

.catalog-mega-show-all {
    color: var(--brand-text);
    font-size: 14px;
    line-height: 1.33;
    text-decoration: none;
}

.catalog-mega-show-all:hover {
    text-decoration: underline;
}

/* Mobile styles */
@media (max-width: 768px) {
    /* Top contact bar - keep phone number visible */
    .top-contact-bar .container {
        flex-direction: column;
        align-items: stretch;
        padding: 5px 20px 0px;
    }

    /* Hide top links - they'll be in burger menu */
    .top-links {
        display: none;
    }

    /* Style phone number to be prominent */
    .contact-dropdown {
        margin: 0 auto;
        margin-right: 90px;
        order: 2;
        text-align: center;
        padding: 5px 0;
    }

    header {
        padding-top: 0px;
    }

    /* Header layout changes */
    .header-container {
        flex-direction: column;
        padding: 0px 15px;
    }

    /* First line - burger button and logo */
    .mobile-header-top {
        display: flex;
        flex-direction: row; /* Изменено с column на row */
        align-items: center;
        width: 100%;
        gap: 10px; /* Добавлен отступ между элементами */
    }

    /* Burger button styles */
    .burger-menu {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
        padding: 5px;
    }

    .cart-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    .cart-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 24px; /* Фиксированная высота как у других иконок */
        margin-top: -5px;
    }

    .cart-icon svg {
        width: 18px;
        height: 18px;
        vertical-align: middle;
        margin-top: -5px;
    }

    .cart-count {
        position: absolute;
        top: -5px;
        right: -5px;
        background: red;
        color: white;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;  /* Ф21 */
    }

    /* Second line - logo centered */
    .logo {
        margin: 0 auto;
        order: 2;
        padding: 5px 0;
    }

    /* Third line - search bar */
    .search-container {
        order: 3;
        width: 100%;
        margin: 10px 0 0;
    }

    /* Navigation - icons only */
    nav {
        display: flex;
        justify-content: space-between; /* Равномерное распределение */
        align-items: center;
        width: 100%;
        order: 4;
        margin-top: 0px;
        padding: 0 5px;
        overflow: visible;
        flex-wrap: nowrap;
        gap: 3px; /* Отступ между элементами */
    }

    .nav-item, .nav-link {
        flex: 1; /* Равные доли пространства */
        min-width: auto; /* Убираем фиксированную ширину */
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 5px;
        position: relative;
    }

    .nav-text {
        display: none;
    }

    .nav-icon {
        font-size: 20px;
        margin-bottom: 5px;
    }

    /* Mobile menu styles */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        background: var(--surface-inverse);
        z-index: 1100;
        padding: 20px;
        transition: left 0.3s ease;
    }

    .mobile-menu.active {
        left: 0;
    }

    .mobile-menu-close {
        position: absolute;
        top: 15px;
        right: 15px;
        color: white;
        font-size: 24px;
        background: none;
        border: none;
    }

    .mobile-menu-links {
        margin-top: 40px;
    }

    .mobile-menu-link {
        display: block;
        color: white;
        padding: 12px 0;
        border-bottom: 1px solid var(--line-strong);
    }

    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1099;
        display: none;
    }

    .mobile-menu-overlay.active {
        display: block;
    }

    .mobile-header-top {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .logo-search-wrapper {
        display: flex;
        align-items: center;
        width: 100%;
        gap: 10px;
        padding: 5px 0;
    }

    .logo {
        margin: 0;
        order: 1;
        flex-shrink: 0;
    }

    .search-container {
        order: 2;
        flex-grow: 1;
        margin: 0;
    }
}

.mobile-header-top,
.mobile-menu-overlay,
.mobile-menu {
    display: none;
}

@media (max-width: 768px) {
    /* Скрываем десктопные элементы */
    .desktop-logo, .desktop-search {
        display: none !important;
    }

    /* Стили для мобильной строки с лого и поиском */
    .mobile-logo-search {
        display: flex;
        align-items: center;
        /* gap: 10px; width: 100%; */
        margin-bottom: 0px;
    }

    .contact-trigger {
        padding: 0px 15px;
    }

    .mobile-logo {
        flex-shrink: 0;
        align-items: center; /* Центрируем лого по вертикали */
    }

    .mobile-logo img {
        width: 50px;
        height: 75px;
        object-fit: contain;
        vertical-align: middle;
    }

    .mobile-search-container {
        flex-grow: 1;
    }

    /* Адаптация формы поиска для мобильных */
    .mobile-search-container .search-form {
        display: flex;
        width: 100%;
    }

    .mobile-search-container .search-input {
        width: 100%;
        padding: 0px 12px;
        font-size: 14px;
    }

    .mobile-search-container .search-button {
        padding: 8px 12px;
    }

    .categories-nav, .brands-nav {
        position: static; /* Изменяем позиционирование для мобильной версии */
    }

    .catalog-mega-menu {
        display: none !important;
    }

    .categories-dropdown, .brands-dropdown {
        position: absolute; /* Фиксированное позиционирование для мобильных */
        top: 100%;
        left: 100px;
        right: 0;
        bottom: 0;
        width: 40%;
        max-height: 37vh;
        border-radius: 10px 10px;
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.2);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 1100; /* Выше чем оверлей */
        height: 60vh;
    }

    .brands-dropdown {
        left: 20px;
        right: 0;
        bottom: 0;
        width: 90%;
        max-height: 60vh !important;
        border-radius: 10px 10px;
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.2);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 1100; /* Выше чем оверлей */
    }

    .categories-dropdown.visible, .brands-dropdown.visible {
        transform: translateY(0);
    }

    .categories-overlay, .brands-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1099;
        display: none;
    }


    /* Исправление для контейнера категорий */
    .categories-container {
        max-height: calc(60vh - 60px);
        overflow-y: auto;
    }

    /* Кнопка закрытия для мобильных меню */
    .dropdown-close-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        background: none;
        border: none;
        font-size: 20px;
        color: var(--ink-muted);
    }
}

@media (max-width: 768px) {
    .copyright {
        flex-direction: column; /* меняем направление на колонку */
        gap: 15px; /* расстояние между блоками */
        text-align: center; /* выравнивание по центру */
    }

    .copyright-text {
        margin-left: 0; /* убираем отступ слева */
        order: 1; /* текст будет первым */
    }

    .payment-card-logo {
        order: 2; /* логотипы будут вторыми */
        justify-content: center; /* центрируем логотипы */
    }
}

/* Десктоп версия */
@media (min-width: 769px) {
    .mobile-logo-search {
        display: none !important;
    }


}

/* ===== Мобильное мегаменю каталога (изолировано от десктопного) ===== */
.cat-m-menu { display: none; }

@media (max-width: 768px) {
    .cat-m-menu {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        z-index: 2000;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
    .cat-m-menu.is-open {
        opacity: 1;
        visibility: visible;
    }
    .cat-m-menu * { box-sizing: border-box; }

    .cat-m-header {
        position: sticky;
        top: 0;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding: 6px 12px;
        background: #fff;
        border-bottom: 1px solid var(--line);
        min-height: 44px;
        z-index: 2;
    }
    .cat-m-close {
        background: none;
        border: none;
        font-size: 32px;
        line-height: 1;
        color: var(--ink);
        padding: 0 8px;
        cursor: pointer;
    }

    .cat-m-list { display: block; }
    .cat-m-menu.is-drilled .cat-m-list { display: none; }

    .cat-m-cat {
        display: flex;
        align-items: stretch;
        border-bottom: 1px solid var(--line);
    }
    .cat-m-head {
        flex: 1 1 auto;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        color: var(--ink);
        text-decoration: none;
        font-weight: 600;
        font-size: 16px;
        line-height: 1.3;
        min-width: 0;
    }
    .cat-m-icon {
        width: 28px;
        height: 28px;
        flex: 0 0 28px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: var(--ink);
        font-size: 22px;
    }
    .cat-m-icon svg { width: 100%; height: 100%; display: block; }
    img.cat-m-icon { object-fit: contain; }
    .cat-m-detail.is-active .cat-m-detail-title .cat-m-icon { color: var(--brand-text); }
    .cat-m-name { flex: 1 1 auto; min-width: 0; }

    .cat-m-toggle {
        flex: 0 0 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--ink);
        padding: 0;
        cursor: pointer;
    }

    .cat-m-detail { display: none; padding: 0 16px 24px; }
    .cat-m-detail.is-active { display: block; }

    .cat-m-detail-head {
        padding: 16px 0 8px;
        border-bottom: 1px solid var(--line);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }
    .cat-m-detail-title {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        color: var(--ink);
        text-decoration: none;
        font-weight: 700;
        font-size: 16px;
        line-height: 1.3;
    }
    .cat-m-back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: none;
        border: none;
        color: var(--ink-muted);
        font-size: 14px;
        padding: 4px 8px;
        cursor: pointer;
    }

    .cat-m-subcats {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 16px 0;
        border-bottom: 1px solid var(--line);
    }
    .cat-m-sub-row {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .cat-m-sub-link {
        flex: 1 1 auto;
        color: var(--ink);
        text-decoration: none;
        font-size: 15px;
        line-height: 1.33;
        min-width: 0;
    }
    .cat-m-sub-toggle {
        flex: 0 0 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--ink);
        padding: 4px;
        cursor: pointer;
    }
    .cat-m-sub-row.is-active .cat-m-sub-link { color: var(--brand-text); }
    .cat-m-sub-row.is-active .cat-m-sub-toggle { color: var(--brand-text); }

    .cat-m-brands {
        display: none;
        grid-template-columns: 1fr 1fr;
        gap: 20px 16px;
        padding: 16px 0 0;
    }
    .cat-m-brands.is-active { display: grid; }
    .cat-m-brand {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 0;
    }
    .cat-m-brand-name {
        font-weight: 700;
        color: var(--ink);
        text-decoration: none;
        font-size: 15px;
    }
    .cat-m-models { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
    .cat-m-models a {
        color: var(--ink);
        opacity: 0.6;
        font-size: 13px;
        text-decoration: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .cat-m-show-all {
        color: var(--brand-text);
        font-size: 13px;
        text-decoration: underline;
        margin-top: 4px;
    }
}
