/**
 * Header Styles - Amazon/MercadoLibre Style
 * FULLY DYNAMIC: All colors from Admin Panel with AUTOMATIC CONTRAST
 * When admin changes colors, text/icons automatically adjust for readability
 * 
 * NOTE: All CSS variables now come from theme-variables.php (Admin Panel)
 * Advanced variables: --header-bg, --navbar-bg, --topbar-bg, --footer-bg
 */

/* =====================
   Top Bar - Full Width
   ===================== */
.header-topbar {
    width: 100%;
    background: var(--header-bg-alt);
    padding: 8px 0;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--header-border);
}

.header-topbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    color: var(--topbar-text);
}

.header-topbar-left,
.header-topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-topbar a,
.header-topbar span {
    color: var(--topbar-text);
    text-decoration: none;
    transition: color 0.2s;
}

.header-topbar a:hover {
    color: var(--header-accent);
}

.header-topbar-location {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-topbar-location i {
    color: var(--topbar-text);
}

/* =====================
   Main Header - Full Width
   ===================== */
.header-main {
    width: 100%;
    background: var(--header-bg);
    padding: 12px 0;
}

.header-main>.container-fluid {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-main .row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 15px;
}

/* =====================
   Logo
   ===================== */
.header-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.header-logo:hover {
    border-color: var(--header-text);
}

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

.header-logo-text {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--header-text);
    letter-spacing: -1px;
}

/* =====================
   Search Bar
   ===================== */
.header-search {
    flex: 1;
    max-width: 700px;
    margin: 0 auto;
}

.header-search-form {
    display: flex;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 3px solid transparent;
    transition: border-color 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-search-form:focus-within {
    border-color: var(--header-accent);
}

.header-search-select {
    border: none;
    background: #ededed;
    padding: 0 15px;
    font-size: 0.9rem;
    color: #333;
    min-width: 110px;
    cursor: pointer;
    border-right: 1px solid #ccc;
}

.header-search-select:focus {
    outline: none;
    background: #ddd;
}

.header-search-input {
    flex: 1;
    border: none;
    padding: 14px 18px;
    font-size: 1rem;
    color: #333;
    min-width: 200px;
}

.header-search-input:focus {
    outline: none;
}

.header-search-input::placeholder {
    color: #888;
}

.header-search-btn {
    background: var(--search-btn-bg);
    border: none;
    color: var(--search-btn-text);
    padding: 14px 22px;
    cursor: pointer;
    transition: background 0.2s;
}

.header-search-btn:hover {
    background: var(--search-btn-hover);
}

.header-search-btn i {
    font-size: 1.25rem;
    color: var(--search-btn-text);
}

/* =====================
   Action Items (Icons) - AUTOMATIC CONTRAST
   ===================== */
.header-actions {
    display: flex;
    align-items: center;
    /* Changed from center to align top */
    gap: 5px;
    flex-shrink: 0;
}

.header-action-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-decoration: none;
    color: var(--header-text);
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.header-action-item:hover {
    border-color: var(--header-text);
    color: var(--header-text);
}

.header-action-top {
    font-size: 0.72rem;
    color: var(--header-text-muted);
    line-height: 1.3;
}

.header-action-bottom {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--header-text);
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-action-bottom i {
    font-size: 0.55rem;
    color: var(--header-icon);
}

.header-action-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: var(--header-icon);
}

/* Badge */
.header-action-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    background: var(--header-accent);
    color: var(--search-btn-text);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Action Label (username) */
.header-action-item-labeled {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.header-action-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--header-text);
    margin-top: 2px;
    white-space: nowrap;
    max-width: 120px;
    /* Increased from 80px */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cart Label */
.header-cart-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 5px;
    color: var(--header-text);
    font-size: 0.8rem;
    line-height: 1.2;
}

.header-cart-label span:first-child {
    font-weight: 700;
}

/* =====================
   WhatsApp Floating Button
   ===================== */
.header-whatsapp {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background: #25D366;
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.5);
    transition: all 0.3s;
    animation: whatsapp-pulse 2s infinite;
}

