/* Файл: static/css/header.css */

/* --- 1. ОСНОВНАЯ ОБЕРТКА --- */
.modern-header {
    background-color: var(--bg-main);
    border-bottom: 1px solid #e5e7eb;
    padding: 0;
    position: sticky; /* sticky по умолчанию (десктоп) */
    top: 0;
    z-index: 1000;
    font-family: "Inter", Arial, sans-serif;
    width: 100%;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, border-bottom-color 0.3s ease;
}

.modern-header__container {
    max-width: 1900px;
    margin: 0 auto;
    padding: 0 30px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    transition: height 0.3s ease, padding 0.3s ease;
    position: relative;
}

/* --- 2. ЛОГОТИП --- */
.header-logo {
    display: flex;
    align-items: center;
    margin-right: 40px;
    z-index: 1002;
    text-decoration: none;
    transition: opacity 0.3s ease, transform 0.3s ease, width 0.3s ease, margin-right 0.3s ease;
}

.header-logo svg,
.header-logo img {
    height: 40px;      /* базовая высота */
    width: auto;
    display: block;
    max-width: 180px;
    object-fit: contain;
    transition: height 0.3s ease;
}

/* --- 3. МЕНЮ (ДЕСКТОП) --- */
.header-nav {
    flex: 1;
    height: 100%;
}

.header-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 30px;
    height: 100%;
}

.header-menu__item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

/* ССЫЛКИ И ЛИНИЯ */
.header-menu__link {
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-body);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 5px;
}

.header-menu__link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 25px;
    width: 0%;
    height: 3px;
    background-color: #f0a733;
    transition: width 0.3s ease;
}

.header-menu__link:hover::after {
    width: 100%;
}

.header-menu__link:hover {
    color: var(--text-body);
}

/* Стрелочка */
.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 4px;
    cursor: pointer;
}

.dropdown-arrow {
    transition: transform 0.2s ease;
    pointer-events: none;
}

.header-dropdown-wrapper:hover .dropdown-arrow,
.header-dropdown-wrapper.active .dropdown-arrow {
    transform: rotate(180deg);
    color: #f0a733;
}

/* --- ВЫПАДАЮЩЕЕ МЕНЮ (ДЕСКТОП) --- */
.header-dropdown-list {
    position: absolute;
    top: calc(100% + 4px); /* было: top: 80px; */
    left: -20px;
    background-color: var(--bg-main);
    min-width: 240px;
    list-style: none;
    padding: 10px 0;
    margin: 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid #e5e7eb;
    border-top: 3px solid #f0a733;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 999;
}

.header-dropdown-wrapper:hover .header-dropdown-list {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item-link {
    display: block;
    padding: 12px 20px 12px 25px;
    font-size: 14px;
    color: var(--text-body);
    text-decoration: none;
    font-weight: 500;
    position: relative;
    transition: background-color 0.2s;
    overflow: hidden;
}

.dropdown-item-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #f0a733;
    transform: scaleY(0);
    transform-origin: center;
    transition: transform 0.2s ease;
}

.dropdown-item-link:hover {
    background-color: var(--bg-secondary);
}

.dropdown-item-link:hover::before {
    transform: scaleY(1);
}

/* --- 4. ИНСТРУМЕНТЫ --- */
.header-tools {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: 20px;
    position: static;
    flex-shrink: 0; /* не даём сжать блок с иконками */
}

/* ПОИСК */
.search-wrapper {
    position: static;
    display: flex;
    align-items: center;
}

.search-input {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    background: var(--bg-main);
    border: none;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    color: var(--text-body);
    font-size: 18px;
    padding: 20px 30px;
    outline: none;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 11000;
}

.search-wrapper.active .search-input {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-body);
    transition: color 0.2s;
    z-index: 2;
}

.search-toggle:hover {
    color: #f0a733;
}

.search-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ЯЗЫК */
.lang-switch {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.lang-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    display: block;
}

.lang-btn img {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    object-fit: cover;
}

.lang-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.lang-btn.active {
    opacity: 1;
    transform: scale(1.1);
    border-radius: 50%;
    box-shadow: 0 0 0 2px #f0a733;
}

