/* ===========================================
   MOBILE RESPONSIVENESS - Janeiro 2026
   Breakpoints: 
   - Mobile: < 768px
   - Tablet: 768px - 1024px
   - Desktop: > 1024px
   =========================================== */

/* ==================== MOBILE MENU TOGGLE ==================== */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ==================== MOBILE DATE SELECTOR ==================== */
.mobile-date-selector {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    margin-top: 8px;
}

.current-date-display-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.date-nav-btn {
    background: var(--accent-blue);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.date-nav-btn:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.date-nav-btn:active {
    transform: scale(0.95);
}

.date-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.date-day {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.date-month {
    font-size: 0.75rem;
    color: var(--accent-blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.day-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.day-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 8px 4px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.day-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.day-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    font-weight: 700;
}

.day-btn.weekend {
    color: var(--accent-orange);
}

.day-btn.weekend.active {
    background: var(--accent-orange);
    color: white;
}

/* ==================== TABLET (768px - 1024px) ==================== */
@media screen and (max-width: 1024px) {

    /* Sidebar adjustments */
    .sidebar {
        width: 240px;
        padding: 1rem;
    }

    /* Main content padding */
    .dashboard-grid {
        padding: 1.25rem;
        gap: 1rem;
    }

    /* Grid adjustments - half-width becomes full on tablet */
    .half-width {
        grid-column: span 12;
    }

    /* KPI cards */
    .kpi-card .value {
        font-size: 1.75rem;
    }

    /* Top bar */
    .top-bar {
        padding: 0 1.25rem;
        height: 70px;
    }

    .page-title h2 {
        font-size: 1.1rem;
    }
}

/* ==================== MOBILE (< 768px) ==================== */
@media screen and (max-width: 768px) {

    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Allow body scroll */
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }

    /* App container - stack vertically */
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* ===== SIDEBAR AS COLLAPSIBLE DRAWER ===== */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        padding: 1rem;
        border-right: 1px solid var(--border-color);
        overflow-y: auto;
        box-shadow: none;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    /* Mobile overlay background */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .mobile-overlay.active {
        display: block;
    }

    /* Close button for sidebar */
    .sidebar-close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        color: var(--text-primary);
        font-size: 1.25rem;
        padding: 0.5rem 0.75rem;
        border-radius: 0.5rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .sidebar-close:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    /* Brand - centered and compact */
    .brand {
        margin-bottom: 1rem;
        justify-content: center;
    }

    .brand-logo {
        max-width: 25px;
    }

    .brand-suffix {
        font-size: 1rem;
    }

    /* Nav sections - collapsible look */
    .nav-section {
        margin-bottom: 1rem;
    }

    .nav-section h3 {
        font-size: 0.7rem;
        margin-bottom: 0.75rem;
        text-align: center;
    }

    /* Date picker full width */
    .date-picker-container input {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    /* View Mode Toggle - horizontal */
    .nav-section div[style*="display: flex"][style*="gap: 8px"] {
        flex-direction: row !important;
        gap: 4px !important;
        margin-bottom: 8px !important;
    }

    /* First nav-section (DATA DA OPERAÇÃO) - ensure date picker is visible */
    .nav-section:first-of-type {
        display: block !important;
        height: auto !important;
        min-height: auto;
        overflow: visible !important;
        margin-bottom: 1rem;
    }

    /* Date picker container styling for mobile */
    .date-picker-container {
        display: block !important;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .date-picker-container input[type="date"] {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        color: var(--text-primary);
        -webkit-appearance: none;
        appearance: none;
    }

    /* ===== MOBILE DATE SELECTOR - FORCED STYLES ===== */
    .nav-section.date-section {
        display: block !important;
        height: auto !important;
        min-height: 280px !important;
        overflow: visible !important;
        margin-bottom: 1.5rem !important;
    }

    .mobile-date-selector {
        display: block !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        border-radius: 12px !important;
        padding: 15px !important;
        margin-top: 10px !important;
    }

    .current-date-display-mobile {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 15px !important;
        padding: 8px !important;
        background: rgba(0, 0, 0, 0.2) !important;
        border-radius: 10px !important;
    }

    .date-nav-btn {
        background: #3b82f6 !important;
        border: none !important;
        color: white !important;
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        font-size: 1.1rem !important;
    }

    .date-info {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }

    .date-day {
        font-size: 2.5rem !important;
        font-weight: 700 !important;
        color: white !important;
        line-height: 1 !important;
    }

    .date-month {
        font-size: 0.8rem !important;
        color: #60a5fa !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
    }

    .day-grid {
        display: grid !important;
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 6px !important;
    }

    .day-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(255, 255, 255, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        color: white !important;
        min-height: 38px !important;
        aspect-ratio: 1 !important;
        border-radius: 8px !important;
        font-size: 0.9rem !important;
        font-weight: 500 !important;
        cursor: pointer !important;
        padding: 0 !important;
    }

    .day-btn.active {
        background: #3b82f6 !important;
        border-color: #3b82f6 !important;
        font-weight: 700 !important;
    }

    .day-btn.weekend {
        color: #fb923c !important;
    }

    .day-btn.weekend.active {
        background: #f97316 !important;
        border-color: #f97316 !important;
        color: white !important;
    }

    /* ===== KPI SECTIONS - ENSURE VISIBILITY ===== */
    /* RESUMO DO DIA section (2nd nav-section) */
    .nav-section:nth-of-type(2) {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        margin-bottom: 1rem !important;
    }

    .nav-section:nth-of-type(2) h3 {
        display: block !important;
        visibility: visible !important;
        margin-bottom: 0.75rem !important;
    }

    /* MÉTRICAS OPERACIONAIS section (3rd nav-section) */
    .nav-section:nth-of-type(3) {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        margin-bottom: 1rem !important;
    }

    .nav-section:nth-of-type(3) h3 {
        display: block !important;
        visibility: visible !important;
        margin-bottom: 0.75rem !important;
    }

    /* KPI Cards in sidebar - visible and stacked */
    .nav-section .kpi-card.mini {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
        padding: 0.75rem !important;
        min-height: 60px !important;
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(30, 41, 59, 0.8) 100%) !important;
        border: 1px solid rgba(59, 130, 246, 0.2) !important;
        border-radius: 10px !important;
    }

    /* KPI cards compact */
    .kpi-card.mini {
        padding: 0.75rem;
        min-height: 60px;
        gap: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .kpi-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        border-radius: 8px;
    }

    .kpi-card .label {
        font-size: 0.65rem;
    }

    .kpi-card .value {
        font-size: 1.35rem;
    }

    .kpi-card .kpi-desc {
        font-size: 0.6rem;
        display: none;
        /* Hide description on mobile */
    }

    /* Nav footer */
    .nav-footer {
        display: flex;
        justify-content: space-between;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color);
    }

    .nav-footer p {
        font-size: 0.65rem;
    }

    /* ===== MAIN CONTENT ===== */
    .main-content {
        flex: 1;
        overflow: visible;
    }

    /* Top bar */
    .top-bar {
        height: 60px;
        padding: 0 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .page-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .page-title h2 {
        font-size: 0.9rem;
    }

    .status-badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.5rem;
    }

    .actions {
        display: flex;
        gap: 0.25rem;
    }

    .btn-icon {
        padding: 0.4rem;
        font-size: 1rem;
    }

    /* ===== DASHBOARD GRID ===== */
    .dashboard-grid {
        padding: 1rem;
        gap: 1rem;
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    /* All grid items full width */
    .grid-item,
    .full-width,
    .half-width {
        grid-column: span 1;
        width: 100%;
    }

    .grid-item {
        padding: 1rem;
        border-radius: 0.5rem;
    }

    /* Card header */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .card-header h3 {
        font-size: 0.95rem;
    }

    .card-header h3 i {
        font-size: 0.9rem;
    }

    /* ===== FILTERS ===== */
    .filters {
        flex-wrap: wrap;
        gap: 0.35rem;
        width: 100%;
    }

    .filter-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.75rem;
        flex: 0 0 auto;
    }

    /* Chart filter buttons */
    .chart-filter-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    /* ===== METRICS GRID ===== */
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .metric-item {
        padding: 0.75rem 0.5rem;
    }

    .metric-item .metric-value {
        font-size: 1.1rem;
    }

    .metric-item .metric-label {
        font-size: 0.6rem;
    }

    /* ===== CHARTS ===== */
    .chart-container {
        min-height: auto;
    }

    .chart-wrapper {
        height: 200px !important;
    }

    /* ===== TIMELINE ===== */
    .timeline-legend {
        flex-wrap: wrap;
        gap: 0.75rem;
        font-size: 0.7rem;
    }

    .legend-item {
        gap: 0.35rem;
    }

    .timeline-scroll {
        padding: 1rem 0;
    }

    .timeline {
        min-width: 800px;
        height: 100px;
    }

    .timeline-hour {
        font-size: 0.6rem;
        width: 33px;
    }

    .timeline-track {
        height: 60px;
    }

    .timeline-flight {
        height: 18px;
        font-size: 0.6rem;
        padding: 0 0.35rem;
    }

    .timeline-flight i {
        font-size: 0.55rem;
    }

    /* ===== FLIGHT TABLE ===== */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .flight-table {
        min-width: 600px;
    }

    .flight-table th,
    .flight-table td {
        padding: 0.6rem 0.5rem;
        font-size: 0.75rem;
    }

    .flight-table th {
        font-size: 0.65rem;
    }

    .flight-table .time-cell {
        font-size: 0.8rem;
    }

    .flight-table .flight-cell {
        font-size: 0.8rem;
    }

    .tag {
        padding: 0.15rem 0.35rem;
        font-size: 0.6rem;
    }

    /* ===== ALERTS ===== */
    .alert-box {
        padding: 0.75rem;
        gap: 0.75rem;
        font-size: 0.8rem;
    }

    .alert-box i {
        font-size: 1rem;
    }

    /* ===== INTERNATIONAL STYLING ===== */
    .intl-route {
        font-size: 0.75rem;
    }

    .intl-badge {
        padding: 0.15rem 0.35rem;
        font-size: 0.6rem;
    }
}

/* ==================== SMALL MOBILE (< 480px) ==================== */
@media screen and (max-width: 480px) {

    /* Even more compact */
    .sidebar {
        padding: 0.75rem;
    }

    .brand {
        margin-bottom: 0.75rem;
    }

    .brand-logo {
        max-width: 20px;
    }

    .nav-section h3 {
        font-size: 0.6rem;
    }

    /* KPI cards - single scrollable row */
    .kpi-card.mini {
        padding: 0.6rem;
        min-height: 50px;
        min-width: 160px;
    }

    .kpi-icon {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .kpi-card .value {
        font-size: 1.15rem;
    }

    /* Top bar */
    .top-bar {
        height: 55px;
        padding: 0 0.75rem;
    }

    .page-title h2 {
        font-size: 0.8rem;
    }

    /* Dashboard */
    .dashboard-grid {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .grid-item {
        padding: 0.75rem;
    }

    .card-header h3 {
        font-size: 0.85rem;
    }

    /* Filters */
    .filter-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }

    /* Metrics */
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.35rem;
    }

    .metric-item .metric-value {
        font-size: 0.95rem;
    }

    .metric-item .metric-label {
        font-size: 0.55rem;
    }

    /* Charts */
    .chart-wrapper {
        height: 180px !important;
    }

    /* Timeline */
    .timeline {
        min-width: 600px;
        height: 80px;
    }

    .timeline-track {
        height: 50px;
    }

    .timeline-flight {
        height: 14px;
        font-size: 0.5rem;
    }

    /* Table */
    .flight-table {
        min-width: 500px;
    }

    .flight-table th,
    .flight-table td {
        padding: 0.5rem 0.35rem;
        font-size: 0.7rem;
    }
}

/* ==================== LANDSCAPE MOBILE ==================== */
@media screen and (max-width: 768px) and (orientation: landscape) {

    /* Adjust for landscape */
    .sidebar {
        max-height: 40vh;
        overflow-y: auto;
    }

    .kpi-card.mini {
        min-width: 180px;
    }

    .chart-wrapper {
        height: 180px !important;
    }
}

/* ==================== TOUCH IMPROVEMENTS ==================== */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .filter-btn,
    .chart-filter-btn {
        min-height: 40px;
        min-width: 40px;
    }

    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    /* Remove hover effects that don't work on touch */
    .kpi-card.mini:hover {
        transform: none;
    }

    .timeline-flight:hover {
        transform: none;
    }

    /* Add active states instead */
    .filter-btn:active,
    .btn-icon:active {
        opacity: 0.7;
        transform: scale(0.95);
    }

    .kpi-card.mini:active {
        transform: scale(0.98);
    }
}

/* ==================== SAFE AREA FOR NOTCHED PHONES ==================== */
@supports (padding: max(0px)) {
    @media screen and (max-width: 768px) {
        .sidebar {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
            padding-top: max(1rem, env(safe-area-inset-top));
        }

        .dashboard-grid {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }

        .top-bar {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .sidebar {
        display: none;
    }

    .main-content {
        width: 100%;
    }

    .dashboard-grid {
        display: block;
    }

    .grid-item {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
}