@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Overpass+Mono:wght@400;700&display=swap');

/* --- GLOBAL STYLES --- */
body { 
    font-family: 'Inter', sans-serif; 
    background-color: #f4f6f9; 
    color: #333; 
}

#flight-table-container table, #live-date, #live-clock, .font-monospace {
    font-family: 'Overpass Mono', monospace;
}

#flight-table-container table {
    line-height: 1em;
}

#live-date, #live-clock {
    color: #198754 !important;
    font-size: inherit;
    font-weight: 700;
}

.tracking-tight { letter-spacing: -0.5px; }

/* --- HEADER SECTION --- */
.flight-header {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-bottom: none; 
}

.logo-icon-wrapper {
    background: #1a1a1a;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.live-status-bar {
    display: flex;
    align-items: baseline; /* Forces characters to sit on the same line */
    letter-spacing: 0.5px;
    margin-top: 4px;
    color: #198754;
}

.live-status-bar span {
    display: inline-block;
    line-height: 1;
}

.status-indicator-dot {
    height: 6px;
    width: 6px;
    background-color: #198754;
    border-radius: 50%;
    margin-right: 8px;
    display: inline-block;
    animation: blinker 2s linear infinite;
}

@keyframes blinker { 50% { opacity: 0; } }

/* Header Controls */
.btn-control {
    background: #fff;
    border: 1px solid #dee2e6;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-group {
    background: #343a40; /* Dark grey background */
    padding: 4px;
    border-radius: 10px;
}

.btn-toggle {
    border: none;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 6px 16px;
    border-radius: 7px !important;
    color: #adb5bd; /* Light grey text for inactive state */
    transition: 0.2s;
}

.btn-toggle:hover {
    color: #fff;
}

.btn-toggle.active {
    background: #fff !important;
    color: #1a1a1a !important; /* High contrast dark text for active state */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-refresh {
    background: #fff;
    color: #198754;
    border: 1px solid #dee2e6;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-refresh-green {
    background: #198754;
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-refresh-green:hover {
    background: #157347;
    color: #fff;
}

.btn-refresh:hover {
    background: #f8f9fa;
}

/* --- TABLE SECTION (DESKTOP) --- */
.table-container {
    max-height: 75vh;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
    scroll-behavior: smooth;
    margin-bottom: 20px; 
    box-shadow: 0 .125rem .25rem rgba(0,0,0,.075) !important;
}

.table thead th {
    position: sticky;
    top: 0;
    background-color: #1a1a1a !important;
    color: #fff;
    z-index: 10;
    font-size: 0.65rem;
    padding: 8px 10px; /* Reduced from 10px to 6px */
    text-transform: uppercase;
}

.table td { 
    vertical-align: middle; 
    font-size: 0.82rem; 
    border-bottom: 1px solid #eee; 
    padding: 5px 10px; /* Reduced from 8px to 4px */
}

/* Target the destination/origin column specifically */
.table td:nth-child(4) {
    max-width: 180px; /* Limits the width */
    white-space: nowrap; /* Prevents text from wrapping to a second line */
    overflow: hidden; /* Hides the text that overflows */
    text-overflow: ellipsis; /* Adds the "..." */
}

/* Optional: Show full name on hover for desktop users */
.table td:nth-child(4):hover {
    overflow: visible;
    white-space: normal;
    background: #fff;
    position: relative;
    z-index: 5;
    cursor: help;
}

/* Updated Font Size for Aircraft Column */
.ac-cell {
    font-size: 0.75rem !important;
    font-weight: 400;
    color: #6c757d !important;
    
    /* Ellipsis Logic */
    max-width: 0;            /* Allows the cell to respect the percentage width */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Optional: Show full name on hover */
.ac-cell:hover {
    overflow: visible;
    white-space: normal;
    background: #fff;
    position: relative;
    z-index: 5;
    cursor: help;
}

.fn-cell { 
    background-color: #fcfcfc; 
    font-weight: 700; 
    border-left: 1px solid #eee; 
    border-right: 1px solid #eee; 
}

/* .current-row { background-color: #f2f6ff !important; } */

/* --- STATUS INDICATORS & ANIMATIONS --- */
.status-dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; margin-right: 10px; vertical-align: middle; }
.dot-pulse-red { background-color: #dc3545; animation: pulse-red 1.5s infinite; }
.dot-pulse-blue { background-color: #0d6efd; animation: pulse-blue 1.5s infinite; }
.dot-static-blue { background-color: #0d6efd; }

@keyframes pulse-red { 0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); } 70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(220, 53, 69, 0); } 100% { transform: scale(0.9); } }
@keyframes pulse-blue { 0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.7); } 70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(13, 110, 253, 0); } 100% { transform: scale(0.9); } }
@keyframes spinner-border { to { transform: rotate(360deg); } }

.bi-spin { display: inline-block; animation: spinner-border .75s linear infinite; }

