/* Leitstellen-taugliches, dunkles Layout */
:root {
    --sev-green: #2ecc71;
    --sev-yellow: #f1c40f;
    --sev-orange: #e67e22;
    --sev-red: #e74c3c;
    --panel-bg: #1b1f27;
    --header-bg: #12151c;
    --border: #2a2f3a;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: #0d0f14;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Kopfzeile */
.app-header {
    height: 56px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    z-index: 1200;
}

.brand-mark {
    font-weight: 700;
    letter-spacing: 1px;
    color: #fff;
}

.brand-sub {
    margin-left: .5rem;
    color: #8b93a3;
    font-size: .85rem;
}

.run-info { line-height: 1.15; }
.run-local { font-size: .9rem; font-weight: 600; }
.run-utc { font-size: .72rem; }

/* Ampel-Statusbalken */
.status-bar {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .75rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    border: 1px solid transparent;
}
.status-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: #888;
    box-shadow: 0 0 0 0 rgba(0,0,0,0);
}
.status-gruen { background: rgba(46,204,113,.12); color: #7ee2a8; border-color: rgba(46,204,113,.4); }
.status-gruen .status-dot { background: var(--sev-green); }
.status-rot { background: rgba(231,76,60,.15); color: #ff9a90; border-color: rgba(231,76,60,.5); }
.status-rot .status-dot { background: var(--sev-red); animation: pulse 1.2s infinite; }
.status-unknown { background: rgba(255,255,255,.06); color: #aab; border-color: var(--border); }

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(231,76,60,.6); }
    70%  { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
    100% { box-shadow: 0 0 0 0 rgba(231,76,60,0); }
}

/* Rumpf: Panel + Karte */
.app-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.side-panel {
    width: 340px;
    flex: 0 0 340px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-head {
    border-bottom: 1px solid var(--border);
    color: #dfe4ee;
}

.panel-legend {
    border-bottom: 1px solid var(--border);
    color: #9aa3b2;
}
.lg {
    display: inline-block;
    width: 11px; height: 11px;
    border-radius: 2px;
    margin: 0 .25rem 0 .6rem;
    vertical-align: -1px;
}
.lg-green { background: var(--sev-green); }
.lg-yellow { background: var(--sev-yellow); }
.lg-orange { background: var(--sev-orange); }
.lg-red { background: var(--sev-red); }

.cell-list {
    overflow-y: auto;
    flex: 1 1 auto;
}
.cell-item {
    padding: .55rem .75rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    gap: .6rem;
    align-items: flex-start;
}
.cell-item:hover { background: rgba(255,255,255,.04); }
.cell-item.affected { background: rgba(231,76,60,.10); }

.sev-chip {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700;
    color: #0d0f14;
}
.cell-main { min-width: 0; flex: 1 1 auto; }
.cell-title { font-size: .85rem; font-weight: 600; color: #e7ebf3; }
.cell-sub { font-size: .72rem; color: #97a0b0; }

.tags { margin-top: .2rem; display: flex; flex-wrap: wrap; gap: .25rem; }
.tag {
    font-size: .66rem;
    padding: .05rem .4rem;
    border-radius: 3px;
    font-weight: 600;
}
.tag-hail  { background: #3ba7d6; color: #04212e; }
.tag-gust  { background: #b58bd6; color: #1c0a29; }
.tag-rain  { background: #4d8fe0; color: #04182e; }
.tag-eta   { background: #e74c3c; color: #fff; }
.tag-meso  { background: #d64f9a; color: #fff; }
.tag-grow  { background: #e0a800; color: #241a00; }

.map-wrap { flex: 1 1 auto; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0d0f14; }

/* Verlauf-Zeitleiste */
.timeline {
    display: none; /* per JS eingeblendet */
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 1100;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    background: rgba(18, 21, 28, .95);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 4px 18px rgba(0,0,0,.5);
    width: min(560px, 82%);
}
.tl-btn {
    flex: 0 0 auto;
    background: transparent;
    color: #e7ebf3;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 30px; height: 30px;
    line-height: 1;
    cursor: pointer;
}
.tl-btn:hover { background: rgba(255,255,255,.08); }
.tl-slider { flex: 1 1 auto; accent-color: #4da3ff; cursor: pointer; }
.tl-time {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-size: .8rem;
    color: #cdd4e0;
    min-width: 118px;
    text-align: right;
}
#histBtn.active { background: #4da3ff; color: #0d0f14; border-color: #4da3ff; }

/* Prognose-Heatmap-Steuerung */
.fc-control {
    display: flex;
    align-items: center;
    gap: .25rem;
    background: rgba(18, 21, 28, .95);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .3rem .4rem;
    box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.fc-label { color: #cdd4e0; font-size: .78rem; margin: 0 .25rem 0 .15rem; }
.fc-btn {
    background: transparent;
    color: #e7ebf3;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: .12rem .45rem;
    font-size: .78rem;
    cursor: pointer;
}
.fc-btn:hover { background: rgba(255,255,255,.08); }
.fc-btn.active { background: #e0a800; color: #241a00; border-color: #e0a800; }

/* Popup dunkel */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: #1b1f27; color: #e7ebf3; border: 1px solid var(--border);
}
.leaflet-popup-content { margin: .6rem .8rem; font-size: .82rem; }
.popup-title { font-weight: 700; margin-bottom: .3rem; }
.popup-grid { display: grid; grid-template-columns: auto auto; gap: .1rem .8rem; }
.popup-grid .k { color: #97a0b0; }
.leaflet-container a.leaflet-popup-close-button { color: #97a0b0; }

/* Fadenkreuz */
.crosshair {
    color: #fff;
    font-size: 20px;
    text-shadow: 0 0 3px #000, 0 0 6px #000;
    line-height: 20px;
    text-align: center;
}

/* Einklapp-Button (☰) auf allen Größen sichtbar */
.panel-toggle { display: inline-flex; align-items: center; justify-content: center; }
/* Schließen-× und Abdunkelung nur mobil */
.panel-close,
.panel-backdrop { display: none; }

/* Desktop/Tablet: Leiste standardmäßig sichtbar, per .panel-hidden einklappbar */
@media (min-width: 821px) {
    .app.panel-hidden .side-panel { display: none; }
    #panelToggle.active { background: #4da3ff; color: #0d0f14; border-color: #4da3ff; }
}

/* ---------------- Mobil / Tablet ---------------- */
@media (max-width: 820px) {
    .app-header {
        gap: .5rem;
        padding: 0 .6rem;
        height: 52px;
        overflow: hidden;
    }
    .brand-sub { display: none; }
    .brand-mark { font-size: .95rem; }
    .run-utc { display: none; }
    .run-local { font-size: .74rem; }
    .run-info { line-height: 1.1; }
    .status-bar { min-width: 0; font-size: .76rem; padding: .2rem .55rem; }
    .status-bar #statusText {
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw;
    }
    /* Wandmonitor-Button auf Mobil ausblenden */
    .app-header a[href="kiosk.php"] { display: none; }

    .panel-toggle { display: inline-flex; align-items: center; justify-content: center; }

    /* Karte in Vollbreite, Panel als einblendbares Overlay */
    .app-body { position: relative; }
    .side-panel {
        position: absolute;
        top: 0; bottom: 0; left: 0;
        width: 88%;
        max-width: 340px;
        flex-basis: auto;
        z-index: 1500;
        transform: translateX(-102%);
        transition: transform .25s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .6);
    }
    .app.panel-shown .side-panel { transform: translateX(0); }

    .panel-close {
        display: inline-block;
        margin-left: .5rem;
        background: transparent;
        border: none;
        color: #cdd4e0;
        font-size: 1.5rem;
        line-height: 1;
        cursor: pointer;
        padding: 0 .2rem;
    }
    .panel-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 1450;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }
    .app.panel-shown .panel-backdrop { opacity: 1; pointer-events: auto; }

    /* Untere Bedienelemente etwas kompakter */
    .fc-control { padding: .25rem .3rem; }
    .fc-label { display: none; }
    .timeline { width: 94%; bottom: 12px; }
    .cell-item { padding: .7rem .75rem; } /* größere Touch-Ziele */
}

/* ---------------- Nur Smartphone ---------------- */
@media (max-width: 520px) {
    #refreshBtn, #histBtn { display: none; } /* Auto-Refresh läuft ohnehin */
    .run-info { display: none; }
    .status-bar #statusText { max-width: 52vw; }
}
