/* Mobile Navigation Fixes */

/* Site Navigation Mobile Improvements */
@media screen and (max-width: 768px) {
    /* Fix mobile menu container */
    .site-nav-container {
        padding: 0 1rem;
    }
    
    .site-logo {
        font-size: 1rem;
        gap: 0.25rem;
    }
    
    .site-menu {
        overflow-y: auto;
        gap: 0;
        padding: 1rem;
    }
    
    .site-menu-item {
        width: 100%;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        margin-bottom: 0.5rem; /* Space between menu items */
    }
    
    .site-menu-item:last-child {
        margin-bottom: 0;
    }
    
    .site-menu-item > a {
        padding: 1rem 1.5rem;
        display: block !important;
        width: 100%;
        position: relative;
        line-height: 1.5;
    }
    
    .dropdown-menu {
        position: static !important;
        display: block !important;
        max-height: 0;
        overflow: hidden !important;
        opacity: 0;
        transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.2s ease-out,
                    padding 0.2s ease-out;
        background: rgba(45, 55, 72, 0.95) !important; /* Darker background */
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    
    .site-menu-item.expanded .dropdown-menu {
        max-height: 500px !important;
        opacity: 1;
        padding: 0.5rem 0 !important;
        margin-top: 0.5rem !important; /* Space between arrow and dropdown items */
    }
    
    /* Add chevron indicator for dropdowns */
    .site-menu-item.has-dropdown > a {
        position: relative;
        padding-right: 2.5rem !important; /* Space for arrow */
        white-space: nowrap !important; /* Prevent text wrapping */
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .site-menu-item.has-dropdown > a::after {
        content: '▼';
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.7rem;
        transition: transform 0.3s;
        color: rgba(255, 255, 255, 0.7);
    }
    
    .site-menu-item.expanded > a::after {
        transform: translateY(-50%) rotate(180deg);
    }
    
    /* Ensure dropdown container keeps items together */
    .dropdown-menu {
        contain: layout style;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .dropdown-menu a {
        display: block !important;
        width: 100% !important;
        padding: 0.75rem 1rem 0.75rem 2rem !important;
        font-size: 0.9rem !important;
        color: rgba(255, 255, 255, 0.9) !important;
        text-decoration: none !important;
        border-left: 3px solid transparent !important;
        transition: all 0.2s;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 1 !important;
        background: transparent !important;
    }
    
    .dropdown-menu a:hover,
    .dropdown-menu a:focus {
        background: rgba(16, 185, 129, 0.1) !important;
        border-left-color: #10b981 !important;
        color: white !important;
    }
    
    /* Better mobile menu toggle button */
    .mobile-menu-toggle {
        padding: 0.5rem;
        font-size: 1.8rem;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Calculator Tab Navigation Mobile Improvements */
@media (max-width: 768px) {
    /* Make tabs scrollable with better visual feedback */
    .nav-tabs {
        position: sticky;
        top: 60px;
        background: white;
        border-bottom: 1px solid #e5e7eb;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    .nav-tabs-container {
        padding: 0;
        gap: 0;
        overflow-x: auto;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
        /* Add scroll indicators */
        position: relative;
    }
    
    /* Custom scrollbar for tabs */
    .nav-tabs-container::-webkit-scrollbar {
        height: 4px;
    }
    
    .nav-tabs-container::-webkit-scrollbar-track {
        background: #f1f5f9;
    }
    
    .nav-tabs-container::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 2px;
    }
    
    /* Visual scroll indicator */
    .nav-tabs-container::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        background: linear-gradient(90deg, transparent, white);
        padding: 0 1rem;
        pointer-events: none;
        font-size: 1.2rem;
        color: #94a3b8;
    }
    
    .nav-tabs-container.scrolled-end::after {
        display: none;
    }
    
    /* Improve tab button appearance on mobile */
    .nav-tab {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
        min-width: fit-content;
        border-bottom: 2px solid transparent;
        border-radius: 0;
        position: relative;
    }
    
    .nav-tab span {
        font-size: 1rem;
        margin-right: 0.25rem;
    }
    
    .nav-tab.active {
        background: rgba(99, 102, 241, 0.05);
        border-bottom-color: #6366f1;
    }
    
    /* Add touch-friendly tap targets */
    .nav-tab {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Table Responsiveness */
@media (max-width: 768px) {
    /* Make tables scrollable */
    .assessment-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        font-size: 0.875rem;
    }
    
    .assessment-table th,
    .assessment-table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Alternative: Stack table rows on very small screens */
    @media (max-width: 480px) {
        .assessment-table thead {
            display: none;
        }
        
        .assessment-table tr {
            display: block;
            border: 1px solid #e5e7eb;
            margin-bottom: 1rem;
            border-radius: 8px;
            padding: 0.5rem;
        }
        
        .assessment-table td {
            display: block;
            text-align: left;
            padding: 0.5rem;
            white-space: normal;
        }
        
        .assessment-table td:before {
            content: attr(data-label);
            font-weight: bold;
            display: inline-block;
            width: 120px;
            color: #64748b;
        }
    }
}

/* Button and Form Improvements */
@media (max-width: 768px) {
    /* Make buttons more touch-friendly */
    .btn, button {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    /* Stack button groups vertically on mobile */
    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .button-group button {
        width: 100%;
    }
    
    /* Form inputs */
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
        min-height: 44px;
    }
    
    /* Form grids */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Container and Content Spacing */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        max-width: 100%;
    }
    
    .section {
        padding: 1.5rem 1rem;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header p {
        font-size: 0.9rem;
    }
}

/* Card and Grid Layouts */
@media (max-width: 768px) {
    .tools-grid,
    .features-grid,
    .cloud-cards,
    .service-mapping-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .tool-card,
    .cloud-card {
        padding: 1.5rem;
    }
}

/* Stat Values */
@media (max-width: 768px) {
    .stat-value {
        font-size: 2rem;
    }
    
    .metric-value {
        font-size: 1.5rem;
    }
}

/* Modal Improvements */
@media (max-width: 768px) {
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

/* Accessibility Improvements */
@media (max-width: 768px) {
    /* Ensure touch targets are at least 44x44px */
    a, button, input, select, textarea {
        min-height: 44px;
    }
    
    /* Add more spacing between interactive elements */
    .site-menu-item + .site-menu-item {
        margin-top: 0.25rem;
    }
}

/* Print Styles */
@media print {
    .site-nav,
    .nav-tabs,
    .mobile-menu-toggle,
    .button-group {
        display: none !important;
    }
}