/* ===== THEME ROOT ===== */
:root[data-theme="dark"]{
    --bg:#111111;
    --panel:#1a1a1a;
    --text:#ffffff;
    --theme-mode-toggle-icon: #ffffff;
    --text-weak:#eeeeee;
    --muted:#aaaaaa;
    --hint:#888888;

    --accent:#ff0000;
    --gold:#ffd700;

    --surface:#161616;
    --surface-2:#0e0e0e;
    --card:#161616;
    --border:#242424;
    --border-weak:#333333;
    --border-strong:#222222;

    --inverse-text:#000000;
    --elev-shadow: rgba(0,0,0,.35);
}
:root[data-theme="light"]{
    --bg:#FAFAFA;
    --panel:#FFFFFF;
    --text: #111111;
    --theme-mode-toggle-icon: #000000;
    --text-weak: #222222;
    --muted:#555555;
    --hint:#666666;

    --accent:#D60000;
    --gold:#C9A300;

    --surface:#F5F5F5;
    --surface-2:#F0F0F0;
    --card:#FFFFFF;
    --border:#E5E5E5;
    --border-weak:#DDDDDD;
    --border-strong:#CCCCCC;

    --inverse-text:#ffffff;
    --elev-shadow: rgba(0,0,0,.10);
}

/* ===== GLOBAL DEFAULT (falls kein data-theme gesetzt) ===== */
:root{ color-scheme: light dark; }
html,body{
    height:100%;
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:system-ui,Segoe UI,Roboto,Arial,sans-serif
}

/* Blazor Fehler-Overlay: standardmäßig verstecken */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--panel);
    color: var(--text);
    border-top: 1px solid var(--border-weak);
    padding: .6rem 1.25rem;
    font-size: 14px;
    box-shadow: 0 -6px 16px var(--elev-shadow);
}
#blazor-error-ui a { color: var(--gold); text-decoration: underline; }
#blazor-error-ui .dismiss {
    position: absolute;
    right: .75rem;
    top: .45rem;
    cursor: pointer;
}

.app-shell{ min-height:100vh; }
.app-content{ min-height:100vh; }

/* ===== Theme-Toggle FAB ===== */
.theme-float{ position:fixed; top:14px; right:14px; z-index:40000; }
.theme-icon-btn{
    width:44px; height:44px; padding:0;
    background: transparent !important;
    border: none; border-radius:50%;
    box-shadow: none !important;
    cursor: pointer;
    -webkit-appearance: none; appearance: none;
}
.theme-icon-btn:hover,
.theme-icon-btn:active,
.theme-icon-btn:focus,
.theme-icon-btn:focus-visible{
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

/* ===== Login ===== */
.login-page{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
.login-card{
    width:100%; max-width:460px; background:var(--panel);
    border-radius:16px; padding:28px; box-shadow:0 10px 30px var(--elev-shadow);
}
.login-title{ text-align:center; margin:0 0 24px 0; line-height:1.1; color:var(--accent); }
.form-field{ margin-bottom:14px; position:relative; }
.input{
    width:100%; padding:12px 14px; border:1px solid var(--border);
    border-radius:8px;
    background:color-mix(in oklab, var(--panel) 90%, black 10%);
    color:var(--text); outline:none;
}
.input:focus{ border-color:var(--border-weak); }
.password-field .show-btn{
    position:absolute; right:8px; top:50%; transform:translateY(-50%);
    background:transparent; border:none; color:var(--muted); cursor:pointer; font-size:.9rem;
}
.login-btn{
    width:100%; padding:12px; background:var(--gold); color:var(--inverse-text);
    border:none; border-radius:10px; font-weight:700; cursor:pointer;
}
.login-btn:disabled{ opacity:.7; cursor:not-allowed; }
.error{ color:#ff6b6b; margin:6px 0 12px 0; font-size:.95rem; }
@media (min-width:768px){ .login-card{ padding:36px; } }

/* ===== Drei-Spalten-Layout ===== */
.three-column-layout { display: flex; flex-direction: row; height: calc(100vh - 60px); }
.left-column { width: 33%; padding: 10px; border-right: 1px solid var(--border-strong); overflow-y: auto; }
.right-column { width: 67%; padding: 10px; overflow-y: auto; }

/* ===== Bottom Toolbar ===== */
.bottom-toolbar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--surface-2);
    border-top: 1px solid var(--border-strong);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    z-index: 5;
}
.bottom-toolbar button {
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 16px;
}

/* ===== Allgemeiner FAB ===== */
.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text);
    font-size: 28px;
    border: none;
    cursor: pointer;
    z-index: 10;
}