/* БУРГЕР */
.burger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 30px;
    height: 30px;
    padding: 0;
    z-index: 10004;
    flex-shrink: 0; /* фиксируем размер бургера */
}

.burger-line {
    width: 100%;
    height: 2px;
    background-color: #000;
    transition: 0.3s;
}

.burger-btn.active .burger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.burger-btn.active .burger-line:nth-child(2) {
    opacity: 0;
}

.burger-btn.active .burger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* --- 4.1. КОМПАКТНЫЙ ХЕДЕР ПРИ ПРОКРУТКЕ (ДЕСКТОП) --- */
.modern-header.header--compact {
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    border-bottom-color: #e5e7eb;
}

.modern-header.header--compact .modern-header__container {
    height: 35px;       /* вместо 80px */
    padding: 0 20px;
}

/* Логотип прячем, чтобы хедер был плоским */
.modern-header.header--compact .header-logo {
    opacity: 1;
    transform: translateX(-10px);
    width: 0;
    margin-right: 16;
    pointer-events: auto;
}

.modern-header.header--compact .header-logo img {
   height: 22px;         /* было 40px в обычном состоянии */
    max-width: 120px;     /* чтобы не растягивался */
}

/* Чуть компактнее отступы в меню и тулбаре */
.modern-header.header--compact .header-tools {
    gap: 10px;
}

.modern-header.header--compact .header-menu {
    gap: 16px;
}

/* ============================================================
   5. МОБИЛЬНАЯ ВЕРСИЯ
   ============================================================ */
@media (max-width: 1024px) {
    .modern-header__container {
        padding: 0 15px;
    }

    .header-logo {
        margin-right: auto;
    }

    .burger-btn {
        display: flex;
        margin-left: 15px;
    }

    .header-nav {
        display: none;
        position: absolute;
        top: 80px;
        left: 0;
        width: 100%;
        background-color: var(--bg-main);
        padding: 0;
        box-shadow: 0 10px 20px rgba(0,0,0,0.15);
        border-top: 1px solid #e5e7eb;
        height: auto;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        z-index: 10001;
    }

    .header-nav.open {
        display: block !important;
    }

    .header-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        height: auto;
    }

    .header-menu__item {
        width: 100%;
        height: auto;
        display: block;
    }

    .header-menu__link {
        width: 100%;
        padding: 15px 20px;
        border-bottom: 1px solid #f3f4f6;
        height: auto;
        justify-content: space-between;
    }

    .header-menu__link::after {
        display: none;
    }

    .header-dropdown-list {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-top: none;
        padding: 0;
        background-color: var(--bg-secondary);
        display: none;
    }

    .header-dropdown-wrapper.active .header-dropdown-list {
        display: block;
    }

    .dropdown-trigger {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-left: 1px solid #eee;
        margin-left: 0;
    }

    .dropdown-item-link {
        padding: 12px 20px 12px 40px;
        color: #666;
        border-bottom: 1px solid #eee;
    }

    .dropdown-item-link::before {
        display: none;
    }

    .search-input {
        font-size: 16px;
        padding: 15px 20px;
    }
}

/* Дополнительная адаптация для очень узких экранов */
@media (max-width: 640px) {
    .modern-header__container {
        padding: 0 10px;
    }

    .header-logo svg,
    .header-logo img {
        height: 32px;           /* -20% от 40px */
        max-width: 144px;       /* -20% от 180px */
    }

    .lang-btn img {
        width: 20px;            /* ~-17% от 24px */
        height: 20px;
    }

    .header-tools {
        gap: 10px;
    }

    .burger-btn {
        width: 24px;            /* -20% от 30px */
        height: 24px;
    }
}

/* МОБИЛЬНЫЕ: хедер не sticky, просто уезжает вверх при скролле */
@media (max-width: 768px) {
    .modern-header {
        position: static;
        box-shadow: none;
    }
}

.wrapper main {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.page-main {
    padding-top: 0 !important;
    margin-top: 0 !important;
}
