/* ===========================================================
   Alarmboard – minimalistisches Design
   Idee: Ruhiges, dunkles Board für den Dauerbetrieb an der Wand.
   Signalrot ist reserviert für den Alarmzustand – dadurch sticht
   der Alarm wirklich heraus, statt dass Rot überall Deko ist.
   =========================================================== */

:root {
    --bg:        #14171c;   /* Board-Hintergrund, tiefes Anthrazit */
    --surface:   #1d2128;   /* Karten/Flächen */
    --surface-2: #262b34;   /* hervorgehoben */
    --line:      #333a45;   /* Trennlinien */
    --text:      #eef1f5;   /* Haupttext */
    --text-dim:  #9aa3b1;   /* Sekundärtext */
    --accent:    #3b82f6;   /* Bedienakzent (Blau, ruhig) */
    --signal:    #e11d2a;   /* Signalrot – nur Alarm */
    --signal-2:  #ff3b48;
    --ok:        #22c55e;
    --warn:      #f59e0b;
    --radius:    10px;
    --font:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono:      ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1.1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; }
.topbar__mark {
    width: 14px; height: 14px; border-radius: 3px;
    background: var(--signal);
    box-shadow: 0 0 0 3px rgba(225,29,42,.18);
}
.topbar__nav { display: flex; align-items: center; gap: 1.1rem; font-size: .95rem; }
.topbar__nav a { color: var(--text-dim); }
.topbar__nav a:hover { color: var(--text); text-decoration: none; }
.topbar__user { color: var(--text); font-weight: 550; }
.topbar__logout { color: var(--text-dim); }

.main { display: block; }

