/* Denkste! Nachhilfe – Eltern-/Schüler-Portal
   Gleiche Gestaltungsidee wie das Mitarbeiter-Portal: soll sich wie ein
   Ableger der iOS-App anfühlen, nicht wie eine separate Web-Anwendung -
   Systemschrift, weißer Hintergrund, hellgraue "grouped list"-Panels.
   Die Akzentfarbe wechselt hier aber je nach Konto-Typ: Grün für
   Eltern-Konten (wie "Vertragspartner" in der App), Gelb/Ocker für
   Schüler-Konten (wie "Schüler" in der App) - gesteuert über
   body[data-typ]. Vor dem Einloggen (Login-Seite) gilt das neutrale
   Terminplan-Blau der App. */

:root {
    --hintergrund: #ffffff;
    --panel: #f2f2f7;
    --panel-linie: #e5e5ea;
    --tinte: #1c1c1e;
    --tinte-gedaempft: #8a8a8e;
    --akzent: #3b6ef5;
    --akzent-dunkler: #2c56c9;
    --akzent-hell: #e8edfd;
    --fehler: #c0392b;
    --fehler-bg: #fbeae8;
    --fokus: #1f6fb2;
    --radius-klein: 8px;
    --radius-panel: 14px;
    --schrift: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body[data-typ="eltern"] {
    --akzent: #3e9b6e;
    --akzent-dunkler: #327d59;
    --akzent-hell: #e6f4ee;
}

body[data-typ="schueler"] {
    --akzent: #e8a63c;
    --akzent-dunkler: #c98a28;
    --akzent-hell: #fbf1e0;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--hintergrund);
    color: var(--tinte);
    font-family: var(--schrift);
    font-size: 17px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

:focus-visible {
    outline: 2px solid var(--fokus);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

.seite {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(20px + env(safe-area-inset-top)) 16px 48px;
}

.kopf {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
}

.kopf .logo-klein {
    height: 40px;
    width: auto;
    display: block;
}

.kopf .angemeldet-als {
    font-size: 0.8125rem;
    color: var(--tinte-gedaempft);
    text-align: right;
    padding-top: 6px;
}

.link-abmelden,
.link-sekundaer {
    background: none;
    border: none;
    color: var(--akzent);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 0;
    min-height: 30px;
}

.link-abmelden:active,
.link-sekundaer:active {
    opacity: 0.6;
}

/* --- Login / Registrieren --- */

.login-flaeche {
    max-width: 340px;
    margin: 0 auto;
    padding: calc(10vh + env(safe-area-inset-top)) 20px 40px;
}

.login-flaeche .logo {
    display: block;
    height: 72px;
    width: auto;
    margin: 0 auto 4px;
}

.login-flaeche .produkttitel {
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--tinte-gedaempft);
    margin: 0 0 4px;
    letter-spacing: 0.2px;
}

.login-flaeche .untertitel {
    color: var(--tinte-gedaempft);
    margin: 0 0 28px;
    font-size: 0.9375rem;
    text-align: center;
}

.feld {
    margin-bottom: 14px;
}

.feld label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--tinte-gedaempft);
    margin-bottom: 6px;
}

.feld input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--panel-linie);
    border-radius: var(--radius-klein);
    background: var(--panel);
    color: var(--tinte);
    font-size: 1rem;
    font-family: inherit;
    min-height: 46px;
}

.feld input:focus {
    background: var(--hintergrund);
    border-color: var(--akzent);
}

.feld-hinweistext {
    font-size: 0.8125rem;
    color: var(--tinte-gedaempft);
    margin-top: 6px;
}

/* Typ-Auswahl (Eltern/Schüler) auf der Registrierungsseite - zwei große,
   antippbare Kacheln statt kleiner Radiobuttons, damit die Auswahl auch
   auf dem Handy bequem zu treffen ist. */
.typ-auswahl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 22px;
}

.typ-kachel {
    display: block;
    position: relative;
    cursor: pointer;
}

.typ-kachel input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.typ-kachel .kachel-inhalt {
    display: block;
    border: 2px solid var(--panel-linie);
    border-radius: var(--radius-panel);
    padding: 16px 10px;
    text-align: center;
    background: var(--panel);
}

