/* ============================================================
   fit4school Portal – Stylesheet
   Farben: Blau #015694 · Grün #bccf02
   Layout: linke Seitenleiste, App im Hauptfenster
   ============================================================ */

:root {
    --blue: #015694;
    --blue-dark: #01426f;
    --blue-soft: #e8f1f8;
    --green: #bccf02;
    --green-dark: #a5b600;
    --green-soft: #f5f8dc;
    --ink: #1d2b3a;
    --muted: #74828f;
    --line: #e3e9ef;
    --bg: #f4f7fa;
    --card: #ffffff;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --ok-soft: #e9f7ef;
    --ok: #1e8449;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(16, 42, 67, .07), 0 8px 24px rgba(16, 42, 67, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

body.auth-body { display: flex; flex-direction: column; min-height: 100vh; height: auto; }
body.has-sidebar { display: flex; flex-direction: row; height: 100vh; overflow: hidden; }

/* ---------- Marke ---------- */

.brand { display: block; text-decoration: none; }
.brand-img { display: block; width: 100%; max-width: 176px; height: auto; }

/* ---------- Seitenleiste ---------- */

.sidebar {
    flex: 0 0 240px;
    width: 240px;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 22px 14px 14px;
    overflow-y: auto;
}
.sidebar .brand { padding: 0 10px; margin-bottom: 26px; }

.sidenav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidenav-label {
    font-size: 11.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--muted);
    margin: 14px 12px 6px;
}
.sidenav-label:first-child { margin-top: 0; }

.sidenav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 600; font-size: 14.5px;
    white-space: nowrap;
}
.sidenav-item:hover { background: var(--blue-soft); color: var(--blue); }
.sidenav-item.on { background: var(--blue); color: #fff; }
.sidenav-icon { display: flex; flex: 0 0 auto; }
.sidenav-icon svg { width: 20px; height: 20px; display: block; }
.sidenav-text { overflow: hidden; text-overflow: ellipsis; }

.sidebar-foot {
    border-top: 1px solid var(--line);
    margin-top: 14px;
    padding-top: 12px;
    display: flex; flex-direction: column; gap: 3px;
}
button.sidenav-item {
    background: none; border: 0; width: 100%;
    font: inherit; font-weight: 600; font-size: 14.5px;
    text-align: left; cursor: pointer;
}

/* Ein-/Ausklappen: kleine Schaltflaeche zuoberst in der Seitenleiste */
.navtoggle-zeile { display: flex; justify-content: flex-end; margin: -6px 0 8px; }
.navtoggle {
    background: none; border: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px;
    color: var(--muted); padding: 0;
}
.navtoggle:hover { background: var(--blue-soft); color: var(--blue); }
.navtoggle svg { width: 20px; height: 20px; display: block; transition: transform .2s ease; }

/* Eingeklappte Seitenleiste: nur Icons */
.brand-mini {
    display: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--green); color: #fff;
    font-weight: 800; font-size: 21px;
    align-items: center; justify-content: center;
    margin: 0 auto;
}

