/* 
 * HEADER STYLES - Scoped to header element only
 * All styles in this file are specifically for the site header.
 * These styles will not affect other page elements.
 * DO NOT modify header styles in other CSS files.
 */

/* Main Header Element - Scoped */
header {
    background-color: #fff !important;
    color: #000 !important;
    padding: 0.75rem 15px !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    border-bottom: 1px solid rgba(0,0,0,0.1) !important;
    min-height: 70px !important;
    max-height: 100px !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    position: relative;
    width: 100%;
    z-index: 1000;
}

/* Navigation within header - Scoped */
header nav {
    width: 100%;
}

header nav .container {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 15px !important;
    padding-left: 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-height: 70px !important;
    max-height: 100px !important;
    height: 100% !important;
    position: relative !important;
}

/* Logo - Scoped to header */
header .logo a {
    position: relative;
    display: flex;
    align-items: center;
    text-decoration: none !important;
    padding-left: 20px;
}

header .logo a img {
    height: auto;
    max-height: 60px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

header .logo a .logo-img {
    transition: opacity 0.5s ease-in-out;
    will-change: opacity;
}

/* First logo - visible by default */
header .logo a .logo-1 {
    opacity: 1;
    position: relative;
    z-index: 1;
}

/* Second logo - hidden by default */
header .logo a .logo-2 {
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 2;
}

/* Hidden state for logo 1 */
header .logo a .logo-1.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Visible state for logo 2 */
header .logo a .logo-2.visible {
    opacity: 1;
    pointer-events: auto;
}

header .logo a:hover .logo-img:not(.hidden) {
    opacity: 0.8;
}

/* Mobile Toggle Button - Scoped to header */
header .mobile-toggle {
    display: none;
    flex-direction: column;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    gap: 5px;
    z-index: 1001;
    justify-content: center;
    align-items: center;
}

header .mobile-toggle span {
    width: 25px;
    height: 3px;
    background-color: #000;
    border-radius: 3px;
    transition: all 0.3s ease;
    display: block;
}

header .mobile-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
    position: relative;
}

header .mobile-toggle.active span:nth-child(2) {
    opacity: 0;
    width: 0;
}

header .mobile-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
    position: relative;
}

