/* 
 * Mobile Navigation Fix for FlotillaTracker.com
 * Ensures perfect mobile dropdown menu functionality
 * Higher specificity to override main styles
 */

/* IMPORTANT: Mobile Navigation Fixes with Higher Specificity */
@media (max-width: 991px) {
    /* Fix main content padding for all pages */
    body .main-content {
        padding-top: 80px !important;
        min-height: 100vh;
    }
    
    /* Ensure all page layouts are properly structured */
    body .page-hero,
    body .hero-section,
    body section {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Fix container widths */
    body .container {
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* Ensure header is properly positioned */
    body .header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 1030 !important;
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(15px) !important;
        border-bottom: 1px solid #e5e7eb !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Nav container positioning */
    body .nav-container {
        padding: 1rem 1.5rem !important;
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    
    /* CRITICAL: Toggle button must be visible and functional */
    body .nav-toggle {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-around !important;
        align-items: center !important;
        width: 32px !important;
        height: 32px !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        padding: 4px !important;
        z-index: 1031 !important;
        transition: all 0.3s ease !important;
        position: relative !important;
        order: 999 !important;
    }
    
    .nav-toggle:focus {
        outline: 2px solid #2563eb;
        outline-offset: 2px;
        border-radius: 4px;
    }
    
    .nav-toggle-icon {
        width: 25px;
        height: 3px;
        background-color: #1e293b;
        transition: all 0.3s ease;
        border-radius: 2px;
    }
    
    /* Hamburger animation */
    .nav-toggle[aria-expanded="true"] .nav-toggle-icon:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .nav-toggle[aria-expanded="true"] .nav-toggle-icon:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle[aria-expanded="true"] .nav-toggle-icon:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    .nav-menu {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
    }
    
    .nav-menu.nav-menu-open,
    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-list {
        flex-direction: column;
        padding: 1.5rem 0;
        margin: 0;
        list-style: none;
        width: 100%;
    }
    
    .nav-item {
        margin: 0;
        width: 100%;
        border-bottom: 1px solid #f1f5f9;
    }
    
    .nav-item:last-child {
        border-bottom: none;
    }
    
    .nav-link {
        display: flex;
        align-items: center;
        padding: 1rem 1.5rem;
        width: 100%;
        color: #64748b;
        text-decoration: none;
        font-weight: 500;
        font-size: 1rem;
        transition: all 0.2s ease;
        border-left: 4px solid transparent;
    }
    
    .nav-link:hover {
        background-color: #f8fafc;
        color: #2563eb;
        border-left-color: #2563eb;
    }
    
    .nav-link.active {
        background-color: #eff6ff;
        color: #2563eb !important;
        border-left-color: #2563eb;
        font-weight: 600;
    }
    
    .nav-link i {
        margin-right: 0.75rem;
        font-size: 1.1rem;
        width: 20px;
        text-align: center;
        color: inherit;
    }
    
    /* Prevent body scroll when menu is open */
    body.nav-open {
        overflow: hidden;
    }
    
    /* Overlay for better UX */
    .nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 998;
    }
    
    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    .nav-container {
        padding: 0.75rem 1rem;
    }
    
    .brand-link {
        font-size: 1.1rem;
    }
    
    .brand-link i {
        font-size: 1.3rem;
    }
    
    .nav-toggle {
        width: 28px;
        height: 28px;
    }
    
    .nav-toggle-icon {
        width: 22px;
        height: 2.5px;
    }
    
    .nav-link {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
    
    .nav-link i {
        font-size: 1rem;
    }
}

/* Extra small mobile */
@media (max-width: 480px) {
    .nav-container {
        padding: 0.75rem 0.75rem;
    }
    
    .brand-link {
        font-size: 1rem;
    }
    
    .brand-text {
        font-size: 1rem;
    }
    
    .nav-link {
        padding: 0.75rem 0.75rem;
        font-size: 0.9rem;
    }
}

/* Smooth animations */
@media (prefers-reduced-motion: reduce) {
    .nav-menu,
    .nav-toggle-icon,
    .nav-link,
    .nav-overlay {
        transition: none;
    }
}

/* High contrast support */
@media (prefers-contrast: high) {
    .nav-menu {
        border: 2px solid #000;
    }
    
    .nav-link {
        border-bottom: 1px solid #000;
    }
    
    .nav-toggle-icon {
        background-color: #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .header {
        background: rgba(30, 41, 59, 0.95);
        border-bottom-color: #374151;
    }
    
    .nav-menu {
        background: #1e293b;
        border-top-color: #374151;
    }
    
    .nav-link {
        color: #cbd5e1;
    }
    
    .nav-link:hover {
        background-color: #334155;
        color: #60a5fa;
    }
    
    .nav-link.active {
        background-color: #1e40af;
        color: white !important;
    }
    
    .nav-toggle-icon {
        background-color: #cbd5e1;
    }
    
    .nav-item {
        border-bottom-color: #374151;
    }
}

/* Universal Mobile Responsive Fixes */
@media (max-width: 991px) {
    /* Fix text sizing and spacing */
    body .page-title,
    body .section-title,
    body .hero-title {
        font-size: 2rem !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }
    
    /* Fix content grids */
    body .content-grid,
    body .features-grid,
    body .values-grid,
    body .technology-grid,
    body .team-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    /* Fix hero sections */
    body .page-hero,
    body .hero-section {
        padding: 2rem 0 !important;
        text-align: center !important;
    }
    
    /* Fix page descriptions */
    body .page-description,
    body .hero-description,
    body .section-description {
        font-size: 1rem !important;
        padding: 0 1rem !important;
    }
    
    /* Fix all sections padding */
    body section {
        padding: 2rem 0 !important;
    }
    
    /* Fix cards and feature boxes */
    body .feature-card,
    body .value-card,
    body .tech-card,
    body .team-card {
        margin-bottom: 1rem !important;
        padding: 1.5rem !important;
    }
    
    /* Fix images */
    body img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Fix buttons */
    body .btn,
    body .button {
        display: block !important;
        width: 100% !important;
        max-width: 300px !important;
        margin: 0.5rem auto !important;
        text-align: center !important;
    }
    
    /* Fix hero actions */
    body .hero-actions {
        flex-direction: column !important;
        align-items: center !important;
        gap: 1rem !important;
    }
    
    /* Fix breadcrumbs */
    body .breadcrumb-list {
        flex-wrap: wrap !important;
        justify-content: center !important;
        font-size: 0.9rem !important;
    }
    
    /* Fix stats sections */
    body .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Fix footer */
    body .footer-content {
        grid-template-columns: 1fr !important;
        text-align: center !important;
        gap: 2rem !important;
    }
}

/* Extra mobile fixes for very small screens */
@media (max-width: 480px) {
    body .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    body .page-title,
    body .section-title,
    body .hero-title {
        font-size: 1.75rem !important;
    }
    
    body .page-description,
    body .hero-description {
        font-size: 0.95rem !important;
    }
    
    body section {
        padding: 1.5rem 0 !important;
    }
    
    body .feature-card,
    body .value-card,
    body .tech-card,
    body .team-card {
        padding: 1rem !important;
    }
}
