/* =====================================================
   Familienportal – zentrales Stylesheet
   Mobile First · Dark Mode · ohne Frameworks
   ===================================================== */

/* ---------- Design-Tokens ---------- */
:root {
    /* Heller Modus (Standard)
       Drei Kontrastfarben nach Apple-Vorbild:
       Grün (Aktionen) · Blau (Links) · Lila wie Apple Podcasts (Akzent) */
    --bg:            #F5F5F7;
    --surface:       #FFFFFF;
    --surface-2:     #ECECF1;
    --text:          #1D1D1F;
    --text-muted:    #6E6E73;
    --primary:       #248A3D;   /* Grün – Buttons, aktive Navigation */
    --primary-soft:  #E2F6E8;
    --link:          #0071E3;   /* Blau – Links */
    --accent:        #8E44EC;   /* Lila (Podcasts) – Highlights */
    --accent-soft:   #F1E7FD;
    --danger:        #D70015;
    --border:        #E2E2E7;
    --shadow:        0 2px 10px rgba(29, 29, 31, 0.07);

    --radius:        14px;
    --radius-sm:     9px;
    --sidebar-w:     250px;
    --sidebar-rail:  76px;
    --font: "Nunito", -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Dunkler Modus per Systemeinstellung
   Grau-basiert (Apple-Grautöne), Farbe nur als Akzent */
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --bg:           #1C1C1E;
        --surface:      #2C2C2E;
        --surface-2:    #3A3A3C;
        --text:         #F5F5F7;
        --text-muted:   #98989F;
        --primary:      #30D158;   /* Grün */
        --primary-soft: #2E3A31;
        --link:         #0A84FF;   /* Blau */
        --accent:       #BF5AF2;   /* Lila (Podcasts) */
        --accent-soft:  #3A2E47;
        --danger:       #FF453A;
        --border:       #3A3A3C;
        --shadow:       0 2px 10px rgba(0, 0, 0, 0.4);
    }
}

/* Dunkler Modus per Umschalter */
html[data-theme="dark"] {
    --bg:           #1C1C1E;
    --surface:      #2C2C2E;
    --surface-2:    #3A3A3C;
    --text:         #F5F5F7;
    --text-muted:   #98989F;
    --primary:      #30D158;
    --primary-soft: #2E3A31;
    --link:         #0A84FF;
    --accent:       #BF5AF2;
    --accent-soft:  #3A2E47;
    --danger:       #FF453A;
    --border:       #3A3A3C;
    --shadow:       0 2px 10px rgba(0, 0, 0, 0.4);
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; }