.typ-kachel .kachel-inhalt .kachel-titel {
    font-weight: 700;
    font-size: 0.9375rem;
    display: block;
    margin-bottom: 3px;
}

.typ-kachel .kachel-inhalt .kachel-untertitel {
    font-size: 0.75rem;
    color: var(--tinte-gedaempft);
    display: block;
}

.typ-kachel input:checked + .kachel-inhalt {
    border-color: var(--akzent);
    background: var(--akzent-hell);
}

button.primaer {
    width: 100%;
    padding: 14px;
    min-height: 50px;
    background: var(--akzent);
    color: #fff;
    border: none;
    border-radius: var(--radius-klein);
    font-size: 1.0625rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

button.primaer:active:not(:disabled) {
    background: var(--akzent-dunkler);
}

button.primaer:disabled {
    opacity: 0.5;
    cursor: default;
}

.hinweis {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-klein);
    font-size: 0.9375rem;
}

.hinweis.fehler {
    background: var(--fehler-bg);
    color: var(--fehler);
}

.hinweis.info {
    background: var(--akzent-hell);
    color: var(--akzent-dunkler);
}

.wechsel-hinweis {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9375rem;
    color: var(--tinte-gedaempft);
}

.wechsel-hinweis a {
    color: var(--akzent);
    font-weight: 600;
    text-decoration: none;
}

.wechsel-hinweis a:active {
    opacity: 0.6;
}

/* --- Abschnitte --- */

section.block {
    margin-bottom: 32px;
}

section.block h2 {
    font-size: 1.0625rem;
    font-weight: 700;
    margin: 0 0 2px;
    padding: 0 4px;
}

.block-kopf {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.block-kopf h2 {
    margin: 0;
}

.block-untertitel {
    color: var(--tinte-gedaempft);
    font-size: 0.8125rem;
    margin: 0 0 10px;
    padding: 0 4px;
}

/* Kind-Umschalter, wenn ein Eltern-Konto mehrere Kinder hat - Pillen zum
   Antippen statt eines Dropdowns, damit sofort sichtbar ist, wie viele
   Kinder es gibt. */
.nachricht-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
    border-radius: var(--radius-panel);
    padding: 14px 16px;
    text-decoration: none;
    color: var(--tinte);
    font-weight: 600;
    font-size: 0.9375rem;
}

.nachricht-link:active {
    background: var(--akzent-hell);
}

.nachricht-link .chevron {
    color: var(--tinte-gedaempft);
    font-size: 1.25rem;
}

.kind-umschalter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    padding: 0 4px;
}

.kind-pille {
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--panel);
    color: var(--tinte);
    cursor: pointer;
}

.kind-pille.aktiv {
    background: var(--akzent);
    color: #fff;
}

.tagesgruppe {
    background: var(--panel);
    border-radius: var(--radius-panel);
    padding: 4px 14px;
    overflow: hidden;
    margin-bottom: 16px;
}

.tagesgruppe .tagestitel {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--tinte-gedaempft);
    padding: 10px 0 6px;
}

.termin-zeile {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--panel-linie);
}

.termin-zeile:last-child {
    border-bottom: none;
}

.termin-zeile .zeit {
    font-variant-numeric: tabular-nums;
    min-width: 52px;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.9375rem;
}

.termin-zeile .termin-info {
    flex: 1;
    min-width: 140px;
}

.termin-zeile .termin-info .lehrkraft {
    font-size: 0.875rem;
    color: var(--tinte-gedaempft);
}

.termin-zeile .termin-info .zusatztermin-label {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 700;
    /* Bewusst fest auf das Termine-Blau der App, unabhängig von der
       Eltern/Schüler-Rollenfarbe (Grün/Gelb) - ein Zusatztermin hat in
       der App immer dieselbe blaue Farbidentität. */
    color: #2c56c9;
    background: #e8edfd;
    border-radius: 999px;
    padding: 2px 8px;
    margin-left: 6px;
    vertical-align: middle;
}

.status-abzeichen {
    font-size: 0.75rem;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
    font-weight: 600;
    color: var(--fehler);
    background: var(--fehler-bg);
}

/* Kompletter Kursausfall (nicht: Absage durch Eltern/Schüler selbst) -
   die ganze Zeile wird rot hervorgehoben, nicht nur das Abzeichen. */
