/* ============================================================
   HEADER.CSS - HEADER, NAVIGATION, MOBILE MENU
   ============================================================ */

/* 1. TOP BAR (INFO) */
#top-bar {
    background: #f1f1f1;
    border-bottom: 1px solid #ddd;
    font-size: 13px;
}

/* 2. HEADER MAIN (LOGO, SEARCH, CART) */
header {
    background: #fff;
    padding: 15px 0;
    position: relative;
    z-index: 10010;
    /* Ensure header is above homepage slider and other content */
}

/* Desktop Search */
#search-custom-wrap .input-group {
    display: flex;
    width: 100%;
}

#search-custom-wrap .form-control {
    height: 45px !important;
    background: #f8f8f8 !important;
    border: 1px solid #ccc !important;
    font-size: 15px !important;
    box-shadow: none !important;
}

#search-custom-wrap .btn-lg {
    height: 45px !important;
    background: var(--accent-color) !important;
    border: none !important;
    color: #fff !important;
    padding: 0 25px !important;
}

/* Desktop Cart - Supports both #header-cart-box and #header-cart-content */
#header-cart-box #cart>.relative,
#header-cart-content #cart>.relative,
#header-cart-box #cart>.btn,
#header-cart-content #cart>.btn {
    border: 1px solid #ddd;
    background: #fff;
    padding: 10px 15px;
    color: #333;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    z-index: 10000 !important;
}

#cart {
    position: relative;
    z-index: 9999 !important;
}

#cart .dropdown-menu {
    display: block !important;
    visibility: hidden;
    opacity: 0;
    transform: translateY(15px);
    border: 1px solid #ddd !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 0 !important;
    min-width: 400px !important;
    width: 450px !important;
    border-radius: 0 !important;
    background: #fff;
    z-index: 10002;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    top: 100%;
    right: 0;
    left: auto;
    margin-top: 5px;
    pointer-events: none;
}

#cart.open .dropdown-menu {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Ограничиваем высоту списка товаров, чтобы не раздувало во весь экран */
#cart .dropdown-menu li:first-child {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
}

#cart .dropdown-menu table {
    margin-bottom: 0;
    width: 100%;
}

#cart .dropdown-menu table td {
    padding: 8px !important;
    font-size: 11px;
    vertical-align: middle;
    word-break: break-word;
}

#cart .dropdown-menu table td.text-left {
    max-width: 200px;
    min-width: 150px;
}

#cart .dropdown-menu img {
    max-width: 80px !important;
    height: auto;
    border: 1px solid #eee;
    padding: 2px;
}

/* Hover Bridge: Transparent element to close the gap between btn and menu */
#cart .dropdown-menu::before {
    content: "";
    position: absolute;
    top: -25px;
    left: 0;
    width: 100%;
    height: 25px;
}

.min-order-warning {
    margin: 10px 0;
    padding: 12px;
    font-size: 13px;
    border-radius: 6px;
    background-color: #fffaf0;
    border: 1px solid #ffeeba;
    color: #856404;
    text-align: center;
}

.cart-buttons {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.cart-buttons p.text-right {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 0;
    flex-wrap: nowrap;
}

.cart-buttons a {
    white-space: nowrap;
    font-size: 13px;
    color: #00509d !important;
    transition: color 0.2s ease;
}

.cart-buttons a:hover {
    color: #d9534f !important;
    text-decoration: none;
}

/* 3. NAVIGATION (BLUE BAR) */
#menu-line {
    background: var(--accent-color);
    height: 50px;
    position: relative;
    /* Context for dropdown if needed */
    z-index: 1000;
    /* Ensure high stacking to cover slider */
}

.catalog-header-link {
    text-decoration: none !important;
    display: block;
}

.catalog-header {
    background: var(--dark-blue);
    color: #fff;
    padding: 0 20px;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    height: 50px;
    display: flex;
    align-items: center;
    transition: opacity 0.2s ease;
}

.catalog-header-link:hover .catalog-header {
    opacity: 0.9;
}

.main-nav-links {
    height: 50px;
    display: flex;
    align-items: center;
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.main-nav-links .nav-link {
    color: #fff !important;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 20px !important;
}

.main-nav-links .nav-link:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* 4. MOBILE MOBILE STYLES */

/* Mobile Top Bar Override */
@media (max-width: 767px) {
    #top-bar {
        display: block !important;
        background: #fff !important;
        border-bottom: 1px solid #eee;
        padding: 5px 0;
    }

    .mobile-top-row {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        font-size: 11px;
        line-height: 14px;
        flex-wrap: nowrap;
        padding: 0 5px;
    }

    .mobile-top-phone {
        flex: 0 1 auto;
        white-space: nowrap;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-top-phone strong {
        font-size: 12px;
    }

    .mobile-top-messengers {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: 4px;
        margin: 0 6px;
    }

    .mobile-top-auth {
        flex: 0 0 auto;
        white-space: nowrap;
        text-align: right;
    }

    /* Compact mobile header: hide desktop search bar, use overlay instead */
    #search-custom-wrap {
        display: none;
    }

    /* Hide second phone on mobile when toggle is active */
    .mobile-phone-hidden {
        display: none !important;
    }
}

