/* TACSA VA — Airline theme: green livery, white, dark navy. Matches hero image (sunset, TACSA aircraft). */
:root, .theme-light {
    /* TACSA: green (livery/tail), navy (TACSA text), white, warm accent from sunset */
    --color-bg: #f0f4f8;
    --color-surface: #ffffff;
    --color-surface-alt: #f8fafc;
    --color-border: #cbd5e1;
    --color-text: #0f172a;
    --color-muted: #475569;
    --color-accent: #0d6b3c;
    --color-accent-hover: #0a552e;
    --color-accent-light: rgba(13, 107, 60, 0.12);
    --color-success: #15803d;
    --color-warning: #a16207;
    --color-error: #b91c1c;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-soft: 0 2px 8px rgba(0,0,0,0.04);
    --hero-overlay: rgba(255,255,255,0.85);
    --header-bg: #0d6b3c;
    --header-bg-bottom: #0a552e;
    --header-text: #ffffff;
    --header-muted: rgba(255,255,255,0.85);
}

.theme-dark {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-alt: #0f172a;
    --color-border: #334155;
    --color-text: #e2e8f0;
    --color-muted: #94a3b8;
    --color-accent: #22c55e;
    --color-accent-hover: #16a34a;
    --color-accent-light: rgba(34, 197, 94, 0.15);
    --color-success: #4ade80;
    --color-warning: #fbbf24;
    --color-error: #f87171;
    --shadow: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.2);
    --shadow-soft: 0 2px 12px rgba(0,0,0,0.15);
    --radius-lg: 14px;
    --hero-overlay: rgba(15,23,42,0.75);
    --header-bg: #0a552e;
    --header-bg-bottom: #064e2a;
    --header-text: #ffffff;
    --header-muted: rgba(255,255,255,0.9);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.65;
}
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 0 1.25rem; }
.container-wide { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }

/* Page shell — middle ground: contained but not boxy; soft lift, no hard border */
.layout .page-shell {
    max-width: 1160px;
    margin: 0 auto;
    background: var(--color-surface);
    box-shadow: var(--shadow-soft);
    border: none;
}
@media (min-width: 768px) {
    .layout .page-shell {
        margin: 1.25rem auto;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-md);
    }
}

/* Header + top bar */
.top-bar {
    background: var(--header-bg-bottom);
    color: var(--header-text);
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.top-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 1.25rem;
}
.top-bar-left, .top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.top-bar-user {
    opacity: 0.9;
}
.top-bar-link {
    color: var(--header-muted);
    font-size: 0.8rem;
}
.top-bar-link:hover {
    color: var(--header-text);
}

/* Main header — TACSA green, subtle depth */
.site-header {
    background: linear-gradient(180deg, var(--header-bg) 0%, var(--header-bg-bottom) 100%);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}
.logo {
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
    color: var(--header-text);
}
.logo:hover { text-decoration: none; color: var(--header-text); }
.nav-main { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.nav-main a {
    color: var(--header-muted);
    font-size: 0.95rem;
}
.nav-main a:hover { color: var(--header-text); }
.nav-utils { display: flex; align-items: center; gap: 0.5rem; }
.nav-utils .theme-btn, .nav-utils .lang-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: var(--header-text);
    cursor: pointer;
    text-decoration: none;
}
.nav-utils .theme-btn:hover, .nav-utils .lang-btn:hover {
    background: rgba(255,255,255,0.25);
    text-decoration: none;
}
.nav-utils .lang-btn.is-active {
    font-weight: 600;
    background: rgba(255,255,255,0.35);
    color: var(--header-text);
}

/* Main — more breathing room */
.site-main {
    min-height: 60vh;
    padding: 2.5rem 0 3rem;
}

/* Footer — soft strip */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 2rem 0;
    color: var(--color-muted);
    font-size: 0.875rem;
    background: var(--color-surface-alt);
}