/* ====== Shell / Layout ====== */
.app-shell {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    display: grid;
    grid-template-rows: 1fr 64px;
}

.content-area{
    overflow-y: auto;
    height: calc(100vh - 64px);
    -webkit-overflow-scrolling: touch;
}

/* ====== 1/3 – 2/3 Seiten-Split ====== */
.page-split {
    display: grid;
    grid-template-columns: 1fr 2fr;
    height: 100%;
}
.left-pane {
    border-right: 1px solid var(--border-strong);
    overflow: auto;
    padding: 12px;
}
.right-pane {
    overflow: auto;
    padding: 12px;
}

/* ====== Bottom Navigation Items ====== */
.bottom-item {
    text-decoration: none;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    height: 100%;
    justify-content: center;
    position: relative;
}
.bottom-item .material-icons { font-size: 24px; line-height: 24px; }
.bottom-item .label { display: none; font-size: 12px; }
.bottom-item.active,
.bottom-item.active:visited { color: var(--gold); font-weight: 600; }
.bottom-item.active .label { display: block; }
.bottom-item.active::after {
    content: "";
    position: absolute;
    top: 6px; bottom: 6px; left: 8px; right: 8px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--gold) 8%, transparent);
    pointer-events: none;
}
.bottom-item:hover { color: var(--text-weak); }

/* ====== Großer FAB rechts unten ====== */
.fab {
    position: fixed;
    right: 20px;
    bottom: 84px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--bg);
    border: none;
    cursor: pointer;
    z-index: 10;
    display: grid; place-items: center;
    box-shadow: 0 10px 30px var(--elev-shadow), 0 6px 10px rgba(0,0,0,0.4) inset;
    transition: transform .08s ease, box-shadow .08s ease, filter .08s ease;
}
.fab .material-icons { font-size: 28px; }
.fab:hover { filter: brightness(1.05); }
.fab:active { transform: translateY(1px); }

/* ====== Suche + Filter ====== */
.search-filter-bar {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 2;
    padding-bottom: 8px;
}
.search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    outline: none;
    margin-bottom: 8px;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }

/* ====== Kartenliste ====== */
.list-cards { margin-top: 6px; }
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
}
.card:hover { border-color: var(--border-weak); }
.card .title { color: var(--text); font-weight: 600; }
.card .sub   { color: var(--muted); font-size: 12px; }
.empty-hint  { color: var(--muted); font-size: 13px; padding: 8px; }

/* kleine Filterchips */
.filter-chip {
    background: var(--surface);
    border: 1px solid var(--border-weak);
    color: var(--text-weak);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}
.filter-chip.active {
    border-color: var(--gold);
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, transparent);
}

/* Karten größer + Grid-Inhalt */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    min-height: 90px;
    display: flex; align-items: stretch;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--border-weak); transform: translateY(-1px); }
.card-content { display: grid; grid-template-rows: auto auto 1fr; width: 100%; }
.card-content .title { color: var(--text); font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.card-content .sub { color: var(--muted); font-size: 13px; }
.card-content .time { color: var(--hint); font-size: 12px; justify-self: end; align-self: end; margin-top: 6px; }

/* ===== Admin Tabs ===== */
.admin-tabs {
    position: sticky; top: 0; background: var(--bg); z-index: 3;
    display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-strong);
}
.admin-tabs .tab {
    background: transparent; border: 1px solid var(--border-weak); color: var(--muted);
    padding: 8px 12px; border-radius: 12px; cursor: pointer;
}
.admin-tabs .tab:hover { color: var(--text-weak); border-color: var(--border-weak); }
.admin-tabs .tab.active {
    color: var(--gold); border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, transparent); font-weight: 600;
}
.admin-content { padding: 12px; }

.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.btn { background: var(--surface); border: 1px solid var(--border-weak); color: var(--text-weak); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.btn:hover { border-color: var(--border); }
.btn-primary { border-color: var(--gold); color: var(--gold); }
.btn-danger  { border-color: #ff4d4f; color: #ff4d4f; }

.admin-layout { background: var(--bg); min-height: 100vh; color: var(--text); }
.admin-content-area { height: 100vh; overflow: auto; }

/* --- Admin Tabs: volle Breite, gleichmäßig verteilt --- */
.tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    padding: 0; margin: 0;
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface-2);
    position: sticky; top: 0; z-index: 3;
}
.tab {
    appearance: none; background: transparent; border: none; color: var(--muted);
    padding: 14px 0; font-size: 15px; cursor: pointer; position: relative; text-align: center; width: 100%;
}
.tab:hover { color: var(--text-weak); }
.tab.active { color: var(--gold); font-weight: 600; }
.tab.active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
    background: var(--gold); border-radius: 3px 3px 0 0;
}

