/* ============================================================
   Plan B – Bibelleseplan – Mobile-First CSS
   ============================================================ */

/* ── Reset & Basis ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-bg:       #f5f5f5;
    --color-surface:  #ffffff;
    --color-border:   #e0e0e0;
    --color-text:     #212121;
    --color-muted:    #757575;
    --color-primary:  #1565C0;
    --color-danger:   #c62828;
    --color-success:  #2e7d32;
    --color-done-bg:  #f1f8f1;

    --radius:    8px;
    --shadow:    0 1px 4px rgba(0,0,0,.12);
    --transition: 180ms ease;

    /* Gruppen-Farben */
    --g1:  #E53935;
    --g2:  #D81B60;
    --g3:  #8E24AA;
    --g4:  #1E3A8A;
    --g5:  #827717;
    --g6:  #00838F;
    --g7:  #1565C0;
    --g8:  #2E7D32;
    --g9:  #00695C;
    --g10: #F57F17;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Screen-reader only ────────────────────────────────────── */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Header ────────────────────────────────────────────────── */
.app-header {
    background: var(--color-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.header-inner {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-text { font-size: 1.25rem; font-weight: 700; color: #fff; letter-spacing: .5px; }
.logo-b    { color: #FFCC02; }

.header-nav { display: flex; align-items: center; gap: 12px; }
.nav-link {
    color: rgba(255,255,255,.9);
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-link:hover { color: #fff; text-decoration: none; }
.nav-label { display: none; }
@media (min-width: 400px) { .nav-label { display: inline; } }

/* ── Main wrapper ──────────────────────────────────────────── */
.app-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
}

/* ── Fortschrittsleiste ────────────────────────────────────── */
.progress-bar-wrap {
    background: var(--color-border);
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 4px;
}
.progress-bar {
    height: 100%;
    background: var(--color-success);
    border-radius: 99px;
    transition: width .4s ease;
    min-width: 0;
}
.progress-label {
    font-size: .75rem;
    color: var(--color-muted);
    text-align: right;
    margin-bottom: 16px;
}

/* ── Tages-Navigation ──────────────────────────────────────── */
.day-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.day-select-form { flex: 1; }
.day-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--color-surface);
    cursor: pointer;
}
.day-select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

/* ── Tages-Überschrift ─────────────────────────────────────── */
.day-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.day-check { color: var(--color-success); }
.day-sub {
    font-size: .8rem;
    font-weight: 400;
    color: var(--color-muted);
    margin-left: auto;
}

/* ── Tag komplett erledigen ────────────────────────────────── */
.day-complete-wrap {
    margin-bottom: 12px;
}
.day-complete-wrap .btn {
    width: 100%;
}

/* ── Kapitel-Liste ─────────────────────────────────────────── */
.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chapter-row {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: background var(--transition);
}
.chapter-row.is-done { background: var(--color-done-bg); }

/* Obere Zeile: Checkbox + Badge + Name */
.chapter-check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 6px;
    cursor: pointer;
    user-select: none;
}
.chapter-check-label:hover { background: rgba(0,0,0,.02); }

.chapter-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: border-color var(--transition), background var(--transition);
    flex-shrink: 0;
}
.chapter-checkbox:checked {
    background: var(--color-success);
    border-color: var(--color-success);
}
.chapter-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px; top: 2px;
    width: 6px; height: 11px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}
.chapter-checkbox:focus { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.chapter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 50%;
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.chapter-name {
    font-size: 1rem;
    font-weight: 500;
    flex: 1;
}
.is-done .chapter-name {
    color: var(--color-muted);
    text-decoration: line-through;
}

/* Notizbereich */
.chapter-note-wrap {
    padding: 0 12px 8px 54px;
    position: relative;
}
.chapter-note {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    background: transparent;
    font-size: .85rem;
    color: var(--color-text);
    resize: none;
    font-family: inherit;
    padding: 2px 24px 2px 0;
    min-height: 24px;
    transition: border-color var(--transition);
}
.chapter-note:focus {
    outline: none;
    border-bottom-color: var(--color-primary);
}
.chapter-note::placeholder { color: #bdbdbd; }

.note-saved-indicator {
    position: absolute;
    right: 14px;
    bottom: 11px;
    font-size: .7rem;
    color: var(--color-success);
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}
.note-saved-indicator.show { opacity: 1; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: var(--radius);
    border: none;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { opacity: .75; }

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-danger    { background: var(--color-danger);  color: #fff; }
.btn-secondary { background: #e0e0e0; color: var(--color-text); }
.btn-full      { width: 100%; }

.btn-nav {
    padding: 9px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-radius: var(--radius);
    font-size: 1.1rem;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}
.btn-nav.disabled {
    opacity: .3;
    pointer-events: none;
    cursor: default;
}

/* ── Auth-Seiten ───────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}
.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.auth-logo { text-align: center; }
.auth-logo .logo-text { font-size: 2rem; color: var(--color-primary); }
.logo-sub { font-size: .8rem; color: var(--color-muted); margin-top: 4px; }

.auth-switch { text-align: center; font-size: .875rem; color: var(--color-muted); }

/* ── Formulare ─────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 14px; }

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: .875rem; font-weight: 600; }
.form-group small { font-size: .75rem; color: var(--color-muted); }

.form-group input[type="text"],
.form-group input[type="password"] {
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color var(--transition);
}
.form-group input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
    border-color: var(--color-primary);
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
}
.alert-error   { background: #ffebee; color: #b71c1c; border-left: 4px solid #c62828; }
.alert-success { background: #e8f5e9; color: #1b5e20; border-left: 4px solid #2e7d32; }

/* ── Profil-Seite ──────────────────────────────────────────── */
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.profile-username { color: var(--color-muted); margin-bottom: 20px; }

.profile-progress { margin-top: 4px; margin-bottom: 24px; height: 12px; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    text-align: center;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}
.stat-of { font-size: 1rem; font-weight: 400; color: var(--color-muted); }
.stat-label { font-size: .75rem; color: var(--color-muted); margin-top: 4px; }

/* ── Gefahrenzone ──────────────────────────────────────────── */
.danger-zone {
    margin-top: 32px;
    background: #fff8f8;
    border: 1px solid #ffcdd2;
    border-radius: var(--radius);
    padding: 20px;
}
.danger-zone h2 { font-size: 1rem; color: var(--color-danger); margin-bottom: 8px; }
.danger-zone p  { font-size: .875rem; color: var(--color-muted); margin-bottom: 16px; }

.confirm-dialog {
    background: #fff3f3;
    border: 1px solid #ef9a9a;
    border-radius: var(--radius);
    padding: 14px;
    margin-top: 12px;
}
.confirm-dialog p { margin-bottom: 12px; font-size: .9rem; color: var(--color-text); }
.confirm-actions { display: flex; gap: 10px; }

/* ── Spinner (Autosave-Feedback) ───────────────────────────── */
.saving-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: pulse .8s infinite alternate;
    margin-right: 4px;
}
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }

/* ── Übersetzungs-Badge (Header) ───────────────────────────── */
.translation-link { margin-right: 4px; }
.translation-badge {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
    white-space: nowrap;
}
.translation-link:hover .translation-badge {
    background: rgba(255,255,255,.3);
    text-decoration: none;
}

/* ── Kapitel-Link (Bibleserver) ────────────────────────────── */
.chapter-link {
    color: inherit;
    text-decoration: none;
}
.chapter-link:hover {
    text-decoration: underline;
    color: var(--color-primary);
}
.is-done .chapter-link { color: var(--color-muted); }

/* ── Einstellungen-Bereich (Profil) ────────────────────────── */
.settings-section {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}
.settings-section h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.settings-section > p {
    font-size: .875rem;
    color: var(--color-muted);
    margin-bottom: 14px;
}
.translation-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--color-surface);
    cursor: pointer;
    margin-bottom: 12px;
}
.translation-select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
