/**
 * Responsive Menu Styles
 * Optimized for iPad and tablet devices
 */

/* Base Menu Toggle Button */
.menu-toggle {
    display: none;
    background: #049a54;
    border: none;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.menu-toggle:hover {
    background: #038242;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.menu-toggle-text {
    font-size: 14px;
}

.menu-toggle-icon {
    display: flex;
    flex-direction: column;
    width: 24px;
    gap: 4px;
}

.menu-toggle-icon span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Animated hamburger icon */
.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(2) {
    opacity: 0;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Navigation wrapper for smooth animations */
.navigation-wrapper {
    overflow: hidden;
    transition: max-height 0.4s ease;
}

/* Menu item arrow indicator */
.menu-item-arrow {
    display: none;
    margin-left: auto;
    font-size: 20px;
    color: #999;
    transition: transform 0.3s ease;
}

/* Desktop styles (default) */
@media (min-width: 1025px) {
    .main-navigation ul {
        display: flex;
        list-style: none;
        margin: 0;
        padding: 0;
        gap: 2rem;
    }
    
    .menu-item-arrow {
        display: none !important;
    }
}

/* iPad and tablets (including 875px width) */
@media (max-width: 1024px) {
    .menu-toggle {
        display: flex;
        width: 100%;
        justify-content: space-between;
    }
    
    .navigation-wrapper {
        position: absolute;
        top: calc(100% + 10px);
        left: 0;
        right: 0;
        background-color: #fff;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.12);
        max-height: 0;
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s ease;
        z-index: 1000;
    }
    
    .main-navigation.active .navigation-wrapper {
        max-height: 600px;
        opacity: 1;
        visibility: visible;
    }
    
    .main-navigation ul {
        flex-direction: column;
        padding: 0;
        margin: 0;
        gap: 0;
    }
    
    .main-navigation li {
        border-bottom: 1px solid #f0f0f0;
        width: 100%;
        transition: background-color 0.3s ease;
    }
    
    .main-navigation li:last-child {
        border-bottom: none;
    }
    
    .main-navigation li:hover {
        background-color: #f8f8f8;
    }
    
    .main-navigation a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 18px 24px;
        color: #333;
        text-decoration: none;
        font-size: 16px;
        font-weight: 500;
        transition: all 0.3s ease;
    }
    
    .main-navigation a:hover {
        color: #049a54;
        padding-left: 28px;
    }
    
    .menu-item-arrow {
        display: block;
    }
    
    .main-navigation a:hover .menu-item-arrow {
        transform: translateX(4px);
    }
    
    /* Special styling for logout */
    .menu-item-logout a {
        color: #dc3545;
        background-color: #fff5f5;
    }
    
    .menu-item-logout a:hover {
        background-color: #ffe0e0;
    }
}

/* iPad and standard tablets (768px to 1024px) - Optimized touch targets */
@media (min-width: 768px) and (max-width: 1024px) {
    .menu-toggle {
        padding: 14px 24px;
        font-size: 17px;
    }
    
    .main-navigation a {
        padding: 20px 28px;
        font-size: 17px;
        min-height: 60px; /* Optimal touch target size for iPad */
    }
    
    /* Increase spacing for better touch experience */
    .navigation-wrapper {
        margin: 0 -10px;
    }
    
    .main-navigation li {
        margin: 0 10px;
        border-radius: 8px;
        border-bottom: none;
        margin-bottom: 8px;
    }
    
    .main-navigation li:last-child {
        margin-bottom: 10px;
    }
}

/* Small tablets and large phones (481px to 767px) */
@media (max-width: 767px) {
    .header-inner {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 10px;
        position: relative;
    }

    .site-branding {
        flex: 1 1 auto;
        text-align: left !important;
    }

    .site-branding-link {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
    }

    .site-title {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .site-title-wrapper {
        display: flex !important;
        flex-direction: column !important;
    }

    .main-navigation {
        flex-shrink: 0;
        position: static;
    }

    .menu-toggle {
        width: auto;
        padding: 8px 12px;
        font-size: 13px;
    }

    .menu-toggle-icon {
        width: 18px;
    }

    .navigation-wrapper {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        border-radius: 0;
        margin: 0;
        width: 100vw;
        margin-left: calc(-50vw + 50%);
    }

    .main-navigation a {
        padding: 16px 20px;
        font-size: 15px;
    }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
    .header-inner {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.5rem 0;
        gap: 8px;
        position: relative;
    }

    .site-branding {
        flex: 1 1 auto;
        text-align: left !important;
    }

    .site-branding-link {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    .site-title {
        font-size: 0.85rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .site-title-wrapper {
        display: flex !important;
        flex-direction: column !important;
    }

    .site-icon img {
        width: 32px;
        height: 32px;
    }

    .main-navigation {
        position: static;
    }

    .menu-toggle {
        padding: 6px 10px;
        font-size: 12px;
        gap: 6px;
        flex-shrink: 0;
    }

    .menu-toggle-icon {
        width: 16px;
        gap: 3px;
    }

    .menu-toggle-icon span {
        height: 2px;
    }

    .navigation-wrapper {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100vw;
        margin-left: calc(-50vw + 50%);
    }

    .main-navigation a {
        padding: 14px 16px;
        font-size: 14px;
    }

    .menu-item-arrow {
        font-size: 18px;
    }
}

/* Touch-friendly enhancements for all touch devices */
@media (hover: none) and (pointer: coarse) {
    .main-navigation a {
        min-height: 48px; /* iOS recommended touch target */
    }
    
    .menu-toggle {
        min-height: 44px; /* iOS recommended touch target */
    }
    
    /* Disable hover effects on touch devices */
    .main-navigation li:hover {
        background-color: transparent;
    }
    
    /* Add active state for touch feedback */
    .main-navigation a:active {
        background-color: #f0f0f0;
        transform: scale(0.98);
    }
}

/* Landscape orientation adjustments for tablets */
@media (orientation: landscape) and (max-width: 1024px) and (min-height: 600px) {
    .navigation-wrapper {
        max-height: 400px;
        overflow-y: auto;
    }
    
    .main-navigation a {
        padding: 14px 24px;
        min-height: 50px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .navigation-wrapper {
        background-color: #2a2a2a;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    }
    
    .main-navigation li {
        border-bottom-color: #444;
    }
    
    .main-navigation a {
        color: #e0e0e0;
    }
    
    .main-navigation a:hover {
        color: #4fc97a;
        background-color: #333;
    }
    
    .menu-item-arrow {
        color: #666;
    }
    
    .menu-item-logout a {
        background-color: #3d2020;
    }
    
    .menu-item-logout a:hover {
        background-color: #4d2525;
    }
}