/* ===========================================
   MFB RDO Tracker - Responsive Design
   =========================================== */

/* ===========================================
   LARGE SCREENS (1200px and down)
   =========================================== */
@media (max-width: 1200px) {
    .truck-table {
        font-size: 0.85em;
    }
    
    .truck-table th,
    .truck-table td {
        padding: 8px 5px;
    }
    
    .summary-stats {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }
}

/* ===========================================
   TABLETS (768px and down)
   =========================================== */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .container {
        padding: 15px;
        border-radius: 10px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    /* Header controls repositioning */
    .header-controls, 
    .header-left-controls {
        position: static;
        justify-content: center;
        margin-bottom: 10px;
        flex-wrap: wrap;
    }
    
    /* Button sizing */
    .btn-control {
        font-size: 0.8em;
        padding: 6px 10px;
        height: 32px;
    }
    
    /* Statistics grid */
    .summary-stats {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-number {
        font-size: 1.4em;
    }
    
    /* Table adjustments */
    .truck-table {
        font-size: 0.75em;
    }
    
    .truck-table th,
    .truck-table td {
        padding: 6px 4px;
    }
    
    /* Form elements */
    .crew-inputs {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    
    .agencies-checkboxes {
        flex-direction: column;
        gap: 4px;
    }
    
    /* Station controls */
    .station-controls {
        flex-direction: column;
        gap: 5px;
    }
    
    .station-header {
        padding: 10px 15px;
        font-size: 1.1em;
    }
    
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}

/* ===========================================
   MOBILE PHONES (480px and down)
   =========================================== */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 10px;
        border-radius: 8px;
    }
    
    h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    /* Even smaller controls */
    .btn-control {
        font-size: 0.75em;
        padding: 5px 8px;
        height: 28px;
    }
    
    .btn-control.theme-toggle {
        width: 28px;
        padding: 5px 6px;
    }
    
    /* Compact statistics */
    .summary-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .stat-card {
        padding: 8px;
    }
    
    .stat-number {
        font-size: 1.2em;
    }
    
    .stat-label {
        font-size: 0.7em;
    }
    
    /* Very compact table */
    .truck-table {
        font-size: 0.7em;
    }
    
    .truck-table th,
    .truck-table td {
        padding: 4px 2px;
    }
    
    .truck-name {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .status-indicator {
        width: 8px;
        height: 8px;
        margin-right: 5px;
        margin-bottom: 2px;
    }
    
    /* Simplified crew inputs */
    .crew-inputs {
        grid-template-columns: 1fr;
        gap: 1px;
    }
    
    .crew-input {
        font-size: 0.65em;
        padding: 2px;
    }
    
    /* Stack agency checkboxes */
    .agencies-checkboxes {
        flex-direction: column;
        gap: 2px;
    }
    
    .agency-checkbox {
        font-size: 0.65em;
    }
    
    /* Station header adjustments */
    .station-header {
        padding: 8px 12px;
        font-size: 1em;
    }
    
    .station-controls {
        flex-direction: column;
        gap: 3px;
    }
    
    .station-section {
        margin-bottom: 20px;
    }
    
    /* Modal full screen on mobile */
    .modal-content {
        width: 98%;
        height: 90vh;
        margin: 5vh auto;
        padding: 12px;
    }
    
    .modal h2 {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    
    .modal input[type="text"] {
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ===========================================
   LANDSCAPE PHONE ORIENTATION
   =========================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .summary-stats {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .header-controls,
    .header-left-controls {
        flex-wrap: nowrap;
    }
    
    .btn-control {
        font-size: 0.75em;
        padding: 4px 8px;
    }
}

/* ===========================================
   HIGH DPI SCREENS
   =========================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .status-indicator {
        border: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .truck-table {
        border-collapse: separate;
        border-spacing: 0;
    }
    
    .truck-table th,
    .truck-table td {
        border-right: 1px solid var(--border-color);
    }
    
    .truck-table th:last-child,
    .truck-table td:last-child {
        border-right: none;
    }
}

/* ===========================================
   PRINT STYLES
   =========================================== */
@media print {
    body {
        background: white !important;
        color: black !important;
        padding: 0;
    }
    
    .container {
        background: white !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0;
    }
    
    .header-controls,
    .header-left-controls,
    .mode-indicator,
    .modal {
        display: none !important;
    }
    
    .summary-stats {
        break-inside: avoid;
    }
    
    .station-section {
        break-inside: avoid;
        margin-bottom: 20px;
    }
    
    .truck-table {
        break-inside: avoid;
    }
    
    .station-header {
        background: #333 !important;
        color: white !important;
    }
}