.admin-panel { padding: 12px; }
.list-cards { margin-top: 6px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; cursor: default; }
.card-content { display: grid; grid-template-rows: auto auto auto; width: 100%; }
.title { color: var(--text); font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Formulare */
.form { display: grid; gap: 12px; }
.field label { display:block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.input {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; padding: 10px 12px; width: 100%; box-sizing: border-box;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@media (max-width: 900px) { .row-2 { grid-template-columns: 1fr; } }

/* Fahrzeug-Tabs */
.vehicle-tabs {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-top: 8px;
}
.vehicle-tab {
    background: var(--surface); border: 1px solid var(--border-weak); color: var(--muted);
    padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.vehicle-tab.active {
    color: var(--gold); border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, transparent); font-weight: 600;
}

/* Matrix */
.matrix-toolbar { margin-top: 10px; margin-bottom: 6px; }
.matrix {
    border: 1px solid var(--border);
    border-radius: 10px;
}
.matrix-row {
    display: grid;
    grid-template-columns: 1.2fr repeat(var(--role-cols, 3), 1fr);
    border-bottom: 1px solid var(--border);
}
.matrix-row:last-child { border-bottom: none; }
.matrix-header {
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 6;
    box-shadow: 0 1px 0 var(--border-strong);
}
.matrix-cell {
    padding: 10px 12px;
    display: flex; align-items: center; justify-content: center;
}
.matrix-cell.name-col { justify-content: flex-start; }
.matrix-cell.head { font-weight: 600; color: var(--text-weak); }
.matrix input[type="checkbox"] { width: 18px; height: 18px; }

@media (max-width: 1100px) {
    .matrix-row { grid-template-columns: 1fr repeat(var(--role-cols, 3), 1fr); }
}

/* Fahrzeug-Tabs über volle Breite */
.tabs.tabs-vehicle {
    display: grid;
    grid-template-columns: repeat(var(--tab-count, 1), 1fr);
    width: 100%;
    padding: 0;
    margin: 8px 0 6px 0;
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface-2);
    position: static;
    top: auto;
    z-index: auto;
}
.tabs.tabs-vehicle .tab {
    appearance: none; background: transparent; border: none; color: var(--muted);
    padding: 12px 0; font-size: 14px; cursor: pointer; text-align: center; position: relative;
}
.tabs.tabs-vehicle .tab:hover { color: var(--text-weak); }
.tabs.tabs-vehicle .tab.active { color: var(--gold); font-weight: 600; }
.tabs.tabs-vehicle .tab.active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
    background: var(--gold); border-radius: 3px 3px 0 0;
}

/* Badge */
.badge{
    margin-left:8px;
    padding:2px 6px;
    border-radius:999px;
    border:1px solid var(--border-weak);
    font-size:11px;
    color:var(--gold);
    background:color-mix(in srgb, var(--gold) 8%, transparent);
}

/* Listen */
.crew-list { list-style: none; padding: 0; margin: 10px 0 0 0; }
.crew-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.crew-list li:last-child { border-bottom: none; }

/* Auswahlkarten (Detailbereich) */
.choose-type { height: 100%; display: grid; place-items: center; padding: 24px; }
.choose-grid {
    display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 16px; max-width: 980px; width: 100%;
}
.choose-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 180px; padding: 16px; border-radius: 16px; box-shadow: 0 4px 14px rgba(0,0,0,.08);
    background: var(--panel); text-align: center; border: none; cursor: pointer;
    transition: transform .08s ease, box-shadow .12s ease; color: var(--text);
}
.choose-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.12); }
.choose-card h3 { margin: 8px 0 6px; }
.choose-card p { margin: 0; opacity: .85; }

.check-grid { display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 8px 12px; }
.check-item { display: inline-flex; align-items: center; gap: 8px; }
.hint { opacity: .7; color: var(--muted); }

.detail-actions { display:flex; gap:8px; margin-bottom:12px; }

