/* Trainingsplaner — Basis-Styles (Phase 1.1 Gerüst) */

:root {
    --bg: #0f1620;
    --surface: #1a2433;
    --surface-2: #243044;
    --text: #e8edf4;
    --muted: #94a3b8;
    --primary: #2f9e44;
    --primary-hover: #37b24d;
    --danger: #e03131;
    --border: #2c3a4f;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Manrope', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* Sicherheitsnetz: kein horizontaler Seiten-Overflow → fixed-Modals bleiben zentriert (Mobile) */
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ── Auth ──────────────────────────────────────────────── */
#authScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.brand {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-align: center;
}
.brand-sub {
    margin: 4px 0 24px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.auth-form h2 { margin: 0 0 16px; font-size: 20px; }

.auth-form label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    margin-top: 6px;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}
input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
    width: auto;
    padding: 8px 14px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); }

.auth-switch {
    margin: 16px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}
.auth-switch a { color: var(--primary); text-decoration: none; }

.form-error {
    background: rgba(224, 49, 49, 0.12);
    border: 1px solid var(--danger);
    color: #ffa8a8;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 14px;
}

.build-badge { font-size: 12px; color: var(--muted); }

/* ── App ───────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Umbruch erlauben: auf schmalen Screens dürfen die rechten Bedienelemente in eine
       zweite Zeile rutschen, statt über den Rand hinaus (Abmelden sonst nicht klickbar). */
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.app-logo { font-weight: 800; font-size: 18px; }
.app-header-right { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.user-badge { font-size: 14px; color: var(--muted); }

.app-main { padding: 32px 24px; max-width: 900px; margin: 0 auto; }

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab-btn {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--primary); }

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.tab-header h2 { margin: 0; font-size: 20px; }
.readonly-hint { color: var(--muted); font-size: 13px; }

/* ── Tabelle ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; } /* breite Tabellen scrollen intern statt die Seite zu verbreitern */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
/* Zebra-Streifen: jede zweite Zeile leicht abgesetzt → bessere Lesbarkeit. */
.data-table tbody tr:nth-child(even) { background: var(--surface-2); }
.data-table tbody tr:hover { background: var(--border); }
.empty-hint { color: var(--muted); padding: 24px 0; text-align: center; }

/* ── Zeitfenster-Matrix (Mo–Fr je Platz in einer Zeile) ── */
.tab-controls { margin-bottom: 14px; }
.tab-controls .field { max-width: 220px; }
.matrix-table td, .matrix-table th { text-align: center; vertical-align: top; }
.matrix-table th.matrix-ort,
.matrix-table th.matrix-ecke { text-align: left; }
.matrix-table th.matrix-ort {
    font-weight: 600; font-size: 13px; text-transform: none; letter-spacing: 0;
    color: var(--text); white-space: nowrap;
}
.matrix-table th.matrix-tag { min-width: 78px; }
.matrix-zelle { white-space: nowrap; }
.matrix-zeit {
    display: block;
    margin: 0 auto 4px;
    padding: 3px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}
button.matrix-zeit { cursor: pointer; }
button.matrix-zeit:hover { border-color: var(--primary); }
.matrix-leer { color: var(--muted); }
.matrix-add {
    display: inline-block;
    padding: 1px 8px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
    font-family: inherit;
    cursor: pointer;
}
.matrix-add:hover { border-color: var(--primary); color: var(--text); }
.matrix-fussnote { margin-top: 10px; font-size: 12px; }

/* ── Toast (kurze Erfolgsmeldung) ──────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 12px 20px;
    background: var(--surface-2);
    border: 1px solid var(--primary);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.color-chip {
    display: inline-block;
    width: 20px; height: 20px;
    border-radius: 5px;
    border: 1px solid var(--border);
    vertical-align: middle;
}
.role-select {
    width: auto;
    padding: 6px 8px;
    margin: 0;
    font-size: 13px;
}

.row-actions { white-space: nowrap; text-align: right; }
.btn-mini {
    padding: 5px 10px;
    margin-left: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}
.btn-mini:hover { border-color: var(--primary); }
.btn-mini.danger:hover { border-color: var(--danger); color: #ffa8a8; }
.btn-sm { width: auto; padding: 8px 14px; font-size: 14px; }
.btn-danger { background: var(--danger); color: #fff; }

/* ── Modal + Formular ──────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-card h3 { margin: 0 0 16px; }
.modal-confirm { max-width: 380px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid .field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.form-grid .field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.form-grid input[type="checkbox"] { width: auto; }
.form-grid input[type="color"] { width: 60px; height: 38px; padding: 2px; }
.form-grid select {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { width: auto; flex: 1; }

/* ===================================================================
   Phase 1.3 — Plan-Raster
   =================================================================== */