/* Status Text Colors */
.status-ONT { color: inherit; font-weight: bold; }
.status-LAN, .status-ARR, .status-DEP { color: #198754 !important; font-weight: bold; }
.status-NBD, .status-GTG { color: #0d6efd !important; font-weight: bold; }
.status-LAC { color: #dc3545 !important; font-weight: bold; animation: text-blink 1.2s linear infinite; }
.status-DLY, .status-DLY-orange { color: #fd7e14 !important; font-weight: bold; }
.status-GTC { color: #2a2a2a !important; font-weight: bold; }

/* Destination Success Color - Brought Back */
.text-success-city { color: #198754 !important; font-weight: 700; }

@keyframes text-blink { 50% { opacity: 0.4; } }

/* --- MISC UI ELEMENTS --- */
.offset-text { 
    font-family: 'Inter', sans-serif !important;
    font-weight: 400 !important; 
    font-size: 0.68rem; 
    margin-left: 5px; 
}
.offset-early, .offset-late-low { color: #198754; }
.offset-late-mid { color: #fd7e14; }
.offset-late-high { color: #dc3545; }

.gate-box { background-color: #f2f2f2; padding: 2px 6px; border-radius: 2px; border: 1px solid #ddd; font-weight: 700; display: inline-block; font-size: 0.75rem; }

/* --- RESPONSIVE MOBILE VIEW --- */
@media (max-width: 768px) {

    /* Hide Table Headers on Mobile */
    .table thead { display: none; }
    
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    .flight-header { padding: 1rem; }
    .header-controls { width: 100%; justify-content: space-between; margin-top: 10px; }
    .btn-group { flex-grow: 1; }
    .btn-toggle { flex-grow: 1; font-size: 0.7rem; }
    .table-container { max-height: none; border: none; background: transparent; box-shadow: none !important; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { margin-bottom: 1rem; border: 1px solid #dee2e6; border-radius: 12px; background: #fff; padding: 12px; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
    .table td { border: none; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; }
    .table td::before { content: attr(data-label); font-weight: 600; font-size: 0.7rem; color: #6c757d; text-transform: uppercase; }
}

/* Instructional Notice Bar */
.refresh-notice-bar {
    background-color: #e9ecef; /* Light grey to stay neutral */
    color: #495057;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.75rem;
    border-left: 4px solid #198754; /* Green accent to point to the refresh button color */
}

.refresh-notice-bar i {
    color: #198754;
    font-size: 0.9rem;
}

/* Ensure the header doesn't have a bottom margin so the bar sits close to it */
.flight-header {
    margin-bottom: 0 !important;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.flight-header h1 {
    font-size: 24px !important;
}

/* Connect the notice bar to the header visually */
.refresh-notice-bar {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0 !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

/* Fix for the @ alignment */
.symbol-align {
    display: inline-flex;
    align-self: center;
    line-height: 1;
    position: relative;
    top: -1px; /* Precision nudge for the Overpass Mono font */
}

/* Ensure only the active button has the white background */
.toggle-container button.active {
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Base style for the buttons when they are not active */
.toggle-container button {
    background-color: transparent;
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

@media (max-width: 768px) {
    /* Reset Table */
    #flight-table-container table,
    #flight-table-container thead,
    #flight-table-container tbody,
    #flight-table-container tr,
    #flight-table-container td {
        display: block;
    }
    #flight-table-container thead { display: none; }
    #flight-table-container td::before { content: none !important; }

    /* The Row Grid */
    #flight-table-container tr.mobile-row {
        display: grid;
        grid-template-columns: 75px 1fr 100px; 
        grid-template-rows: auto auto;
        gap: 2px 12px;
        padding: 12px 10px;
        border-bottom: 1px solid #eee;
        background: #fff;
    }

    #flight-table-container td { padding: 0 !important; border: none !important; }

    /* Column 1: Time (Tall) */
    #flight-table-container td:nth-child(1) { 
        grid-column: 1; grid-row: 1 / span 2; 
        font-size: 1.2rem; font-weight: 700; align-self: center;
    }

    /* Column 2: Destination & Flight + Aircraft */
    #flight-table-container td:nth-child(4) { /* Destination */
        grid-column: 2; 
        grid-row: 1; 
        font-weight: 600; 
        font-size: 1.05rem;
        
        /* THE FIX: Add padding and adjust line height */
        padding-top: 4px !important; 
        line-height: 1.2;
        overflow: visible !important;
    }
    #flight-table-container td:nth-child(5) { /* Flight + AC */
        margin-top: -2px; grid-column: 2; grid-row: 2; font-size: 0.95rem; color: #198754; font-weight: 600;
    }

    /* Aircraft Code Styling */
    .mobile-ac-inline {
        color: #888;
        font-weight: 400;
        font-size: 0.85rem;
        margin-left: 4px;
    }
    .mobile-ac-inline::before {
        content: "•";
        margin-right: 6px;
        color: #ccc;
    }

    /* Column 3: Status & Gate */
    #flight-table-container td:nth-child(8) { /* Status */
        grid-column: 3; grid-row: 1; text-align: right; font-weight: 700; font-size: 0.85rem;
    }
    #flight-table-container td:nth-child(7) { /* Gate */
        grid-column: 3; grid-row: 2; text-align: right; font-size: 0.85rem;
    }

    /* Hide redundant cells */
    #flight-table-container td:nth-child(2), 
    #flight-table-container td:nth-child(3), 
    #flight-table-container td:nth-child(6) {
        display: none !important;
    }
}

/* Hide the inline AC code on desktop */
@media (min-width: 769px) {
    .mobile-ac-inline { display: none; }
}