/* =========================================
   3. HEADER STYLES
   ========================================= */
header {
    background: rgba(255, 255, 255, 0.98);
    position: fixed; 
    width: 100%; 
    top: 0; 
    z-index: 1000;
    border-bottom: 1px solid var(--c-sand-dark); 
    padding: 10px 0;
    -webkit-box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    -moz-box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header-inner { 
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex; 
    -webkit-box-pack: justify;
    -moz-box-pack: justify;
    -ms-flex-pack: justify;
    -webkit-justify-content: space-between;
    justify-content: space-between; 
    -webkit-box-align: center;
    -moz-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center; 
    position: relative;
    gap: 20px;
}

/* Logo wrapper to align logo to the left */
.logo-wrapper {
    -webkit-box-ordinal-group: 0;
    -moz-box-ordinal-group: 0;
    -webkit-order: -1;
    -ms-flex-order: -1;
    order: -1;
    flex-shrink: 0;
}

.logo {
    display: block;
}

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

/* More compact logo for all devices */
.logo img,
.custom-logo {
    height: 40px !important; 
    width: auto !important; 
    max-height: 40px !important;
}

/* Even more compact logo for mobile devices */
@media (max-width: 768px) {
    .logo img,
    .custom-logo {
        height: 35px !important; 
        max-height: 35px !important;
    }
}

@media (max-width: 480px) {
    .logo img,
    .custom-logo {
        height: 30px !important; 
        max-height: 30px !important;
    }
}

/* Navigation */
nav {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-links { 
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex; 
    gap: 25px; 
    -webkit-box-flex: 0;
    -moz-box-flex: 0;
    -webkit-flex: 0 0 auto;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    -webkit-box-pack: center;
    -moz-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    list-style: none;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.nav-links li {
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

.nav-links a { 
    font-size: 0.85rem; 
    font-weight: 600; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    color: var(--c-deep-blue);
    text-decoration: none;
    white-space: nowrap;
    padding: 5px 0;
    transition: color 0.3s ease;
    display: block;
}

.nav-links a:hover { 
    color: var(--c-gold); 
}

/* Submenu Styles */
.nav-links .menu-item-has-children {
    position: relative;
}

.nav-links .menu-item-has-children > a {
    padding-right: 20px;
    position: relative;
}

.nav-links .menu-item-has-children > a::after {
    content: "\f107"; /* FontAwesome chevron-down */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.nav-links .menu-item-has-children:hover > a::after,
.nav-links .menu-item-has-children.active > a::after {
    transform: translateY(-50%) rotate(180deg);
}

.nav-links .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--c-white);
    min-width: 200px;
    list-style: none;
    margin: 0;
    padding: 10px 0;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 999;
    border: 1px solid var(--c-sand-dark);
    margin-top: 10px;
}

/* Предотвращаем закрытие подменю при переходе на него */
.nav-links .menu-item-has-children:hover > .sub-menu,
.nav-links .sub-menu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Desktop: hover для подменю */
@media (min-width: 901px) {
    .nav-links .menu-item-has-children:hover > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    /* Улучшенный hover для вложенных подменю */
    .nav-links .sub-menu .menu-item-has-children:hover > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

/* Мобильные: активное состояние для подменю */
@media (max-width: 900px) {
    .nav-links .menu-item-has-children.active > .sub-menu {
        display: block;
        max-height: 1000px;
        padding: 10px 0;
    }
}

/* Desktop: активное состояние тоже работает */
@media (min-width: 901px) {
    .nav-links .menu-item-has-children.active > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

.nav-links .sub-menu li {
    white-space: nowrap;
    width: 100%;
}

.nav-links .sub-menu a {
    display: block;
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--c-text-main);
    text-transform: none;
    letter-spacing: 0;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-links .sub-menu li:last-child a {
    border-bottom: none;
}

.nav-links .sub-menu a:hover {
    background: var(--c-sand-bg);
    color: var(--c-gold);
    padding-left: 25px;
}

/* Nested submenu support */
.nav-links .sub-menu .menu-item-has-children > a::after {
    right: 15px;
    content: "\f105"; /* chevron-right */
}

.nav-links .sub-menu .sub-menu {
    top: 0;
    left: 100%;
    margin-top: 0;
    margin-left: 10px;
}

.header-phone {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -moz-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    flex-shrink: 0;
    margin-right: 10px;
}

.header-phone-link {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -moz-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    gap: 6px;
    color: var(--c-deep-blue);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.header-phone-link:hover {
    color: var(--c-gold);
}

.header-phone-link i {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.header-phone-text {
    font-size: 0.85rem;
}

.header-actions { 
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex; 
    -webkit-box-align: center;
    -moz-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center; 
    gap: 12px;
    flex-shrink: 0;
}

.header-actions .btn-icon { 
    font-size: 1.3rem; 
    color: var(--c-deep-blue);
    text-decoration: none;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-actions .btn-icon:hover { 
    color: var(--c-gold); 
}

.mobile-toggle { 
    display: none; 
    font-size: 1.5rem; 
    color: var(--c-deep-blue); 
    cursor: pointer; 
    padding: 5px 8px;
    transition: color 0.3s ease;
    border: none;
    background: none;
}

.mobile-toggle:hover {
    color: var(--c-gold);
}

.mobile-toggle.active i.fa-bars::before {
    content: "\f00d"; /* fa-times вместо fa-bars */
}

/* Large screens - prevent wrapping */
@media (min-width: 1200px) {
    .nav-links {
        gap: 30px;
    }
}

/* Medium screens - reduce gap to prevent wrapping */
@media (min-width: 901px) and (max-width: 1199px) {
    .nav-links {
        gap: 18px;
    }
    
    .nav-links a {
        font-size: 0.82rem;
        letter-spacing: 0.4px;
    }
}

/* Tablet and Mobile styles */
@media (max-width: 1024px) {
    .nav-links {
        gap: 15px;
    }
    
    .nav-links a {
        font-size: 0.8rem;
        letter-spacing: 0.3px;
    }
}

@media (max-width: 900px) {
    .header-inner {
        gap: 15px;
    }
    
    nav {
        position: static;
    }
    
    .nav-links { 
        display: none; 
        position: absolute; 
        top: 100%; 
        left: 0; 
        right: 0;
        width: 100%; 
        background: var(--c-white); 
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -moz-box-orient: vertical;
        -moz-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column; 
        padding: 20px; 
        -webkit-box-shadow: 0 10px 20px rgba(0,0,0,0.1); 
        -moz-box-shadow: 0 10px 20px rgba(0,0,0,0.1); 
        box-shadow: 0 10px 20px rgba(0,0,0,0.1); 
        border-top: 1px solid var(--c-sand-dark); 
        gap: 0; 
        text-align: left;
        z-index: 999;
        white-space: normal;
    }
    
    .nav-links li {
        width: 100%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .nav-links li:last-child {
        border-bottom: none;
    }
    
    .nav-links a {
        font-size: 0.95rem;
        padding: 12px 15px;
        white-space: normal;
        border-bottom: none;
        display: block;
        width: 100%;
    }
    
    /* Mobile submenu styles */
    .nav-links .menu-item-has-children > a {
        padding-right: 40px;
    }
    
    .nav-links .menu-item-has-children > a::after {
        right: 15px;
        font-size: 0.8rem;
    }
    
    .nav-links .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
        background: var(--c-sand-bg);
        display: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }
    
    .nav-links .menu-item-has-children.active > .sub-menu {
        display: block;
        max-height: 1000px;
        padding: 10px 0;
    }
    
    .nav-links .sub-menu li {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .nav-links .sub-menu a {
        padding: 10px 30px;
        font-size: 0.9rem;
        color: var(--c-text-light);
    }
    
    .nav-links .sub-menu a:hover {
        padding-left: 35px;
        background: transparent;
    }
    
    .nav-links .sub-menu .sub-menu {
        position: static;
        margin: 0;
        background: rgba(0, 0, 0, 0.02);
    }
    
    .nav-links .sub-menu .sub-menu a {
        padding-left: 45px;
    }
    
    .nav-links.active { 
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex; 
    }
    
    .mobile-toggle { 
        display: block; 
    }
    
    /* Компактный номер телефона на мобильных */
    .header-phone {
        display: flex;
        margin-right: 5px;
    }
    
    .header-phone-link {
        padding: 6px 8px;
    }
    
    .header-phone-text {
        display: none; /* Скрываем текст на маленьких экранах, оставляем только иконку */
    }
    
    .header-phone-link i {
        font-size: 1rem;
        margin-right: 0;
    }
    
    .header-actions .btn-icon {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .header-inner {
        gap: 10px;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .header-actions .btn-icon {
        font-size: 1.1rem;
    }
    
    .mobile-toggle {
        font-size: 1.3rem;
        padding: 5px;
    }
}