/* ---------- Login ---------- */
.screen-login { display: grid; place-items: center; }
.login { width: 100%; display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login__card {
    width: 100%; max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem 1.6rem;
    text-align: center;
}
.login__mark {
    display: inline-block; width: 38px; height: 38px; border-radius: 8px;
    background: var(--signal); margin-bottom: .8rem;
    box-shadow: 0 0 0 5px rgba(225,29,42,.15);
}
.login__title { font-size: 1.3rem; }
.login__sub { color: var(--text-dim); margin: 0 0 1.4rem; font-size: .92rem; }
.login__form { display: grid; gap: .9rem; text-align: left; }
.login__form label { display: grid; gap: .3rem; font-size: .85rem; color: var(--text-dim); }
.login__error {
    background: rgba(225,29,42,.12);
    border: 1px solid rgba(225,29,42,.4);
    color: #ffb8bd;
    padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem;
}

/* ---------- Formularelemente ---------- */
input[type=text], input[type=password], input[type=number],
input[type=datetime-local], input[type=file], textarea, select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 8px;
    padding: .55rem .65rem;
    font: inherit;
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}
textarea { resize: vertical; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: .4rem;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .5rem .9rem;
    font: inherit; font-weight: 550;
    cursor: pointer;
}
.btn:hover { background: #2e3540; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #2f6fe0; }
.btn--danger { background: transparent; border-color: rgba(225,29,42,.5); color: #ff8a92; }
.btn--danger:hover { background: rgba(225,29,42,.12); }
.btn--alarm { background: var(--signal); border-color: var(--signal); color: #fff; font-weight: 650; }
.btn--alarm:hover { background: var(--signal-2); }
.btn--block { width: 100%; }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ===========================================================
   DASHBOARD
   =========================================================== */
.dash {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 53px);
}

/* Fahrzeuge links */
.dash__vehicles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-rows: min-content;
    gap: .8rem;
    overflow-y: auto;
    align-content: start;
}
.vehicle {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.vehicle__img {
    aspect-ratio: 16 / 10;
    background-size: cover;
    background-position: center;
    background-color: var(--surface-2);
}
.vehicle__placeholder {
    aspect-ratio: 16 / 10;
    display: grid;
    place-items: center;
    background:
        repeating-linear-gradient(45deg, #20252e 0 12px, #1b1f27 12px 24px);
}
.vehicle__short {
    font-family: var(--mono);
    font-size: clamp(2rem, 6vw, 3.4rem);
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--text);
}
.vehicle__callsign {
    padding: .5rem .7rem;
    font-size: .9rem;
    color: var(--text-dim);
    border-top: 1px solid var(--line);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vehicle--empty {
    grid-column: 1 / -1;
    padding: 2rem; text-align: center; color: var(--text-dim);
}

/* Rechte Spalte */
.dash__side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}
.clock {
    font-family: var(--mono);
    font-size: clamp(3.5rem, 11vw, 8rem);
    font-weight: 700;
    line-height: 1;
    text-align: center;
    letter-spacing: -0.02em;
    margin-top: .5rem;
}
.clock__sec { color: var(--text-dim); font-size: .5em; }
.clock__date {
    text-align: center;
    color: var(--text-dim);
    font-size: 1.1rem;
    margin-top: -.3rem;
}

.warnblock, .infoblock {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .9rem 1rem;
}
.warnblock__title, .infoblock__title {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-dim); margin-bottom: .6rem;
}
.warn {
    border-left: 4px solid var(--warn);
    padding: .35rem 0 .35rem .7rem;
    margin-bottom: .5rem;
}
.warn:last-child { margin-bottom: 0; }
.warn__event { font-weight: 600; }
.warn__head { color: var(--text-dim); font-size: .9rem; }
.info { padding: .35rem 0; border-bottom: 1px solid var(--line); }
.info:last-child { border-bottom: none; }
.info__title { font-weight: 600; }
.info__body { color: var(--text-dim); font-size: .92rem; }

/* ===========================================================
   ALARM-ANSICHT (Vollbild-Overlay)
   =========================================================== */
.alarm {
    position: fixed; inset: 0; z-index: 1000;
    background: #0b0d10;
    display: flex; flex-direction: column;
    animation: alarmPulse 1.1s ease-in-out infinite;
}
@keyframes alarmPulse {
    0%, 100% { box-shadow: inset 0 0 0 0 rgba(225,29,42,0); }
    50%      { box-shadow: inset 0 0 0 12px rgba(225,29,42,.55); }
}
@media (prefers-reduced-motion: reduce) {
    .alarm { animation: none; box-shadow: inset 0 0 0 8px var(--signal); }
}
.alarm__inner {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 1.6fr) minmax(0, 1.4fr);
    gap: 1px;
    background: var(--line);
    min-height: 0;
}
.alarm__vehicles, .alarm__center, .alarm__map { background: #0b0d10; padding: 1.4rem; }
.alarm__vehicles { overflow-y: auto; }
.alarm__veh {
    background: var(--surface);
    border-left: 4px solid var(--signal);
    border-radius: 8px;
    padding: .8rem 1rem;
    margin-bottom: .7rem;
}
.alarm__veh-short { font-family: var(--mono); font-size: 1.8rem; font-weight: 700; }
.alarm__veh-call { color: var(--text-dim); font-size: .9rem; }

.alarm__center {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
}
.alarm__keyword {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 750;
    color: var(--signal-2);
    line-height: 1.05;
    text-transform: uppercase;
    letter-spacing: -0.01em;
}
.alarm__address {
    font-size: clamp(1.3rem, 2.6vw, 2.2rem);
    margin-top: 1rem;
}
.alarm__notes {
    color: var(--text-dim);
    margin-top: 1rem;
    font-size: 1.1rem;
    max-width: 40ch;
}
.alarm__map { padding: 0; }
.alarm__map .leaflet-container { width: 100%; height: 100%; background: #0b0d10; }

.alarm__footer {
    display: flex; align-items: center; justify-content: center;
    gap: 2.5rem;
    padding: 1rem;
    background: var(--signal);
    color: #fff;
}
.alarm__time { font-family: var(--mono); font-size: 2.4rem; font-weight: 700; line-height: 1; }
.alarm__elapsed { font-size: 1.3rem; }
.alarm__elapsed span { font-family: var(--mono); font-weight: 700; }

/* ===========================================================
   BEDIEN-DASHBOARD
   =========================================================== */
.control { padding: 1.2rem; max-width: 1100px; margin: 0 auto; }
.control__tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.tab {
    background: none; border: none; color: var(--text-dim);
    padding: .7rem 1.1rem; font: inherit; font-weight: 550; cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab--active { color: var(--text); border-bottom-color: var(--accent); }

.panel { display: none; }
.panel--active { display: block; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .9rem; }
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
}
.card--active { border-color: var(--signal); }
.card__title { font-weight: 650; font-size: 1.05rem; }
.card__meta { color: var(--text-dim); font-size: .9rem; margin: .25rem 0 .7rem; }
.card__tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; }
.tag {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; color: var(--text-dim);
}
.card__actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge {
    display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    padding: .12rem .5rem; border-radius: 999px; font-weight: 650;
}
.badge--planned { background: rgba(59,130,246,.15); color: #93c5fd; }
.badge--active  { background: rgba(225,29,42,.18); color: #ff9aa1; }

/* ---------- Dialog ---------- */
.dialog {
    width: min(560px, 92vw);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 1.4rem;
}
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog form { display: grid; gap: .8rem; }
.dialog label { display: grid; gap: .3rem; font-size: .85rem; color: var(--text-dim); }
.dialog .row { display: flex; gap: .6rem; }
.dialog .row > * { flex: 1; }
.dialog .row .btn { flex: 0 0 auto; align-self: end; }
.fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; }
.fieldset legend { color: var(--text-dim); font-size: .85rem; padding: 0 .4rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: .4rem; }
.checks label, .checkbox { display: flex; align-items: center; gap: .4rem; color: var(--text); font-size: .9rem; }
.checks input, .checkbox input { width: auto; }
.dialog__actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .4rem; }

.toast {
    position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--text); padding: .7rem 1.1rem; border-radius: 8px;
    z-index: 2000; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast--error { border-color: rgba(225,29,42,.5); color: #ffb8bd; }

/* ---------- Responsiv ---------- */
@media (max-width: 860px) {
    .dash { grid-template-columns: 1fr; height: auto; }
    .alarm__inner { grid-template-columns: 1fr; }
    .alarm__map { min-height: 240px; }
}