.termin-zeile.ausgefallen {
    background: var(--fehler-bg);
    border-radius: 8px;
    padding-left: 8px;
    padding-right: 8px;
    margin: 0 -8px;
}

.termin-zeile.ausgefallen .lehrkraft {
    text-decoration: line-through;
    color: var(--tinte-gedaempft);
}

button.absagen-button {
    background: none;
    border: 1px solid var(--panel-linie);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--fehler);
    cursor: pointer;
    white-space: nowrap;
}

button.absagen-button:active:not(:disabled) {
    background: var(--fehler-bg);
}

button.absagen-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.leer-hinweis,
.lade-hinweis {
    color: var(--tinte-gedaempft);
    font-size: 0.9375rem;
    padding: 14px 4px;
}

/* --- Einstellungen (nur Eltern-Konto) --- */

.einstellung-zeile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--panel-linie);
}

.einstellung-zeile:last-child {
    border-bottom: none;
}

.einstellung-zeile .einstellung-text {
    flex: 1;
}

.einstellung-zeile .einstellung-titel {
    font-weight: 600;
    font-size: 0.9375rem;
}

.einstellung-zeile .einstellung-untertitel {
    font-size: 0.8125rem;
    color: var(--tinte-gedaempft);
    margin-top: 2px;
}

/* Schalter im iOS-Stil - reines CSS, kein Fremd-Skript nötig. */
.schalter {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 30px;
    flex-shrink: 0;
}

.schalter input {
    opacity: 0;
    width: 0;
    height: 0;
}

.schalter .schieber {
    position: absolute;
    inset: 0;
    background: var(--panel-linie);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}

.schalter .schieber::before {
    content: "";
    position: absolute;
    height: 26px;
    width: 26px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s;
}

.schalter input:checked + .schieber {
    background: var(--akzent);
}

.schalter input:checked + .schieber::before {
    transform: translateX(20px);
}

@media (max-width: 380px) {
    .kopf {
        flex-direction: column;
        gap: 2px;
    }

    .kopf .angemeldet-als {
        text-align: left;
        padding-top: 0;
    }
}

/* --- Nachrichten-Chat --- */

.chat-seite {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-bottom: 0;
}

.chat-verlauf {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 2px 16px;
}

.chat-blase-zeile {
    display: block;
    text-align: left;
    max-width: 100%;
}

.chat-blase-zeile.eigene {
    text-align: right;
}

.chat-blase {
    display: inline-block;
    text-align: left;
    max-width: 78%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 0.9375rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-blase-zeile.eigene .chat-blase {
    background: var(--akzent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-blase-zeile:not(.eigene) .chat-blase {
    background: var(--panel);
    color: var(--tinte);
    border-bottom-left-radius: 4px;
}

.chat-meta {
    display: flex;
    gap: 8px;
    font-size: 0.6875rem;
    color: var(--tinte-gedaempft);
    margin-top: 3px;
    padding: 0 4px;
}

.chat-blase-zeile.eigene .chat-meta {
    justify-content: flex-end;
}

.chat-meta button {
    background: none;
    border: none;
    padding: 0;
    color: var(--tinte-gedaempft);
    text-decoration: underline;
    font-size: 0.6875rem;
    cursor: pointer;
}

.chat-eingabe {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--panel-linie);
    background: var(--hintergrund);
}

.chat-eingabe textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 11px 14px;
    border: 1px solid var(--panel-linie);
    border-radius: 18px;
    background: var(--panel);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--tinte);
}

.chat-eingabe textarea:focus {
    background: var(--hintergrund);
    border-color: var(--akzent);
}

.chat-eingabe button {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--akzent);
    color: #fff;
    font-size: 1.125rem;
    cursor: pointer;
}

.chat-eingabe button:disabled {
    opacity: 0.4;
}

.nachricht-link-rechts {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nachrichten-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--fehler);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

/* WICHTIG: ohne diese Regel gewinnt "display: inline-flex" oben gegen
   das hidden-Attribut, und das Abzeichen bliebe auch bei 0 ungelesenen
   Nachrichten sichtbar (mit der zuletzt gesetzten Zahl) - das war der
   eigentliche Fehler. */
.nachrichten-badge[hidden] {
    display: none;
}