/* Extra-small screens: compact messenger icons further */
@media (max-width: 359px) {
    .mobile-top-messengers .messenger-hub-link.hub-mobile {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    .mobile-top-messengers .messenger-hub-link.hub-mobile img {
        width: 14px;
        height: 14px;
    }
    .mobile-top-auth {
        font-size: 10px;
    }
    .mobile-top-phone strong {
        font-size: 11px;
    }
}

/* Mobile Header Right (Cart) */
@media (max-width: 767px) {
    .mobile-header-right {
        padding-right: 10px;
        /* Space for cart */
    }

    .mobile-min-order {
        display: block;
        font-size: 9px;
        color: #999;
        white-space: nowrap;
        margin-top: -2px;
        line-height: 1;
    }

    .mobile-cart-icon {
        text-decoration: none !important;
    }

    .cart-count-mobile {
        position: absolute;
        top: -5px;
        right: -8px;
        background: #ffcc00;
        color: #000;
        font-size: 10px;
        font-weight: bold;
        border-radius: 50% !important;
        width: 16px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile Menu Button & Search Button */
.btn-mobile-menu {
    background: transparent;
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 700;
    padding: 0 15px;
    text-align: left;
    cursor: pointer;
    height: 50px;
    display: flex;
    align-items: center;
}

.btn-mobile-menu i {
    margin-right: 10px;
}

.btn-mobile-search-blue {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    font-size: 16px;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px !important;
    margin-right: 15px;
}

/* Mobile Menu Dropdown */
.mobile-menu-dropdown {
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: absolute;
    /* Overlay content */
    top: 100%;
    /* If wrapper allows, otherwise it flows */
    left: 0;
    width: 100%;
    z-index: 9999;
    /* Ensure on top of slider */
    margin-top: -1px;
    /* Overlap border */
}

.mobile-menu-inner {
    padding: 0;
}

.mobile-menu-link {
    display: block;
    padding: 14px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #eee;
}

.mobile-menu-link:hover {
    background: #f9f9f9;
    color: #00509d;
}

.category-link-mobile {
    font-weight: 600;
    border-bottom: 1px solid #f0f0f0;
    background: #f9f9f9;
    color: #004080;
}

.mobile-menu-divider {
    height: 10px;
    background: #eee;
    border-top: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
}

/* Mobile Search Overlay */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    /* Above everything */
    display: none;
}

.search-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.mobile-search-container {
    position: relative;
    background: #fff;
    padding: 20px;
    width: 100%;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

.search-top-info {
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* Customizing the search input within the override */
#search-mobile-wrap .form-control {
    border: none !important;
    border-bottom: 2px solid var(--accent-color) !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 16px !important;
    padding-left: 0 !important;
    height: 40px !important;
}

#search-mobile-wrap .input-group-btn {
    position: absolute;
    right: 0;
    top: 0;
}

#search-mobile-wrap .btn-lg {
    background: transparent !important;
    color: #333 !important;
    border: none !important;
    padding: 0 !important;
    height: 40px !important;
    font-size: 18px !important;
}


#search-mobile-wrap .input-group-btn .btn {
    border-radius: 4px !important;
    margin-left: 5px;
}

/* 5. SIDEBAR MENU (eandc.ru style) */
/* Moved to stylesheet.css */
/* ============================================================
   TABLET HEADER RESPONSIVE (768px - 991px)
   ============================================================ */

@media (min-width: 768px) and (max-width: 991px) {
    /* Header row adjustments */
    .header-row {
        flex-wrap: wrap;
    }
    
    /* Logo - smaller on tablet */
    header .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }
    
    /* Search - wider on tablet */
    #search-custom-wrap .form-control {
        height: 40px !important;
        font-size: 14px !important;
    }
    
    #search-custom-wrap .btn-lg {
        height: 40px !important;
        padding: 0 20px !important;
    }
    
    /* Cart - compact on tablet */
    #header-cart-box #cart > .relative,
    #header-cart-content #cart > .relative,
    #header-cart-box #cart > .btn,
    #header-cart-content #cart > .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    /* Navigation bar */
    #menu-line {
        height: 45px;
    }
    
    .catalog-header {
        height: 45px;
        padding: 0 15px;
        font-size: 13px;
    }
    
    .main-nav-links {
        height: 45px;
    }
    
    .main-nav-links .nav-link {
        height: 45px;
        padding: 0 12px !important;
        font-size: 11px;
    }
    
    /* Top bar - compact text */
    #top-bar {
        font-size: 12px;
    }
    
    #top-bar .col-md-5 a {
        margin-right: 10px !important;
    }
}