/* Nav Wrapper - Scoped to header */
header .nav-wrapper {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

header .nav-menu {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

header .nav-menu li {
    margin: 0;
    position: relative;
}

header .nav-menu a {
    color: #000;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

header .nav-menu a:hover {
    background-color: #dc3545 !important;
    color: #fff !important;
}

/* Better hover area for dropdown toggles - Scoped */
header .dropdown-toggle:hover {
    background-color: #dc3545 !important;
    color: #fff !important;
}

header .nav-menu a i {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

/* Dropdown Styles - Scoped to header */
header .dropdown {
    position: relative;
}

header .dropdown-toggle {
    cursor: pointer;
    position: relative;
}

header .dropdown:hover .dropdown-toggle i,
header .dropdown.active .dropdown-toggle i {
    transform: rotate(180deg);
}

header .dropdown-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background-color: #fff;
    min-width: 200px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-5px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Add invisible bridge to prevent dropdown from closing - Scoped */
header .dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 5px;
    background: transparent;
    z-index: 999;
    pointer-events: none;
}

header .dropdown:hover::before {
    pointer-events: auto;
}

header .dropdown:hover .dropdown-menu,
header .dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

header .dropdown:hover .dropdown-toggle i,
header .dropdown.active .dropdown-toggle i {
    transform: rotate(180deg);
}

/* Keep dropdown open when hovering over it - Scoped */
header .dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

header .dropdown-menu li {
    margin: 0;
    width: 100%;
}

header .dropdown-menu a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 0;
    font-size: 0.95rem;
    font-weight: 500;
}

header .dropdown-menu a:hover {
    background-color: #dc3545 !important;
    color: #fff !important;
    padding-left: 1.5rem;
}

/* Mobile Auth Items - Hide on Desktop */
header .mobile-auth-item {
    display: none;
}

/* Auth Buttons - Scoped to header */
header .auth-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-left: auto;
}

/* User Menu Styles */
.user-menu-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.user-icon {
    font-size: 1.8rem;
    color: #333;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.user-icon:hover {
    background-color: #f0f0f0;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px); /* Position below the icon */
    right: 0;
    background-color: #fff;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

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

.user-dropdown-menu a {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.user-dropdown-menu a:hover {
    background-color: #f5f5f5;
    color: #dc3545;
}

/* Cart Icon - Scoped to header, positioned at extreme right */
header .cart-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #333;
    text-decoration: none;
    border-radius: 50%;
    transition: all 0.3s ease;
    background-color: transparent;
    order: 999;
    flex-shrink: 0;
}

header .cart-icon:hover {
    background-color: #f8f9fa;
    color: #dc3545;
}

header .cart-icon i {
    font-size: 1.3rem;
}

header .cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #dc3545;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 20px;
}

header .cart-count:empty,
header .cart-count:not(:has-text) {
    display: none;
}

header .btn-login,
header .btn-signup,
header .btn-logout {
    padding: 0.4rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

header .btn-login {
    color: #dc3545 !important;
    background-color: transparent !important;
    border-color: #dc3545 !important;
}

header .btn-login:hover {
    background-color: #dc3545 !important;
    color: #fff !important;
}

header .btn-signup {
    color: #fff !important;
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
}

header .btn-signup:hover {
    background-color: #c82333 !important;
    border-color: #c82333 !important;
}

header .btn-logout {
    color: #fff !important;
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
}

header .btn-logout:hover {
    background-color: #c82333 !important;
    border-color: #c82333 !important;
}

/* Responsive Design - All scoped to header */

/* Large Desktops (1400px and up) */
@media (min-width: 1400px) {
    header nav .container {
        padding: 0 20px !important;
    }
    
    header .nav-menu {
        gap: 2rem;
    }
    
    header .logo a img {
        max-height: 70px;
        max-width: 250px;
    }
}

/* Medium Desktops and Tablets Landscape (1024px - 1399px) */
@media (min-width: 1024px) and (max-width: 1399px) {
    header .nav-menu {
        gap: 1.25rem;
    }
    
    header .nav-menu a {
        font-size: 0.9rem;
        padding: 0.5rem 0.875rem;
    }
}

/* Medium Screens (769px - 900px) - Transition to mobile menu */
@media (min-width: 769px) and (max-width: 900px) {
    header {
        padding: 0.75rem 10px !important;
    }
    
    header nav .container {
        padding: 0 10px !important;
        padding-left: 0 !important;
    }
    
    header .logo a {
        padding-left: 15px;
    }
    
    header .logo a .logo-2 {
        left: 15px;
    }
    
    header .logo a img {
        max-height: 55px;
        max-width: 180px;
    }
    
    header .nav-menu {
        gap: 0.75rem;
    }
    
    header .nav-menu a {
        font-size: 0.8rem;
        padding: 0.5rem 0.65rem;
    }
    
    header .btn-login,
    header .btn-signup,
    header .btn-logout {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
    
    header .cart-icon {
        width: 36px;
        height: 36px;
    }
    
    header .cart-icon i {
        font-size: 1.2rem;
    }
}

/* Tablets Portrait (901px - 1023px) */
@media (min-width: 901px) and (max-width: 1023px) {
    header {
        padding: 0.75rem 12px !important;
    }
    
    header nav .container {
        padding: 0 12px !important;
        padding-left: 0 !important;
    }
    
    header .logo a {
        padding-left: 15px;
    }
    
    header .logo a .logo-2 {
        left: 15px;
    }
    
    header .logo a img {
        max-height: 55px;
        max-width: 180px;
    }
    
    header .nav-menu {
        gap: 1rem;
    }
    
    header .nav-menu a {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }
    
    header .btn-login,
    header .btn-signup,
    header .btn-logout {
        padding: 0.4rem 0.875rem;
        font-size: 0.85rem;
    }
    
    header .cart-icon {
        width: 36px;
        height: 36px;
    }
    
    header .cart-icon i {
        font-size: 1.2rem;
    }
}

/* Mobile and Small Tablets (up to 768px) */
@media (max-width: 768px) {
    header {
        min-height: 60px !important;
        max-height: none !important;
        padding: 0.75rem 15px !important;
        position: relative;
        z-index: 1001;
    }
    
    header nav .container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        min-height: 60px !important;
        max-height: none !important;
        position: relative !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    /* Overlay background when menu is open */
    body.menu-open {
        overflow: hidden;
    }
    
    body.menu-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        pointer-events: auto;
    }
    
    header .logo {
        order: 1;
        flex: 1;
    }
    
    header .logo a img {
        max-height: 50px !important;
        max-width: 150px !important;
    }
    
    header .mobile-toggle {
        display: flex;
        order: 2;
        margin-left: auto;
        z-index: 1001;
        position: relative;
        overflow: visible;
    }
    
    header .mobile-toggle span {
        position: relative;
        transform-origin: center;
    }
    
    header .mobile-toggle.active {
        position: relative;
        z-index: 1002;
    }
    
    header .nav-wrapper {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        transform: translateX(100%);
        width: 60%;
        height: 75vh;
        order: 3;
        margin-top: 0;
        padding-top: 1rem;
        border-top: none;
        border-left: 1px solid rgba(0, 0, 0, 0.1);
        border-bottom-left-radius: 8px;
        background-color: #fff;
        overflow-y: auto;
        z-index: 1000;
        box-shadow: -2px 0 20px rgba(0, 0, 0, 0.2);
        transition: transform 0.3s ease;
    }
    
    header .nav-wrapper.active {
        display: flex;
        transform: translateX(0);
    }
    
    /* Overlay when menu is open - Scoped */
    header .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    header .nav-overlay.active {
        display: block;
    }
    
    header .nav-menu {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        margin: 0;
        padding: 0;
    }
    
    header .nav-menu li {
        width: 100%;
    }
    
    /* Show mobile auth items in mobile view */
    header .mobile-auth-item {
        display: list-item;
    }
    
    header .nav-menu a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        padding: 0.75rem 1rem;
        width: 100%;
    }
    
    header .nav-menu a i {
        font-size: 0.8rem;
        transition: transform 0.3s ease;
    }
    
    /* Dropdown on Mobile - Scoped */
    header .dropdown {
        width: 100%;
    }
    
    header .dropdown-toggle {
        width: 100%;
    }
    
    header .dropdown.active .dropdown-toggle i {
        transform: rotate(180deg);
    }
    
    header .dropdown-menu {
        position: static;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: none;
        box-shadow: none;
        background-color: #f8f9fa;
        margin-top: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, opacity 0.3s ease, visibility 0.3s ease, padding 0.3s ease;
        border-radius: 4px;
        width: 100%;
    }
    
    header .dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        max-height: 500px;
        padding: 0.5rem 0;
        margin-top: 0.25rem;
    }
    
    header .dropdown-menu li {
        width: 100%;
    }
    
    header .dropdown-menu a {
        padding: 0.6rem 1rem 0.6rem 2rem;
        font-size: 0.9rem;
        display: block;
    }
    
    header .dropdown-menu a:hover {
        padding-left: 2.25rem;
    }
    
    /* Hide desktop auth buttons in mobile */
    header .auth-buttons {
        display: none;
    }
    
    /* Mobile Auth Items - Style like other menu items */
    header .mobile-auth-item {
        width: 100%;
        margin-top: 0.5rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        padding-top: 0.5rem;
    }
    
    header .mobile-auth-link {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        width: 100%;
        color: #000;
        text-decoration: none;
        border-radius: 4px;
        transition: all 0.2s ease;
        font-size: 0.95rem;
        gap: 0.5rem;
    }
    
    header .mobile-auth-link:hover {
        background-color: #dc3545 !important;
        color: #fff !important;
    }
    
    header .mobile-auth-link i {
        font-size: 0.9rem;
    }
    
    /* Show cart icon separately in mobile if needed */
    header .cart-icon {
        display: none;
    }
}

