/* Header Fixes for Trapper Outdoors - Clean and Consolidated */

/* Reset and base styles */
* {
    box-sizing: border-box;
}

/* Body padding management - single source of truth */
body {
    padding-top: 120px;
    margin: 0;
    transition: padding-top 0.3s ease;
}

/* When notification banner is present */
body.with-notification {
    padding-top: 170px;
}

/* Notification Banner - Fixed positioning at top */
.notification-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    min-height: 50px;
    max-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    transform-origin: top;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Prevent banner from interfering with header content */
    pointer-events: auto;
}

/* Site Header - Fixed positioning below notification */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

/* When notification is present, move header down */
body.with-notification .site-header {
    top: 50px;
}

/* Ensure header doesn't get covered by notification on any screen size */
@media (max-width: 1200px) {
    body.with-notification .site-header {
        top: 50px;
    }
}

/* Header scroll effects */
.site-header.scrolled {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
}

.site-header.hide-header {
    transform: translateY(-100%);
}

/* Prevent header hiding when notification is present */
body.with-notification .site-header.hide-header {
    transform: translateY(0);
}

/* Mega menu positioning */
.mega-menu {
    z-index: 999;
    position: fixed;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
}

/* When notification is present, adjust mega menu position */
body.with-notification .mega-menu {
    top: calc(100% + 50px);
}

/* Ensure content doesn't get hidden */
main, 
.container, 
.hero-section, 
.content-wrapper,
.features-section,
.categories-section,
.brands-section,
.products-section,
.newsletter-section {
    position: relative;
    z-index: 1;
}

/* Hero section specific adjustments */
.hero-section {
    margin-top: 0;
    min-height: 90vh;
}

/* Mobile responsive adjustments */
@media (max-width: 991px) {
    body {
        padding-top: 140px;
    }
    
    body.with-notification {
        padding-top: 185px;
    }
    
    /* Ensure proper header positioning on mobile */
    .site-header {
        top: 0;
    }
    
    body.with-notification .site-header {
        top: 45px;
    }
    
    .notification-banner {
        min-height: 45px;
        max-height: 45px;
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 130px;
    }
    
    body.with-notification {
        padding-top: 175px;
    }
    
    /* Ensure proper header positioning on tablets */
    .site-header {
        top: 0;
    }
    
    body.with-notification .site-header {
        top: 45px;
    }
    
    .hero-section {
        min-height: 70vh;
        background-attachment: scroll;
    }
}

@media (max-width: 480px) {
    body {
        padding-top: 120px;
    }
    
    body.with-notification {
        padding-top: 165px;
    }
    
    /* Ensure proper header positioning on small mobile */
    .site-header {
        top: 0;
    }
    
    body.with-notification .site-header {
        top: 45px;
    }
    
    .notification-banner {
        padding: 0.5rem;
        font-size: 0.9rem;
        min-height: 45px;
        max-height: 45px;
    }
    
    .hero-section {
        min-height: 60vh;
    }
}

/* Notification banner specific styles */
.notification-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.notification-content {
    flex: 1;
    max-width: 800px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.notification-message {
    margin-left: 0.5rem;
    opacity: 0.9;
}

.notification-cta {
    margin-left: 1rem;
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.notification-cta:hover {
    opacity: 1;
    color: inherit;
}

.notification-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.notification-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

/* Toast notifications - ensure they appear above all other elements */
.toast-container {
    z-index: 10000 !important;
}

/* Individual toast elements */
.toast {
    z-index: 10001 !important;
}

/* Ensure toast containers are positioned correctly relative to notification banner */
#toastContainer,
.toast-container {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 10000 !important;
    pointer-events: none;
}

/* Make individual toasts clickable */
.toast {
    pointer-events: auto;
}

/* When notification banner is present, adjust toast position */
body.with-notification .toast-container,
body.with-notification #toastContainer {
    top: 70px !important;
}

@media (max-width: 991px) {
    body.with-notification .toast-container,
    body.with-notification #toastContainer {
        top: 65px !important;
    }
}