.plan-controls { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.plan-controls .field { display: flex; flex-direction: column; gap: 4px; }
.plan-controls select { padding: 6px 8px; }

.plan-legende { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.legende-titel { font-size: 13px; color: #555; font-weight: 600; }
.team-chip { font-size: 12px; color: #fff; padding: 3px 8px; border-radius: 10px; text-shadow: 0 1px 1px rgba(0,0,0,.25); }

/* Scroll-Container: horizontal scrollen, Zeit-Spalte bleibt sichtbar (mobil) */
.plan-grid-wrap { overflow-x: auto; }
.plan-grid { display: grid; min-width: max-content; border: 1px solid #e2e2e2; background: #fff; }

.plan-corner { position: sticky; left: 0; z-index: 3; background: #f4f4f4; border-bottom: 1px solid #ddd; }
.plan-ort-head { font-size: 13px; font-weight: 600; text-align: center; padding: 6px 4px; background: #f4f4f4;
    border-bottom: 1px solid #ddd; border-left: 1px solid #eee; }
.plan-zeit { position: sticky; left: 0; z-index: 2; background: #fafafa; font-size: 11px; color: #666;
    padding: 0 8px; display: flex; align-items: center; border-top: 1px solid #f0f0f0; border-right: 1px solid #ddd; }

.plan-cell { border-top: 1px solid #f0f0f0; border-left: 1px solid #eee; }
.plan-cell.gesperrt { background: repeating-linear-gradient(45deg, #f7f7f7, #f7f7f7 6px, #f0f0f0 6px, #f0f0f0 12px); }
.plan-cell.planbar { background: #fff; }
.plan-cell.klickbar { cursor: pointer; }
.plan-cell.klickbar:hover { background: #eef6ff; }

/* Overlay je Ort-Spalte: Kacheln werden darin absolut positioniert */
.plan-overlay { position: relative; pointer-events: none; }
.plan-slot { position: absolute; pointer-events: auto; box-sizing: border-box; border-radius: 4px;
    color: #fff; font-size: 11px; padding: 2px 4px; overflow: hidden; text-shadow: 0 1px 1px rgba(0,0,0,.3);
    display: flex; flex-direction: column; gap: 1px; }
.plan-slot.klickbar { cursor: pointer; }
.plan-slot-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-slot-bem { font-size: 10px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-slot-del { position: absolute; top: 1px; right: 2px; background: rgba(0,0,0,.25); color: #fff; border: none;
    border-radius: 3px; width: 16px; height: 16px; line-height: 14px; font-size: 13px; cursor: pointer; padding: 0; }
.plan-slot-del:hover { background: rgba(200,0,0,.7); }

/* Kollisions-Warnung (Phase 1.4): Warnung, kein Verbot — Kachel bleibt klickbar/loeschbar.
   box-shadow:inset statt outline -> rendert INNERHALB der Box (kein Ragen in Nachbar-Lanes,
   respektiert border-radius, wird vom .plan-slot{overflow:hidden} nicht abgeschnitten). */
.plan-slot.kollision { box-shadow: inset 0 0 0 2px #f59f00; }
.plan-slot-warn { position: absolute; top: 1px; left: 2px; font-size: 11px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.plan-warn-zaehler { align-self: center; color: #f59f00; font-weight: 600; font-size: 13px; }
.plan-warn-icon { font-size: 14px; }

/* Wochen-Übersicht: sieben Tagesblöcke untereinander. */
.woche-block { margin-bottom: 24px; }
.woche-tag-titel { margin: 0 0 6px; font-size: 15px; color: #343a40; border-bottom: 1px solid #dee2e6; padding-bottom: 4px; }