/* Small Mobile Devices (up to 480px) */
@media (max-width: 480px) {
    header {
        padding: 0.75rem 10px !important;
        min-height: 55px !important;
    }
    
    header nav .container {
        padding: 0 10px !important;
        padding-left: 0 !important;
        min-height: 55px !important;
    }
    
    header .logo a {
        padding-left: 10px;
    }
    
    header .logo a .logo-2 {
        left: 10px;
    }
    
    header .logo a img {
        max-height: 40px !important;
        max-width: 120px !important;
    }
    
    header .mobile-toggle {
        padding: 0.4rem;
    }
    
    header .mobile-toggle span {
        width: 22px;
        height: 2.5px;
    }
    
    header .nav-wrapper {
        width: 70%;
        height: 100vh;
        border-bottom-left-radius: 0;
    }
    
    header .nav-menu a {
        padding: 0.65rem 1rem;
        font-size: 0.875rem;
    }
    
    header .auth-buttons {
        display: none;
    }
    
    header .mobile-auth-link {
        padding: 0.65rem 1rem;
        font-size: 0.875rem;
    }
    
    header .cart-icon {
        display: none;
    }
    
    header .cart-count {
        width: 18px;
        height: 18px;
        font-size: 0.65rem;
        top: -3px;
        right: -3px;
    }
}

/* Extra Small Mobile Devices (up to 360px) */
@media (max-width: 360px) {
    header {
        padding: 0.65rem 8px !important;
        min-height: 50px !important;
    }
    
    header nav .container {
        padding: 0 8px !important;
        padding-left: 0 !important;
        min-height: 50px !important;
    }
    
    header .logo a {
        padding-left: 8px;
    }
    
    header .logo a .logo-2 {
        left: 8px;
    }
    
    header .logo a img {
        max-height: 35px !important;
        max-width: 100px !important;
    }
    
    header .mobile-toggle {
        padding: 0.3rem;
    }
    
    header .mobile-toggle span {
        width: 20px;
        height: 2px;
    }
    
    header .nav-wrapper {
        width: 80%;
    }
    
    header .nav-menu a {
        padding: 0.6rem 0.875rem;
        font-size: 0.8rem;
    }
    
    header .auth-buttons {
        display: none;
    }
    
    header .mobile-auth-link {
        padding: 0.6rem 0.875rem;
        font-size: 0.8rem;
    }
    
    header .cart-icon {
        display: none;
    }
}

/* Landscape Orientation Adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    header .nav-wrapper {
        height: 100vh;
        max-height: 100vh;
    }
}
