/* Consistent Mobile Menu - Unified Format */

/* Reset and base styles */
* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

/* Desktop - Hide mobile menu completely with enhanced responsive behavior */
@media (min-width: 768px) {
    .hamburger-wrapper,
    .menu-overlay,
    .slide-menu {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
        transform: translateX(100%) !important;
    }
    
    /* Ensure no mobile menu interference on desktop */
    .menu-open {
        overflow: auto !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
    }
}

/* Mobile only styles */
@media (max-width: 767px) {
    /* Hamburger Button Wrapper */
    .hamburger-wrapper {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Enhanced hamburger button - responsive design matching desktop navbar */
    .hamburger-button {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        border-radius: 8px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        
        /* Enhanced responsive touch target */
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Responsive hamburger button sizing */
    @media (max-width: 480px) {
        .hamburger-button {
            width: 40px;
            height: 40px;
            min-width: 40px;
            min-height: 40px;
            padding: 6px;
        }
    }
    
    @media (max-width: 360px) {
        .hamburger-button {
            width: 36px;
            height: 36px;
            min-width: 36px;
            min-height: 36px;
            padding: 4px;
        }
    }

    .hamburger-button:hover {
        background-color: rgba(220, 38, 38, 0.1);
    }

    .hamburger-button:active {
        transform: scale(0.98);
        background-color: rgba(220, 38, 38, 0.2);
    }

    .hamburger-button:focus {
        outline: none;
        outline-offset: 2px;
    }

    /* Enhanced hamburger lines - responsive design matching desktop navbar behavior */
    .hamburger-line {
        width: 24px;
        height: 2.5px;
        background-color: #ffffff; /* Default white like desktop navbar */
        margin: 2px 0;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 2px;
        display: block;
        transform-origin: center;
    }
    
    /* Responsive hamburger line sizing */
    @media (max-width: 480px) {
        .hamburger-line {
            width: 22px;
            height: 2px;
            margin: 1.5px 0;
        }
    }
    
    @media (max-width: 360px) {
        .hamburger-line {
            width: 20px;
            height: 2px;
            margin: 1.5px 0;
        }
    }

    /* Hamburger lines when page is scrolled - red color (matches desktop login button) */
    .navbar-scrolled .hamburger-line {
        background-color: #dc2626 !important;
    }

    /* White hamburger lines at top (matches desktop initial state) */
    .hamburger-line.text-white {
        background-color: #ffffff !important;
    }

    /* Red hamburger lines when scrolled (matches desktop scrolled state) */
    .hamburger-line.text-red-600 {
        background-color: #dc2626 !important;
    }

    /* Ensure active state maintains proper colors */
    .hamburger-button.active .hamburger-line.text-white {
        background-color: #ffffff !important;
    }

    .hamburger-button.active .hamburger-line.text-red-600 {
        background-color: #dc2626 !important;
    }

    .navbar-scrolled .hamburger-button.active .hamburger-line {
        background-color: #dc2626 !important;
    }

    /* X Animation - Consistent */
    .hamburger-button.active .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }

    .hamburger-button.active .hamburger-line:nth-child(2) {
        opacity: 0;
        transform: scale(0);
    }

    .hamburger-button.active .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Menu Overlay - Consistent */
    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Slide Menu - Consistent Layout */
    .slide-menu {
        position: fixed;
        top: 0;
        right: 0;
        width: 320px;
        height: 100vh;
        background: white;
        z-index: 999;
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        overflow-x: hidden;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
    }

    .slide-menu.active {
        transform: translateX(0);
    }

    /* Enhanced responsive width with improved breakpoints (matches desktop navbar) */
    @media (max-width: 480px) {
        .slide-menu {
            width: 300px;
        }
        
        /* Enhanced touch targets for smaller screens */
        .menu-item,
        .menu-dropdown-btn {
            padding: 16px 20px;
            font-size: 15px;
        }
        
        .dropdown-content .menu-item {
            padding: 14px 20px;
            font-size: 15px;
        }
    }

    @media (max-width: 360px) {
        .slide-menu {
            width: 280px;
        }
        
        /* Further optimize for very small screens */
        .menu-header {
            padding: 16px;
        }
        
        .logo-text {
            font-size: 13px;
        }
        
        .menu-item,
        .menu-dropdown-btn {
            padding: 14px 16px;
            font-size: 14px;
        }
        
        .dropdown-content .menu-item {
            padding: 12px 16px;
            font-size: 14px;
        }
        
        .login-button {
            margin: 16px;
            padding: 12px 16px;
            font-size: 15px;
        }
    }
    
    /* Enhanced responsive behavior for landscape orientation */
    @media (max-width: 767px) and (orientation: landscape) {
        .slide-menu {
            width: 300px;
            max-height: 100vh;
            overflow-y: auto;
        }
        
        .menu-header {
            padding: 12px 20px;
        }
        
        .menu-nav {
            padding: 12px 0;
        }
        
        .menu-item,
        .menu-dropdown-btn {
            padding: 10px 20px;
        }
        
        .dropdown-content .menu-item {
            padding: 8px 20px;
        }
    }

    /* Menu Header - Consistent Format */
    .menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20px;
        border-bottom: 1px solid #e5e7eb;
        background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
        flex-shrink: 0;
    }

    /* Logo - Consistent Format */
    .menu-logo {
        display: flex;
        align-items: center;
        gap: 12px;
        flex: 1;
    }

    .logo-img {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        flex-shrink: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .logo-text {
        font-weight: 700;
        color: #374151;
        font-size: 14px;
        line-height: 1.2;
        flex: 1;
    }

    .close-button {
        background: none;
        border: none;
        font-size: 20px;
        cursor: pointer;
        padding: 8px;
        border-radius: 6px;
        color: #6b7280;
        transition: all 0.2s ease;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
    }

    .close-button:hover {
        background-color: #e5e7eb;
        color: #374151;
    }

    .close-button:active {
        transform: scale(0.98);
    }

    .close-button:focus {
        outline: none;
        outline-offset: 2px;
    }

    /* Menu Navigation - Consistent Format */
    .menu-nav {
        flex: 1;
        padding: 20px 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    /* Menu Items - Consistent Format */
    .menu-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 20px;
        color: #374151;
        text-decoration: none;
        font-weight: 500;
        font-size: 16px;
        transition: all 0.3s ease;
        border: none;
        background: transparent;
        width: 100%;
        text-align: left;
        cursor: pointer;
        position: relative;
        border-radius: 0;
        
        /* Animation initial state */
        opacity: 0;
        transform: translateY(20px);
    }

    /* Staggered entrance animation */
    .slide-menu.active .menu-item:nth-child(1) { animation: slideInUp 0.5s ease 0.1s forwards; }
    .slide-menu.active .menu-item:nth-child(2) { animation: slideInUp 0.5s ease 0.15s forwards; }
    .slide-menu.active .menu-item:nth-child(3) { animation: slideInUp 0.5s ease 0.2s forwards; }
    .slide-menu.active .menu-item:nth-child(4) { animation: slideInUp 0.5s ease 0.25s forwards; }
    .slide-menu.active .menu-item:nth-child(5) { animation: slideInUp 0.5s ease 0.3s forwards; }

    @keyframes slideInUp {
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .menu-item:hover {
        background-color: #f3f4f6;
        color: #dc2626;
    }

    .menu-item:active {
        transform: scale(0.98);
    }

    .menu-item.active {
        color: #dc2626;
        background-color: #fef2f2;
        border-left: 4px solid #dc2626;
    }

    .menu-item:focus {
        outline: none;
        outline-offset: -2px;
    }

    /* Menu Icons - Consistent Format */
    .menu-icon {
        width: 20px;
        height: 20px;
        text-align: center;
        color: #dc2626;
        font-size: 16px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .menu-text {
        flex: 1;
        font-weight: 500;
        font-size: 16px;
    }

    /* Dropdown Container - Consistent Format */
    .menu-dropdown {
        display: block;
        position: relative;
        
        /* Animation initial state */
        opacity: 0;
        transform: translateY(20px);
    }

    /* Staggered animation for dropdowns */
    .slide-menu.active .menu-dropdown:nth-child(2) { animation: slideInUp 0.5s ease 0.15s forwards; }
    .slide-menu.active .menu-dropdown:nth-child(4) { animation: slideInUp 0.5s ease 0.25s forwards; }

    .menu-dropdown-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 14px 20px;
        color: #374151;
        font-weight: 500;
        font-size: 16px;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: all 0.3s ease;
        text-align: left;
    }

    .menu-dropdown-btn:hover {
        background-color: #f3f4f6;
        color: #dc2626;
    }

    .menu-dropdown-btn:active {
        transform: scale(0.98);
    }

    .menu-dropdown-btn:focus {
        outline: none;
        outline-offset: -2px;
    }

    .menu-item-content {
        display: flex;
        align-items: center;
        gap: 12px;
        flex: 1;
    }

    .arrow-icon {
        font-size: 12px;
        transition: transform 0.3s ease;
        color: #6b7280;
        flex-shrink: 0;
        width: 16px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .menu-dropdown.active .arrow-icon {
        transform: rotate(180deg);
    }

    /* Dropdown Content - Simple Format (matching main menu items) */
    .dropdown-content {
        background-color: #f9fafb;
        border-top: 1px solid #e5e7eb;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .menu-dropdown.active .dropdown-content {
        max-height: 400px;
    }

    /* Dropdown menu items use same styling as main menu items */
    .dropdown-content .menu-item {
        background-color: #f9fafb;
        border-left: none;
        margin: 0;
    }

    .dropdown-content .menu-item:hover {
        background-color: #f3f4f6;
        color: #dc2626;
    }

    .dropdown-content .menu-item.active {
        color: #dc2626;
        background-color: #fef2f2;
        border-left: 4px solid #dc2626;
    }

    /* Logout Form - Consistent Format */
    .logout-form {
        margin-top: 16px;
        border-top: 1px solid #e5e7eb;
        padding-top: 20px;
        
        /* Animation initial state */
        opacity: 0;
        transform: translateY(20px);
    }

    .slide-menu.active .logout-form {
        animation: slideInUp 0.5s ease 0.4s forwards;
    }

    .logout-btn {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 20px;
        color: #dc2626;
        text-decoration: none;
        font-weight: 500;
        font-size: 16px;
        transition: all 0.3s ease;
        border: none;
        background: transparent;
        width: 100%;
        text-align: left;
        cursor: pointer;
    }

    .logout-btn:hover {
        background-color: #fef2f2;
        color: #b91c1c;
    }

    .logout-btn:active {
        transform: scale(0.98);
    }

    .logout-btn:focus {
        outline: none;
        outline-offset: -2px;
    }

    /* Login Button - Consistent Format */
    .login-button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        background: linear-gradient(135deg, #dc2626, #b91c1c);
        color: white;
        padding: 14px 20px;
        border-radius: 8px;
        font-weight: 600;
        font-size: 16px;
        text-align: center;
        margin: 20px;
        transition: all 0.3s ease;
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
        text-decoration: none;
        
        /* Animation initial state */
        opacity: 0;
        transform: translateY(20px);
    }

    .slide-menu.active .login-button {
        animation: slideInUp 0.5s ease 0.45s forwards;
    }

    .login-button:hover {
        background: linear-gradient(135deg, #b91c1c, #991b1b);
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4);
        color: white;
    }

    .login-button:active {
        transform: scale(0.98);
    }

    .login-button:focus {
        outline: none;
        outline-offset: 2px;
    }

    /* Login Icons - Consistent Format */
    .login-icon {
        width: 16px;
        height: 16px;
        font-size: 14px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .login-text {
        font-weight: 600;
        font-size: 16px;
    }

    /* Body scroll lock */
    .menu-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) and (max-width: 767px) {
    .slide-menu {
        border: 2px solid #000;
    }
    
    .hamburger-line {
        background-color: #000;
    }
    
    .menu-item:hover,
    .menu-dropdown-btn:hover {
        background: #000;
        color: #fff;
    }
    
    .dropdown-content .menu-item:hover {
        background: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) and (max-width: 767px) {
    .hamburger-line,
    .menu-overlay,
    .slide-menu,
    .dropdown-content,
    .arrow-icon,
    .menu-item,
    .menu-dropdown,
    .login-button,
    .logout-form {
        transition: none;
        animation: none;
    }
    
    .slide-menu.active .menu-item,
    .slide-menu.active .menu-dropdown,
    .slide-menu.active .login-button,
    .slide-menu.active .logout-form {
        opacity: 1;
        transform: none;
    }
}