a { color: var(--link); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
    position: absolute; left: -999px; top: 0;
    background: var(--primary); color: #fff;
    padding: 0.5rem 1rem; z-index: 100; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

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

/* ---------- Layout ---------- */
.layout { min-height: 100vh; }

.content-area {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main {
    flex: 1;
    width: 100%;
    max-width: 1200px;       /* Ultrawide: Inhalt bleibt lesbar zentriert */
    margin-inline: auto;
    padding: 1rem;
}

.page-footer {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-title { font-weight: 800; font-size: 1.05rem; }

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px; height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* Theme-Umschalter: passendes Icon zeigen */
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .icon-sun  { display: none; }
    html[data-theme="auto"] .icon-moon { display: inline; }
}

.logout-form { display: inline; }

/* ---------- Sidebar (Mobile: Off-Canvas) ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
}

body.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem;
    color: var(--primary);
    font-weight: 800;
    font-size: 1.1rem;
}

.sidebar-nav { flex: 1; padding: 0.5rem; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.25rem;
    border-radius: 999px;          /* freundliche Pillen-Form */
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.is-active {
    background: var(--primary-soft);
    color: var(--primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---------- Karten ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    margin-bottom: 1rem;
}

.card-narrow { max-width: 560px; }

.card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.card-link {
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.card-link:hover { text-decoration: underline; }

/* Begrüßung – Signatur-Element */
.card-greeting {
    background:
        linear-gradient(135deg, var(--accent-soft), var(--primary-soft) 55%, var(--surface));
    border: none;
}
.greeting-title { font-size: 1.4rem; }
.greeting-sub { color: var(--text-muted); margin: 0; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 1rem; }
.grid-dashboard, .grid-two { grid-template-columns: 1fr; }
.grid-stats { grid-template-columns: repeat(2, 1fr); }

/* ---------- Terminliste ---------- */
.event-list { list-style: none; margin: 0; padding: 0; }

.event-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.event-item:last-child { border-bottom: none; }

.event-date {
    flex: 0 0 52px;
    text-align: center;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0;
    line-height: 1.15;
}
.event-day { display: block; font-size: 1.2rem; font-weight: 800; }
.event-month { display: block; font-size: 0.7rem; text-transform: uppercase; }

.event-body strong { display: block; }
.event-meta { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Medien ---------- */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.media-grid-large {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.media-thumb {
    margin: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-2);
    aspect-ratio: 1 / 1;
    position: relative;
}
.media-grid-large .media-thumb { aspect-ratio: auto; }

.media-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.media-grid-large .media-thumb img { aspect-ratio: 4 / 3; }

.media-thumb figcaption {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}

.media-video-badge {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    color: var(--primary);
}

/* ---------- Speicheranzeige ---------- */
.storage-text { margin: 0 0 0.5rem; }

.progress {
    height: 12px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--link), var(--accent));
    transition: width 0.4s ease;
}
.progress-bar.is-critical { background: var(--danger); }

.storage-hint {
    margin: 0.4rem 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---------- Statistik ---------- */
.stat-card { text-align: center; }
.stat-number {
    display: block;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary);
}
.stat-label { color: var(--text-muted); font-size: 0.85rem; }

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    height: 180px;
    padding-top: 1.5rem;
}
.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.bar {
    width: 100%;
    max-width: 56px;
    min-height: 6px;
    background: linear-gradient(180deg, var(--accent), var(--link));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    position: relative;
}
.bar-value {
    position: absolute;
    top: -1.4rem; left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    font-weight: 700;
}
.bar-label {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---------- Formulare ---------- */
label { display: block; font-weight: 700; margin: 0.75rem 0 0.25rem; }

input[type="text"], input[type="password"], input[type="date"],
input[type="time"], input[type="file"] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input:focus { border-color: var(--primary); }

.form-stack .btn { margin-top: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-hint { color: var(--text-muted); font-size: 0.85rem; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-top: 0.75rem;
}
.checkbox-label input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 999px;
    padding: 0.7rem 1.4rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Meldungen ---------- */
.alert {
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
.alert-info  { background: var(--primary-soft); color: var(--primary); }
.alert-error { background: rgba(194, 74, 63, 0.12); color: var(--danger); }

.empty-state { color: var(--text-muted); }

/* ---------- Login-Seite ---------- */
.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1rem;
    background:
        radial-gradient(1100px 500px at 80% -10%, var(--accent-soft), transparent),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 1.5rem;
}

.login-logo { color: var(--primary); margin-bottom: 0.5rem; }
.login-sub { color: var(--text-muted); margin-top: 0; }

.password-wrap { position: relative; }
.password-toggle {
    position: absolute;
    right: 0.4rem; top: 50%;
    transform: translateY(-50%);
    border: none; background: transparent;
    cursor: pointer; font-size: 1rem;
    padding: 0.3rem;
}

.login-footer {
    margin: 1.25rem 0 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* =====================================================
   Tablet (ab 768px): schmale Icon-Leiste, immer sichtbar
   ===================================================== */
@media (min-width: 768px) {
    .sidebar {
        transform: none;
        width: var(--sidebar-rail);
    }
    .sidebar-brand-name,
    .nav-link span,
    .sidebar-footer { display: none; }

    .sidebar-brand { justify-content: center; padding: 1rem 0.5rem; }
    .nav-link { justify-content: center; padding: 0.8rem; }

    .sidebar-overlay { display: none !important; }
    .sidebar-toggle { display: none; }

    .content-area { margin-left: var(--sidebar-rail); }

    .grid-dashboard { grid-template-columns: 1fr 1fr; }
    .grid-dashboard > :first-child { grid-column: 1 / -1; }
    .grid-two { grid-template-columns: 1fr 1fr; }
    .grid-stats { grid-template-columns: repeat(4, 1fr); }
    .main { padding: 1.5rem; }
}

/* =====================================================
   Desktop (ab 1024px): volle Sidebar mit Beschriftung
   ===================================================== */
@media (min-width: 1024px) {
    .sidebar { width: var(--sidebar-w); }

    .sidebar-brand-name,
    .nav-link span,
    .sidebar-footer { display: block; }

    .sidebar-brand { justify-content: flex-start; padding: 1rem; }
    .nav-link { justify-content: flex-start; padding: 0.7rem 0.9rem; }

    .content-area { margin-left: var(--sidebar-w); }

    .grid-dashboard { grid-template-columns: 1.2fr 1fr 1fr; }
    .grid-dashboard > :first-child { grid-column: 1 / -1; }
}

/* =====================================================
   Ultrawide (ab 1800px): Inhalt großzügig, aber begrenzt
   ===================================================== */
@media (min-width: 1800px) {
    .main { max-width: 1500px; padding: 2rem 3rem; }
    html { font-size: 106%; }
}

/* ---------- Reduzierte Bewegung respektieren ---------- */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------- Medien-Filter (Hochgeladen von) ---------- */
.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.filter-bar label {
    margin: 0;
    font-size: 0.9rem;
}
select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
}
select:focus { border-color: var(--accent); }