.header-whatsapp i {
    font-size: 2.2rem;
    color: #fff;
}

@keyframes whatsapp-pulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.5);
    }

    50% {
        box-shadow: 0 4px 30px rgba(37, 211, 102, 0.8);
    }
}

.header-whatsapp:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
    color: #fff;
}

/* =====================
   Navbar - AUTOMATIC CONTRAST
   ===================== */
.header-navbar {
    width: 100%;
    background: var(--header-bg-alt);
    border-top: 1px solid var(--header-border);
}

.header-navbar-container {
    display: flex;
    align-items: center;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-all-categories {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: none;
    border: none;
    color: var(--navbar-text);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.header-all-categories:hover {
    background: var(--topbar-border);
}

.header-all-categories i {
    font-size: 1.1rem;
    color: var(--navbar-icon);
}

.header-nav-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    list-style: none;
    margin: 0;
    padding: 0;
}

.header-nav-item {
    display: block;
    padding: 12px 16px;
    color: var(--navbar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.header-nav-item:hover {
    background: var(--topbar-border);
    color: var(--navbar-text);
}

.header-nav-item i {
    color: var(--navbar-icon);
}

/* =====================
   User Dropdown
   ===================== */
.header-user-dropdown {
    position: relative;
}

.header-user-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
    z-index: 1000;
}

.header-user-dropdown:hover .header-user-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-user-menu-item {
    display: block;
    padding: 12px 18px;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.header-user-menu-item:hover {
    background: #f5f5f5;
    color: var(--primary-color);
}

.header-user-menu-item i {
    width: 20px;
    margin-right: 10px;
    color: #666;
}

.header-user-menu-divider {
    height: 1px;
    background: #eee;
    margin: 5px 0;
}

/* =====================
   Nav Dropdown Menu
   ===================== */
.header-nav-dropdown {
    position: relative;
}

.header-nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
    z-index: 1000;
}

.header-nav-dropdown:hover .header-nav-dropdown-menu,
.header-nav-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-nav-dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.header-nav-dropdown-item:hover {
    background: #f5f5f5;
}

.header-nav-dropdown-item .cat-name {
    flex: 1;
}

.header-nav-dropdown-item .cat-count {
    font-size: 0.75rem;
    color: #999;
    margin-left: 10px;
}

.header-nav-dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 5px 0;
}

.header-nav-dropdown-item-all {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
}

/* =====================
   Mobile Responsive
   ===================== */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--navbar-text, #fff);
    font-size: 1.4rem;
    padding: 10px;
    cursor: pointer;
    margin-left: auto;
}

.mobile-search-bar {
    background: var(--header-bg);
    padding: 10px 15px;
}

.mobile-search-bar .form-control {
    flex: 1;
    border: none;
    padding: 10px 15px;
}

.mobile-search-bar .btn {
    background: var(--header-accent);
    color: var(--search-btn-text);
    padding: 10px 18px;
}

/* Fix wrapper alignment */
.header-user-dropdown {
    display: flex;
    align-items: center;
}

@media (max-width: 991px) {
    .header-topbar {
        display: none;
    }

    .header-main .row {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: space-between;
    }

    .header-search {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin: 10px 0 0;
    }

    .header-nav-menu {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    /* Fixed floating WhatsApp for mobile */
    .header-whatsapp {
        position: fixed !important;
        bottom: 25px !important;
        right: 25px !important;
        z-index: 9999 !important;
        margin-left: 0;
        width: 70px;
        height: 70px;
        background: #25D366;
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.5);
    }

    .header-whatsapp i {
        font-size: 2.2rem;
        color: #fff;
    }

    .header-actions {
        gap: 0;
    }

    .header-action-item {
        padding: 8px 8px;
    }

    .header-action-top,
    .header-action-bottom span:not(.header-cart-text),
    .header-action-label {
        display: none;
    }
}

@media (max-width: 576px) {
    .header-logo img {
        max-height: 36px;
    }

    .header-logo-text {
        font-size: 1.4rem;
    }

    .header-action-item {
        padding: 6px;
    }

    .header-action-icon {
        font-size: 1.2rem;
    }
}