:root {
    --bg-color: #121212;
    --surface-color: #1E1E1E;
    --primary-color: #F59E0B;
    /* Orange */
    --accent-color: #FCD34D;
    /* Yellow */
    --text-primary: #ffffff;
    --text-secondary: #E5E5E5;
    /* High contrast grey */
    --border-color: #333333;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --font-family: 'Inter', sans-serif;
    --glass-bg: rgba(30, 30, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: transform 2s ease-in-out;
    /* Smooth pixel shifting */
    will-change: transform;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.logo svg {
    color: var(--text-primary);
}

.current-time {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.search-section {
    text-align: center;
    margin-bottom: 2rem;
}

.search-section h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-bar {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

#airportInput {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 99px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    text-transform: uppercase;
}

#airportInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

#searchBtn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

#searchBtn:hover {
    background-color: #2563EB;
}

.error-message {
    color: var(--danger-color);
    margin-top: 10px;
    min-height: 24px;
    font-size: 0.9rem;
}

/* Results Section */
.results-section {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease;
}

.results-section.hidden {
    display: none;
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.3s;
    position: relative;
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -0.6rem;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary-color);
}

.flight-list-header {
    display: grid;
    grid-template-columns: 0.8fr 1fr 1.5fr 1fr 0.5fr;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.flight-item {
    display: grid;
    grid-template-columns: 0.8fr 1fr 1.5fr 1fr 0.5fr;
    padding: 1rem;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.flight-item:last-child {
    border-bottom: none;
}

.flight-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Columns */
.col-time {
    font-weight: 600;
    color: var(--text-primary);
}

.col-flight {
    color: var(--accent-color);
    font-weight: 500;
}

.col-dest {
    color: var(--text-secondary);
}

.col-gate {
    text-align: right;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-on-time {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

.status-delayed {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-color);
}

.status-canceled {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
}

.status-boarding {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .flight-list-header {
        display: none;
    }

    .flight-item {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "time gate"
            "dest dest"
            "flight status";
        gap: 0.5rem;
        background: rgba(255, 255, 255, 0.02);
        margin-bottom: 10px;
        border-radius: 8px;
        border: none;
    }

    .col-time {
        grid-area: time;
        font-size: 1.1rem;
    }

    .col-gate {
        grid-area: gate;
    }

    .col-dest {
        grid-area: dest;
        color: var(--text-primary);
        font-size: 1rem;
    }

    .col-flight {
        grid-area: flight;
    }

    .col-status {
        grid-area: status;
        text-align: right;
    }
}

/* Kiosk Mode / Split View Styles */
body.kiosk-mode .search-section,
body.kiosk-mode .tabs {
    display: none !important;
    /* Force hide */
}

body.kiosk-mode main {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    max-width: 100%;
}

body.kiosk-mode .results-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-top: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border: none;
}

body.kiosk-mode .list-wrapper {
    height: 50%;
    display: flex !important;
    /* Force show both */
    flex-direction: column;
    padding: 1rem 2rem;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.kiosk-mode .flight-list {
    flex: 1;
    overflow-y: auto;
    /* Hide scrollbar but allow scroll */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

body.kiosk-mode .flight-list::-webkit-scrollbar {
    display: none;
}

/* Kiosk Titles */
.kiosk-title {
    display: none;
    /* Hidden by default */
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body.kiosk-mode .kiosk-title {
    display: block;
}

/* Visibility Utility */
.hidden {
    display: none !important;
}

/* Ensure wrappers take full height in normal mode when active */
.list-wrapper {
    display: block;
}

.list-wrapper.hidden {
    display: none;
}


/* Mobile & PWA Optimizations */

/* Safe Area Insets for modern mobile devices */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Larger Touch Targets */
.tab-btn {
    padding: 12px 20px;
    /* Bigger touch area */
}

#searchBtn {
    width: 48px;
    height: 48px;
    /* Easier to tap */
}

/* Mobile Card Layout Adjustments */
@media (max-width: 600px) {
    .app-container {
        padding: 10px;
    }

    .flight-item {
        padding: 1.25rem;
        /* More breathing room */
    }

    .col-time {
        font-size: 1.2rem;
        /* Easier to read time */
    }

    .status-badge {
        padding: 0.4rem 0.8rem;
    }

    /* Stack wrappers in kiosk mode on very small screens? No, keep split. */

    /* Better spacing for search */
    .search-section h1 {
        font-size: 1.5rem;
    }

    #airportInput {
        font-size: 1.1rem;
        /* Prevent auto-zoom on iOS */
    }
}


/* Ultra-Compact Kiosk Styles */
body.kiosk-mode .app-container {
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

body.kiosk-mode main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll */
}

body.kiosk-mode .results-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

body.kiosk-mode .list-wrapper {
    flex: 1;
    /* Both wrappers take equal available space */
    min-height: 0;
    /* Crucial for nested flex scrolling */
    display: flex !important;
    flex-direction: column;
    padding: 0.2rem 0.5rem;
    height: auto;
}

body.kiosk-mode .flight-list {
    flex: 1;
    overflow-y: auto;
    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Compact Center Clock */
body.kiosk-mode .center-clock {
    display: block;
    flex: 0 0 auto;
    /* Natural height, don't grow/shrink */
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 0.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Header & Item Styles */
body.kiosk-mode .flight-list-header {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    opacity: 0.8;
    flex: 0 0 auto;
}

body.kiosk-mode .flight-item {
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.kiosk-mode .col-time {
    font-size: 0.95rem;
}

body.kiosk-mode .kiosk-title {
    font-size: 1rem;
    margin-bottom: 0.2rem;
    padding-left: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding-top: 5px;
    padding-bottom: 5px;
    flex: 0 0 auto;
}

#centerTime {
    font-size: 1.5rem;
    font-weight: 700;
}

body.kiosk-mode .app-header {
    display: none;
}