/* Hero — with photo: overlay tuned for sunset/TACSA image; text readable over warm sky */
.hero-banner {
    position: relative;
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(135deg, var(--color-surface-alt) 0%, var(--color-border) 100%);
    background-size: cover;
    background-position: center;
}
.hero-banner.has-photo {
    min-height: 480px;
    background-image: var(--hero-bg);
    background-size: cover;
    background-position: center;
}
/* Overlay: darken bottom + slight warm tint so white text reads over sunset */
.hero-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--hero-overlay);
    pointer-events: none;
}
.hero-banner.has-photo::before {
    background: linear-gradient(to top, rgba(15,23,42,0.75) 0%, rgba(15,23,42,0.35) 40%, rgba(124,58,18,0.15) 100%);
}
.hero-banner .hero-inner {
    position: relative;
    z-index: 1;
    padding: 3rem 1.5rem;
    max-width: 40rem;
}
.hero-banner h1 {
    font-size: 2.35rem;
    margin: 0 0 0.5rem;
    color: var(--color-text);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.hero-banner .tagline {
    font-size: 1.2rem;
    color: var(--color-muted);
    margin-bottom: 2rem;
    text-shadow: 0 1px 1px rgba(0,0,0,0.05);
}
.hero-banner .ctas {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}
.hero-banner.has-photo h1,
.hero-banner.has-photo .tagline {
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
.hero-banner.has-photo .ctas .btn {
    background: var(--color-accent);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
}
.hero-banner.has-photo .ctas .btn:hover {
    background: var(--color-accent-hover);
    border-color: rgba(255,255,255,0.6);
    color: #fff;
}
.hero-banner.has-photo .ctas .btn-secondary {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.5);
    color: #fff;
}
.hero-banner.has-photo .ctas .btn-secondary:hover {
    background: rgba(255,255,255,0.3);
    color: #fff;
}
.theme-dark .hero-banner.has-photo h1,
.theme-dark .hero-banner.has-photo .tagline { color: #fff; }

/* Home sections — TACSA green accent */
.home-section {
    padding: 2.75rem 0;
}
.home-section h2 {
    font-size: 1.45rem;
    margin: 0 0 1.25rem;
    color: var(--color-text);
    padding-left: 1rem;
    border-left: 4px solid var(--color-accent);
}
.home-section p {
    margin: 0 0 0.75rem;
    color: var(--color-muted);
    max-width: 52rem;
    line-height: 1.7;
}

.home-section--intro {
    border-bottom: 1px solid var(--color-border);
}

.home-panels {
    display: grid;
    gap: 1.5rem;
    padding: 2rem 0 1.5rem;
}
@media (min-width: 768px) {
    .home-panels {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.home-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.75rem;
    box-shadow: var(--shadow-soft);
}
.home-panel h2 {
    border-left-color: var(--color-accent);
}
.home-section-body { display: block; }
.home-section.has-photo .home-section-body { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 640px) { .home-section.has-photo .home-section-body { grid-template-columns: 1fr 260px; } }
.home-photo { margin: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.home-photo img { width: 100%; height: auto; display: block; vertical-align: top; }

/* Forms */
label { display: block; margin-bottom: 0.25rem; color: var(--color-muted); font-size: 0.9rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
    width: 100%; max-width: 24rem; padding: 0.5rem 0.75rem; margin-bottom: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text); font: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-accent); }
button, .btn {
    display: inline-block;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--color-accent);
    color: #fff;
    font: inherit;
    cursor: pointer;
    font-weight: 500;
    box-shadow: var(--shadow);
}
button:hover, .btn:hover {
    background: var(--color-accent-hover);
    text-decoration: none;
    color: #fff;
}
.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
    border-color: var(--color-accent);
}

/* Messages */
.msg { padding: 0.75rem 1rem; margin-bottom: 1rem; border-radius: var(--radius); border: 1px solid; }
.msg.success { background: rgba(21,128,61,0.1); border-color: var(--color-success); }
.msg.error { background: rgba(185,28,28,0.1); border-color: var(--color-error); }
.msg.warning { background: rgba(161,98,7,0.1); border-color: var(--color-warning); }
.theme-dark .msg.success { background: rgba(74,222,128,0.15); }
.theme-dark .msg.error { background: rgba(248,113,113,0.15); }
.theme-dark .msg.warning { background: rgba(251,191,36,0.15); }

/* Legacy hero (simpler) */
.hero { text-align: center; padding: 2rem 0; }
.hero h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.hero p { color: var(--color-muted); margin-bottom: 1.5rem; }
.hero .btn { margin: 0 0.25rem; }

/* Cards — soft, not boxy */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-soft);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-muted); font-weight: 600; font-size: 0.9rem; }

/* Flight map */
.flight-profile-chart-wrap,
.stats-chart-wrap {
    position: relative;
    margin-top: 0.5rem;
}
.flight-profile-chart-wrap { height: 220px; }
.flight-profile-chart-wrap.flight-profile-chart-compact { height: 160px; }
.stats-chart-wrap { height: 200px; }
.stats-chart-wrap.stats-chart-pie { max-width: 280px; }
.table-wrap { overflow-x: auto; }
.track-points-table { font-size: 0.9rem; }
.track-points-table th, .track-points-table td { padding: 0.35rem 0.6rem; }
#dashboard-map {
    height: 360px;
    margin-top: 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
}
#flight-map {
    margin-top: 1rem;
    height: 320px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

/* Live map page */
.livemap-header {
    margin-bottom: 0.5rem;
}
.livemap-desc {
    color: var(--color-muted);
    font-size: 0.95rem;
    margin: 0.25rem 0 0.5rem;
}
.livemap-meta {
    font-size: 0.9rem;
    margin: 0.5rem 0;
}
.livemap-meta .btn {
    margin-left: 0.5rem;
}
.livemap-updated {
    margin-left: 0.5rem;
    color: var(--color-muted);
    font-size: 0.85rem;
    transition: opacity 0.3s;
}
.livemap-container {
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 400px;
    margin: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-alt);
}
.livemap-marker {
    background: none;
    border: none;
}
.livemap-marker-dot {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-accent);
    border: 2px solid var(--color-surface);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Two-column layout for pilot/admin areas */