@media (max-width: 768px) {
    body.with-notification .toast-container,
    body.with-notification #toastContainer {
        top: 65px !important;
    }
}

@media (max-width: 480px) {
    body.with-notification .toast-container,
    body.with-notification #toastContainer {
        top: 65px !important;
    }
}

/* Mobile notification adjustments */
@media (max-width: 768px) {
    .notification-content {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .notification-message {
        margin-left: 0;
    }
    
    .notification-cta {
        margin-left: 0;
    }
    
    /* Critical mobile positioning fix */
    body.with-notification .site-header {
        top: 45px !important;
    }
    
    .notification-banner {
        max-height: 45px !important;
    }
}

@media (max-width: 480px) {
    .notification-icon {
        font-size: 1rem;
    }
    
    .notification-close {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
    
    /* Critical small mobile positioning fix */
    body.with-notification .site-header {
        top: 45px !important;
    }
    
    .notification-banner {
        max-height: 45px !important;
    }
}

/* Smooth transitions for all elements */
.site-header,
.notification-banner,
.mega-menu {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fix for any layout shifts */
.hero-section,
.features-section,
.categories-section,
.brands-section,
.products-section {
    width: 100%;
    overflow-x: hidden;
}

/* Ensure proper stacking context */
.site-header {
    isolation: isolate;
}

.notification-banner {
    isolation: isolate;
}

/* Fix brand section layout if needed */
.brands-section .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.brands-section .row {
    margin: 0 -15px;
}

.brands-section [class*="col-"] {
    padding: 0 15px;
}

/* Ensure brand cards are properly sized */
.brand-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.brand-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.brand-description {
    flex-grow: 1;
}

/* Enhanced Mobile Menu and Touch Improvements */
@media (max-width: 991px) {
    .menu-item.has-dropdown > a {
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .menu-item.has-dropdown > a::after {
        content: '\25BC';
        font-size: 10px;
        transition: transform 0.3s ease;
        color: #3498db;
        margin-left: auto;
        flex-shrink: 0;
    }
    
    .menu-item.has-dropdown.expanded > a::after {
        transform: rotate(180deg);
    }
    
    .mobile-subcategories {
        background: rgba(52, 152, 219, 0.03);
        border-left: 3px solid #3498db;
        margin: 8px 0;
        border-radius: 0 8px 8px 0;
        max-height: 0;
        overflow: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        opacity: 0;
    }
    
    .menu-item.has-dropdown.expanded .mobile-subcategories {
        max-height: 600px;
        padding: 12px 0;
        opacity: 1;
    }
    
    .mobile-subcategories a {
        padding: 12px 1.5rem;
        font-size: 0.95rem;
        border-left: 3px solid transparent;
        transition: all 0.3s ease;
        margin: 4px 0;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.8);
        display: block;
        text-decoration: none;
        color: #2c3e50;
        min-height: 44px;
        display: flex;
        align-items: center;
        position: relative;
        overflow: hidden;
    }
    
    .mobile-subcategories a::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 0;
        background: linear-gradient(135deg, #3498db, #2980b9);
        transition: width 0.3s ease;
    }
    
    .mobile-subcategories a:hover,
    .mobile-subcategories a:active {
        border-left-color: #3498db;
        background: rgba(52, 152, 219, 0.12);
        transform: translateX(8px);
        color: #3498db;
    }
    
    .mobile-subcategories a:hover::before,
    .mobile-subcategories a:active::before {
        width: 4px;
    }
    
    /* Improve mobile menu scrolling */
    .nav-menu {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Prevent body scroll when mobile menu is open */
    body.mobile-menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    /* Mobile search improvements */
    .search-container {
        width: 100%;
        margin: 0.75rem 0 0 0;
    }
    
    .search-input-group {
        box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    }
    
    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Touch target improvements */
.mobile-top-icon,
.mobile-menu-toggle,
.mobile-user-action-link,
.nav-menu a {
    min-height: 44px;
    -webkit-tap-highlight-color: rgba(52, 152, 219, 0.2);
    tap-highlight-color: rgba(52, 152, 219, 0.2);
}

/* Performance optimizations */
.site-header,
.mega-menu,
.mobile-menu-backdrop {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .site-header,
    .mega-menu,
    .mobile-menu-backdrop,
    .nav-menu,
    .mobile-subcategories,
    body {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

/* Focus management */
.user-action-link:focus,
.mobile-top-icon:focus,
.mobile-menu-toggle:focus,
.nav-menu a:focus,
.mobile-user-action-link:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Desktop mega menu improvements */
@media (min-width: 992px) {
    .mega-menu {
        /* Add hover zone above menu */
        margin-top: -10px;
        padding-top: 10px;
    }
    
    .mega-menu-content {
        background: rgba(255, 255, 255, 0.98);
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.12);
        max-width: 800px;
    }
    
    /* Ensure smooth transitions */
    .menu-item.has-dropdown {
        transition: all 0.3s ease;
    }
    
    .menu-item.has-dropdown:hover {
        background: rgba(52, 152, 219, 0.05);
    }
    
    /* Add visual indicator for dropdown items */
    .menu-item.has-dropdown > a::after {
        content: '\25BC';
        font-size: 10px;
        margin-left: 8px;
        opacity: 0.6;
        transition: all 0.3s ease;
    }
    
    .menu-item.has-dropdown:hover > a::after {
        opacity: 1;
        transform: rotate(180deg);
    }
    
    /* Clean mega menu styling */
    .mega-menu-column {
        border: 1px solid rgba(0,0,0,0.08);
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
    
    .mega-menu-column h3 {
        font-size: 14px;
        font-weight: 700;
        margin-bottom: 16px;
        padding-bottom: 8px;
        border-bottom: 2px solid currentColor;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    
    .mega-menu-column ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    
    .mega-menu-column li {
        margin-bottom: 8px;
    }
    
    .mega-menu-column a {
        color: #555;
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        padding: 6px 0;
        display: block;
        transition: all 0.3s ease;
        border-radius: 4px;
    }
    
    .mega-menu-column a:hover {
        color: #3498db;
        padding-left: 8px;
        background: rgba(52, 152, 219, 0.08);
    }
    
    /* Promo section styling */
    .mega-menu-promo {
        flex: 0 0 250px;
        margin-left: 1rem;
    }
    
    .promo-image {
        border-radius: 8px;
        overflow: hidden;
        height: 200px;
        position: relative;
    }
    
    .promo-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .promo-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(135deg, rgba(52, 152, 219, 0.9), rgba(41, 128, 185, 0.9));
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        color: white;
        text-align: center;
    }
    
    .promo-overlay h3 {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 12px;
    }
    
    .promo-button {
        background: white;
        color: #3498db;
        padding: 8px 16px;
        border-radius: 20px;
        text-decoration: none;
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        transition: all 0.3s ease;
    }
    
    .promo-button:hover {
        background: #f8f9fa;
        transform: translateY(-2px);
        color: #2980b9;
    }
}

/* Safe area handling for modern devices */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: calc(130px + env(safe-area-inset-top));
    }
    
    body.with-notification {
        padding-top: calc(180px + env(safe-area-inset-top));
    }
    
    .site-header {
        top: env(safe-area-inset-top);
    }
    
    .notification-banner {
        top: env(safe-area-inset-top);
        padding-left: calc(1rem + env(safe-area-inset-left));
        padding-right: calc(1rem + env(safe-area-inset-right));
    }
    
    .nav-menu {
        padding-left: calc(2rem + env(safe-area-inset-left));
        padding-right: calc(2rem + env(safe-area-inset-right));
    }
}