/*
 * Shared header styles for Casa Jardín storefront
 * Ensures a consistent header experience across every page.
 */

.header-tmp {
    background: var(--primary700, #2E6C29);
    padding: 0.75rem 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-tmp .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.header-tmp .header-logo {
    flex: 0 0 auto;
    width: auto;
    min-width: 135px;
}

.header-tmp .header-logo a {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.header-tmp .header-logo a img {
    width: 135px;
    max-width: 100%;
    height: auto;
    display: block;
    filter: brightness(0) invert(1);
    transition: transform 0.3s ease;
}

.header-tmp .header-logo a:hover img {
    transform: scale(1.05);
}

.header-tmp .col.d-none.d-md-block {
    flex: 1 1 auto;
    max-width: none;
    padding: 0 1.5rem;
}

.header-search {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.header-search .search-group {
    position: relative;
}

.header-search .search-group .input-group {
    width: 100%;
    display: flex;
    align-items: stretch;
    background: #fff;
    border-radius: 32px;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.header-search .search-group .input-group:focus-within {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.header-search #search {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    padding: 14px 20px;
    font-size: 15px;
    color: var(--neutral800, #1f1f1f);
    background: transparent;
}

.header-search #search:focus {
    outline: none;
    box-shadow: none;
}

.header-search #search::placeholder {
    color: var(--neutral400, #7a7a7a);
}

.header-search .btn.dropdown-toggle {
    background: var(--sage200, #9FDB9A) !important;
    border: none;
    padding: 14px 20px;
    border-radius: 32px 0 0 32px;
    transition: background 0.3s ease;
}

.header-search .btn.dropdown-toggle:hover {
    background: var(--sage300, #87C887) !important;
}

.header-search #search-button {
    background: var(--neutral200, #D8DEDF) !important;
    border: none;
    padding: 14px 24px;
    border-radius: 0 32px 32px 0;
    transition: background 0.3s ease;
}

.header-search #search-button:hover {
    background: var(--neutral300, #C2CACA) !important;
}

.header-tmp .col-auto.d-flex {
    flex: 0 0 auto;
    min-width: 200px;
    gap: 1rem;
    align-items: center;
}

.header-icons img {
    width: 28px !important;
    height: 28px !important;
    display: block !important;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.header-icons img:hover {
    transform: scale(1.05);
    opacity: 0.85;
}

.header-icons .dropdown-toggle {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.header-icons .dropdown-toggle::after {
    display: none !important;
}

.header-tmp .col-auto.d-flex > .dropdown,
.header-tmp .col-auto.d-flex > a {
    order: initial !important;
}

.header-tmp .d-none.d-md-inline-block {
    color: #fff !important;
    font-weight: 500;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    transition: background 0.3s ease;
}

.header-tmp .d-none.d-md-inline-block:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Dropdown menu styling */
.header-tmp .dropdown-menu {
    border-radius: 8px;
    max-height: 480px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1050;
}

/* Mobile menu toggle dropdown - higher z-index */
.mobile-menu-toggle .dropdown-menu {
    z-index: 1070 !important;
}

/* Search dropdown suggestions - must be above banner but below menus */
.header-search .dropdown-suggestions,
.header-search .suggestions {
    z-index: 1065 !important;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    max-height: 400px;
    overflow-y: auto;
    width: 100%;
}

.header-search .dropdown-suggestions .suggestion-item,
.header-search .suggestions .suggestion-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.header-search .dropdown-suggestions .suggestion-item:hover,
.header-search .suggestions .suggestion-item:hover {
    background-color: #f8f8f8;
}

.header-search .dropdown-suggestions .suggestion-item:last-child,
.header-search .suggestions .suggestion-item:last-child {
    border-bottom: none;
}

.header-search .dropdown-suggestions .no-results,
.header-search .suggestions .no-results {
    padding: 12px 16px;
    text-align: center;
}

/* Category filter dropdown in search - must be above banner */
.header-search .search-group .dropdown-menu {
    z-index: 1070 !important;
}

.header-tmp .dropdown-menu .dropdown-header {
    color: #000;
    font-size: 1.02rem;
}

/* Mobile adjustments */
@media (max-width: 992px) {
    .header-tmp {
        position: sticky;
    }

    .header-tmp .container {
        position: relative;
    }

    .header-tmp .row {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .header-tmp .col.d-none.d-md-block {
        display: none !important;
    }

    /* Ensure search group has proper positioning context */
    .header-search .search-group {
        position: relative;
    }

    /* Fix dropdown suggestions positioning on mobile */
    .header-search .dropdown-suggestions {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1065 !important;
        margin-top: 4px;
    }

    /* Ensure category dropdown is visible on mobile */
    .header-search .search-group .dropdown-menu {
        z-index: 1070 !important;
    }

    .mobile-menu-toggle .dropdown-menu {
        z-index: 1070 !important;
    }
}

@media (max-width: 768px) {
    .header-tmp {
        padding: 0.5rem 0;
    }

    .header-tmp .container {
        padding-left: 0;
        padding-right: 0;
        max-width: 100%;
        overflow: visible;
    }

    .header-tmp .row {
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    /* Mobile header row */
    .header-tmp .mobile-header-row {
        padding: 0.5rem 0.75rem;
    }

    .header-tmp .mobile-header-row > .d-flex {
        gap: 0.5rem;
    }

    /* Mobile menu toggle */
    .header-tmp .mobile-menu-toggle {
        flex-shrink: 0;
    }

    /* Logo - centered with flex-grow */
    .header-tmp .mobile-header-row .header-logo {
        flex-grow: 1;
    }

    .header-tmp .mobile-header-row .header-logo a {
        display: inline-block;
    }

    .header-tmp .mobile-header-row .header-logo a img {
        width: 120px;
        height: auto;
    }

    /* User & Cart - right side */
    .header-tmp .mobile-user-cart {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        flex-shrink: 0;
        gap: 0.75rem !important;
    }

    /* User icon wrapper - always first */
    .header-tmp .mobile-user-cart .user-icon-wrapper {
        order: 1;
        display: flex !important;
        align-items: center;
    }

    /* Cart icon wrapper - always second */
    .header-tmp .mobile-user-cart .cart-icon-wrapper {
        order: 2;
        display: flex !important;
        align-items: center;
        position: relative;
    }

    /* Icon styling */
    .header-tmp .mobile-user-cart .user-icon,
    .header-tmp .mobile-user-cart .cart-icon {
        width: 24px !important;
        height: 24px !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Cart badge positioning */
    .header-tmp .mobile-user-cart .cart-icon-wrapper .badge {
        position: absolute;
        top: -8px;
        right: -8px;
        min-width: 18px;
        height: 18px;
        padding: 2px 5px;
        font-size: 10px;
        line-height: 14px;
    }

    /* Search bar - full width below */
    .header-tmp .mobile-search-row {
        width: 100%;
        padding: 0 0.75rem 0.5rem;
        margin-top: 0;
        position: relative;
    }

    .header-tmp .mobile-search-row .header-search {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }

    /* Ensure mobile search group has positioning context */
    .header-tmp .mobile-search-row .search-group {
        position: relative;
        overflow: visible;
    }

    /* Make sure suggestions appear on mobile */
    .header-tmp .mobile-search-row .dropdown-suggestions {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1065 !important;
        margin-top: 4px;
        display: block;
        overflow: visible;
    }

    /* Hide desktop elements on mobile */
    .header-tmp .header-actions,
    .header-tmp .header-logo.d-none.d-md-block {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .header-tmp .header-logo a img {
        width: 100px;
    }

    .header-tmp .mobile-user-cart {
        gap: 0.5rem !important;
    }

    .header-tmp .mobile-user-cart img {
        width: 20px !important;
        height: 20px !important;
    }
}