.two-col {
    display: flex;
    gap: 1.5rem;
}
@media (max-width: 768px) {
    .two-col {
        flex-direction: column;
    }
}
.side-nav {
    flex: 0 0 190px;
    padding: 1.25rem 1rem;
    background: var(--color-surface-alt);
    border-right: 1px solid var(--color-border);
}
.side-nav-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
}
.side-nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.side-nav-menu a {
    font-size: 0.92rem;
    color: var(--color-text);
}
.side-nav-menu a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}
.content-main {
    flex: 1 1 auto;
}

/* App layout — full width with collapsible sidebar (pilot / admin) */
.layout-app .page-shell {
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}
.layout-app .site-main {
    padding: 0;
    min-height: 80vh;
}
.app-layout {
    display: flex;
    min-height: 80vh;
    width: 100%;
}
.app-sidebar {
    flex: 0 0 260px;
    width: 260px;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--color-surface-alt);
    border-right: 1px solid var(--color-border);
    transition: width 0.2s ease, flex 0.2s ease;
    overflow: hidden;
}
.app-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 1rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.app-sidebar-title {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease;
}
.app-sidebar-toggle {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-sidebar-toggle:hover {
    background: var(--color-accent-light);
    border-color: var(--color-accent);
    color: var(--color-accent);
}
.app-sidebar-menu {
    flex: 1;
    padding: 0.75rem 0.5rem;
    gap: 0.25rem;
}
.app-sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--color-text);
    transition: background 0.15s ease, color 0.15s ease;
}
.app-sidebar-menu a:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
    text-decoration: none;
}
.app-sidebar-menu a.active {
    background: var(--color-accent-light);
    color: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}
.app-sidebar-icon {
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
    font-size: 1.1rem;
}
.app-sidebar-label {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease;
}
.app-layout--collapsed .app-sidebar {
    flex: 0 0 56px;
    width: 56px;
}
.app-layout--collapsed .app-sidebar-header {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}
.app-layout--collapsed .app-sidebar-title,
.app-layout--collapsed .app-sidebar-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}
.app-layout--collapsed .app-sidebar-menu a {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}
.app-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1.5rem 2rem 2rem;
    overflow: auto;
}
.app-main .container {
    max-width: 1200px;
}

/* Admin: contact messages */
.contact-msg { margin-bottom: 0.5rem; }
.contact-msg.contact-unread { border-color: var(--color-accent); }

/* Utils */
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* Bootstrap overrides — keep TACSA theme; use BS grid only */
.app-main .container { max-width: 1200px; }
.app-main .card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 0;
    box-shadow: var(--shadow-soft);
}
.app-main .card h2 {
    font-size: 1.1rem;
    margin: 0 0 0.75rem;
    font-weight: 600;
    color: var(--color-text);
}
.app-main .card h2:not(:first-child) { margin-top: 0; }

/* Dashboard: compact chart grid — small, balanced */
.dashboard-charts .stats-chart-wrap { height: 100px; margin-top: 0.25rem; }
.dashboard-charts .stats-chart-wrap.stats-chart-pie {
    max-width: 100%;
    height: 100px;
    margin-left: auto;
    margin-right: auto;
}
.dashboard-charts .card { padding: 0.75rem 1rem; }
.dashboard-charts .card h2 { font-size: 0.8rem; margin-bottom: 0.35rem; }
#dashboard-map { height: 300px; }

/* Responsive tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.app-main table { margin-bottom: 0; }
.app-main .table-responsive table { margin-bottom: 0; }
.app-main .table th,
.app-main .table td { border-color: var(--color-border); color: inherit; }
.app-main .table thead th { color: var(--color-muted); font-weight: 600; }
.app-main .text-muted { color: var(--color-muted) !important; }
.app-main .btn-sm { padding: 0.35rem 0.75rem; font-size: 0.875rem; }
.app-main .gap-2 { gap: 0.5rem; }
.app-main .form-control,
.app-main .form-select {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius);
}
.app-main .form-control:focus,
.app-main .form-select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 0.2rem var(--color-accent-light);
}
.app-main .form-label { color: var(--color-muted); }
.app-main .table-borderless th,
.app-main .table-borderless td { border: none; }
.app-main .flight-info-table th { width: 40%; }
.app-main .flight-info-table td { padding-left: 0.5rem; }
.app-main .card.p-0 { padding: 0; }
.app-main .card-body { padding: 1rem 1.5rem; }
.app-main .border-bottom { border-color: var(--color-border) !important; }
.app-main .btn-group .btn { border-radius: 0; }
.app-main .btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.app-main .btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.app-main .btn-group .btn + .btn { margin-left: -1px; }
.app-main .chart-toggle .btn.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}
.app-main .chart-toggle .btn.active:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: #fff;
}
.app-main .chart-toggle.btn-group-sm .btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