body.nav-collapsed .sidebar { flex-basis: 74px; width: 74px; padding: 20px 10px 12px; }
body.nav-collapsed .sidebar .brand { padding: 0; margin-bottom: 20px; }
body.nav-collapsed .brand-img,
body.nav-collapsed .sidenav-text,
body.nav-collapsed .sidenav-label,
body.nav-collapsed .sidebar-user { display: none; }
body.nav-collapsed .brand-mini { display: flex; }
body.nav-collapsed .sidenav-item { justify-content: center; padding: 11px 0; }
body.nav-collapsed .navtoggle svg { transform: rotate(180deg); }
body.nav-collapsed .navtoggle-zeile { justify-content: center; margin: -4px 0 10px; }
.sidebar-user {
    font-size: 13px; font-weight: 700; color: var(--muted);
    padding: 0 12px 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Hauptfenster ---------- */

.mainarea {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.mainarea-app { overflow: hidden; }

.flash-wrap { padding: 12px 18px 0; }

.appbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 18px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}
.appbar-title { font-weight: 700; color: var(--blue); font-size: 15px; }
.appbar-ext {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13.5px; font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px; border-radius: 8px;
}
.appbar-ext:hover { background: var(--blue-soft); color: var(--blue); }
.appbar-ext svg { width: 15px; height: 15px; }

.appframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* Shell: alle Bereiche bleiben geladen, nur der aktive ist sichtbar */
.appstage { flex: 1; position: relative; background: #fff; }
.appstage .appframe { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.appstage .appframe.active { display: block; }
.appspinner {
    position: absolute; inset: 0;
    display: none; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .6);
    pointer-events: none;
}
.appspinner.on { display: flex; }
.appspinner span {
    width: 42px; height: 42px;
    border: 4px solid var(--blue-soft);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: appspin .8s linear infinite;
}
@keyframes appspin { to { transform: rotate(360deg); } }

.app-note { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 48px 24px; overflow-y: auto; }
.app-note-card {
    max-width: 620px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 32px 36px;
}
.app-note-icon { display: inline-flex; width: 56px; height: 56px; align-items: center; justify-content: center; border-radius: 14px; background: var(--blue-soft); color: var(--blue); margin-bottom: 6px; }
.app-note-icon svg { width: 30px; height: 30px; }
.app-note-card h2 { margin: 8px 0 10px; font-size: 20px; color: var(--blue); }
.app-note-card p { margin: 10px 0; font-size: 14.5px; }
.app-note-card code { background: #eef1f4; border-radius: 6px; padding: 1px 6px; font-size: 13px; }
.app-note-card pre {
    background: #f0f3f6; border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 14px; font-size: 12.5px; overflow-x: auto; line-height: 1.5;
}
.app-note-card .btn { margin-right: 8px; }

/* ---------- Seiteninhalt (Verwaltung, Konto) ---------- */

.page { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 32px 28px 48px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 14px; }

.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 22px; flex-wrap: wrap; }
.pagehead h1 { margin: 0; font-size: 26px; color: var(--blue); }

.empty-state {
    background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
    padding: 40px; text-align: center; color: var(--muted);
}

/* ---------- Karten & Formulare ---------- */

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px;
}
.card h2 { margin: 0 0 16px; font-size: 18px; color: var(--blue); }
.cards-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 720px) { .cards-2col { grid-template-columns: 1fr; } }

label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }

fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 16px 0 0; padding: 12px 14px 14px; }
legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--blue); }
.fieldnote { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.dl dt { font-weight: 600; color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; }

/* ---------- SSO-Check ---------- */

.checkrow { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.checkrow:last-of-type { border-bottom: none; }
.checkmark {
    flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 14px;
}
.check-ok { background: var(--ok-soft); color: var(--ok); }
.check-fail { background: var(--danger-soft); color: var(--danger); }
.check-info { background: var(--blue-soft); color: var(--blue); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 11px 18px;
    font-size: 15px; font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s ease;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: transparent; color: var(--blue); border-color: var(--line); }
.btn-ghost:hover { background: var(--blue-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; margin-top: 20px; }
button.btn { line-height: 1.4; }

/* ---------- Meldungen ---------- */

.flash {
    border-radius: 10px;
    padding: 12px 16px;
    margin: 0 0 20px;
    font-size: 14.5px;
    font-weight: 600;
}
.flash-success { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe8cf; }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f5c6c0; }
.flash-wrap .flash { margin-bottom: 8px; }

/* ---------- Anmeldung ---------- */

.authwrap { display: flex; justify-content: center; padding: 48px 0 24px; }
.authcard {
    width: 100%; max-width: 420px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: 18px; box-shadow: var(--shadow);
    padding: 36px;
}
.authbrand { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; }
.authbrand .brand-img { max-width: 250px; }
.authcard h1 { font-size: 21px; color: var(--blue); margin: 0 0 6px; text-align: center; }
.authintro { color: var(--muted); font-size: 14.5px; margin: 0 0 10px; text-align: center; }
.authlinks { text-align: center; margin: 18px 0 0; font-size: 14px; }
.authlinks a { color: var(--blue); font-weight: 600; text-decoration: none; }
.authlinks a:hover { text-decoration: underline; }

/* ---------- Benutzertabelle ---------- */

.card-table { padding: 6px 0 0; overflow-x: auto; }
.usertable { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.usertable th {
    text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px;
    color: var(--muted); font-weight: 700;
    padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.usertable td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.usertable tr:last-child td { border-bottom: none; }
.usertable tbody tr:hover { background: #fafcfe; }
.row-muted td { opacity: .55; }
.td-name { font-weight: 700; white-space: nowrap; }
.td-areas { max-width: 260px; }
.td-actions { white-space: nowrap; }
.ta-r { text-align: right; }
.muted { color: var(--muted); }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 12.5px; font-weight: 700;
}
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: #eef1f4; color: var(--muted); }

.chip {
    display: inline-block; margin: 2px 3px 2px 0; padding: 2px 9px;
    border-radius: 999px; font-size: 12px; font-weight: 600;
    background: #eef1f4; color: var(--ink);
}
.chip-green { background: var(--green-soft); color: #6d7a00; }
.chip-self { background: var(--green); color: #fff; }

.status { font-weight: 700; font-size: 13px; }
.status::before { content: "●"; margin-right: 6px; font-size: 11px; }
.status-active { color: var(--ok); }
.status-invited { color: #b7791f; }
.status-inactive { color: var(--muted); }

/* Aktionsmenü */
.menu { display: inline-block; position: relative; }
.menu-list {
    display: none;
    position: absolute; right: 0; top: calc(100% + 4px);
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: var(--shadow);
    min-width: 210px; z-index: 30; padding: 6px;
}
.menu-list.open { display: block; }
.menu-list form { margin: 0; }
.menu-list button {
    display: block; width: 100%; text-align: left;
    background: none; border: none; cursor: pointer;
    font-family: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
    padding: 9px 12px; border-radius: 8px;
}
.menu-list button:hover { background: var(--blue-soft); color: var(--blue); }
.menu-list button.danger { color: var(--danger); }
.menu-list button.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Modal ---------- */

.modal-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(16, 42, 67, .45);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 6vh 16px 16px;
    overflow-y: auto;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
    width: 100%; max-width: 480px;
    background: var(--card); border-radius: 16px;
    box-shadow: 0 24px 64px rgba(16, 42, 67, .3);
    padding: 24px 28px 28px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 20px; color: var(--blue); }
.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 26px; line-height: 1; color: var(--muted);
    padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { background: var(--blue-soft); color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal-aktionen { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-aktionen .btn { flex: 1 1 auto; }
.btn-danger { color: var(--danger); border-color: #f0cfcb; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
#f-pwbox { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- Mobile ---------- */

@media (max-width: 760px) {
    body.has-sidebar { flex-direction: column; }
    /* Auf dem Handy gibt es kein Einklappen – Zustand neutralisieren */
    .navtoggle { display: none !important; }
    body.nav-collapsed .sidebar { width: 100%; padding: 10px 12px; }
    body.nav-collapsed .brand-img { display: block; }
    body.nav-collapsed .brand-mini { display: none; }
    body.nav-collapsed .sidenav-text { display: inline; }
    body.nav-collapsed .sidenav-item { justify-content: flex-start; padding: 8px 10px; }
    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
        overflow-y: hidden;
    }
    .sidebar .brand { padding: 0; margin: 0 8px 0 0; flex: 0 0 auto; }
    .sidebar .brand-img { width: 108px; }
    .sidenav { flex-direction: row; align-items: center; gap: 4px; flex: 1 0 auto; }
    .sidenav-label { display: none; }
    .sidenav-item { padding: 8px 10px; font-size: 13.5px; }
    .sidebar-foot { flex-direction: row; align-items: center; border-top: none; margin: 0 0 0 8px; padding: 0; flex: 0 0 auto; }
    .sidebar-user { display: none; }
    .sidenav-text { max-width: 120px; }
    .page { padding: 24px 16px 40px; }
    .usertable { font-size: 13.5px; }
}