/* ===== Mitglieder-Detail: Teilnahme-Karten ===== */
.participation-grid{
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px; margin-top: 8px;
}
.card.mission-card, .card.exercise-card{
    background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
    transition: border-color .15s ease, transform .12s ease, box-shadow .12s ease;
}
.card.mission-card:hover, .card.exercise-card:hover{
    border-color: var(--border-weak); transform: translateY(-1px); box-shadow: 0 6px 18px var(--elev-shadow);
}
.card.mission-card .title, .card.exercise-card .title{ color: var(--text); font-weight: 700; font-size: 15px; }
.card.mission-card .sub, .card.exercise-card .sub{ color: var(--muted); font-size: 13px; margin-top: 2px; }
.card.mission-card .time, .card.exercise-card .time{
    color: var(--hint); font-size: 12px; justify-self: end; align-self: end; margin-top: 6px;
}

/* ===== Stats ===== */
.stats-root { padding: 12px; }
.stats-section { margin: 18px 0 8px; }
.stats-h { margin: 0 0 8px 0; font-size: 18px; color: var(--text-weak); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.kpi-title { color: var(--muted); font-size: 12px; }
.kpi-value { color: var(--text); font-weight: 700; font-size: 22px; margin-top: 6px; }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px,1fr)); gap: 12px; }
.chart-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.card-head { color: var(--text-weak); font-weight: 700; margin-bottom: 8px; }

.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: 1fr auto 64px; gap: 10px; align-items: center; }
.hbar-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; height: 12px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--gold); }
.hbar-val { color: var(--text-weak); text-align: right; font-variant-numeric: tabular-nums; }

.triple-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; }
.kv-k { color: var(--muted); }
.kv-v { color: var(--text); font-weight: 600; }
.big-text { font-size: 18px; font-weight: 700; color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
    display:inline-block; padding: 4px 10px; border-radius: 999px;
    background: color-mix(in srgb, var(--gold) 8%, transparent);
    border: 1px solid var(--gold);
    color: var(--gold); font-size: 12px;
}

.cards-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); }
.mini-list { margin: 0; padding-left: 18px; }
.mini-list li { color: var(--text); margin: 4px 0; }

/* <<< Mobile-Header standardmäßig aus >>> */
.mobile-detail-header { display: none; }

@media (max-width: 900px) {
    .page-split { grid-template-columns: 1fr; }
    .page-split.mobile-detail .right-pane { display: block; }
    .page-split.mobile-detail .left-pane { display: none; }
    .right-pane { display: none; }
    .page-split .left-pane { display: block; }

    .mobile-detail-header{
        position: sticky;
        top: 0;
        z-index: 5;
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 8px;
        align-items: center;
        padding: 10px 6px 10px 2px;
        background: var(--bg);
        border-bottom: 1px solid var(--border-strong);
    }
    .mobile-detail-header .icon-btn{
        display: inline-grid;
        place-items: center;
        width: 40px; height: 40px;
        border-radius: 10px;
        background: var(--surface);
        border: 1px solid var(--border-weak);
        color: var(--text-weak);
        cursor: pointer;
    }
    .mobile-detail-header .title{
        font-weight: 700; font-size: 16px; color: var(--text);
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    .choose-grid { grid-template-columns: 1fr; }
}

/* Pfeil immer rechts, Container volle Breite */
@media (max-width: 900px) {
    .filter-row-mobile{ width: 100%; display: flex; justify-content: flex-end; align-items: center; padding-right: 2px; margin: 6px 0; }
    .filter-toggle{ background: transparent; border: none; padding: 0; margin: 0; width: 28px; height: 28px; border-radius: 6px; display: inline-grid; place-items: center; cursor: pointer; }
    .filter-toggle:focus{ outline: none; }
    .filter-toggle .mi{ font-family: "Material Icons"; font-size: 20px; line-height: 20px; color: var(--muted); transition: transform .12s ease; }
    .filter-toggle.open .mi{ transform: rotate(180deg); }

    .filter-body.mobile-collapsible{ display: none; }
    .filter-body.mobile-collapsible.open{ display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
}

/* Desktop/Tablet */
@media (min-width: 901px) {
    .filter-row-mobile{ display: none; }
    .filter-body.mobile-collapsible{ display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
}

.filter-chip{ white-space: nowrap; display: inline-flex; align-items: center; }

/* Phone: Formular Vollbild */
@media (max-width: 900px) {
    .page-split.mobile-form .right-pane { display: block; }
    .page-split.mobile-form .left-pane  { display: none; }
}

/* === Ergänzungen (sichtbare Matrix im Formular, disabled Select klar erkennbar) === */
.form .tabs.tabs-vehicle,
.form .matrix { display:block; }
.form .matrix { margin-top:12px; }
select.input:disabled { opacity:.9; }
