/* ============================================================
   DIFAK Lernplattform — main.css
   Design System: Navy / Gold / Parchment / Source Serif 4 + DM Sans
   ============================================================ */

:root {
    /* ── Farben — identisch zu pro.difak.org ──────────────── */
    --navy:        #1a2744;
    --navy-deep:   #111b30;
    --navy-mid:    #1f3058;
    --navy-light:  #2a4070;

    --gold:        #c9a84c;
    --gold-light:  #e8c97a;
    --gold-pale:   #f5e9c8;

    --parchment:   #f4efe4;
    --parch-dark:  #ebe4d5;
    --white:       #ffffff;

    --text:        #1a1e2e;
    --text-mid:    #4a5168;
    --text-soft:   #8a90a8;

    --border:      #ddd8cc;
    --border-soft: #eee9df;

    --success:     #4a8c6f;
    --warn:        #b87333;
    --danger:      #c0392b;

    --admin:       #6b3fa0;
    --admin-light: #9b6fd0;
    --admin-pale:  #f0e8ff;

    /* ── Layout ───────────────────────────────────────────── */
    --sidebar-w:   248px;
    --header-h:    60px;

    /* ── Schatten ─────────────────────────────────────────── */
    --shadow-sm:   0 1px 3px rgba(26, 39, 68, 0.05);
    --shadow-md:   0 4px 16px rgba(26, 39, 68, 0.08);
    --shadow-lg:   0 12px 40px rgba(26, 39, 68, 0.15);
}

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

html, body {
    margin: 0; padding: 0;
    height: 100%;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--parchment);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    font-family: 'Source Serif 4', Georgia, serif;
    color: var(--navy);
    margin: 0 0 8px 0;
    font-weight: 600;
    line-height: 1.25;
}

h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

p { margin: 0 0 12px 0; }

a {
    color: var(--navy);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover { color: var(--gold); }

button {
    font-family: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
    font-size: 14px;
}

/* ============================================================
   App-Loading (vor JS-Boot)
   ============================================================ */
.app-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--parchment);
    z-index: 9999;
}

.app-loading-inner { text-align: center; }

.app-loading-logo {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 48px;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -2px;
}

.app-loading-text {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
    margin-top: 4px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 6px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--navy);
    color: #fff;
}
.btn-primary:hover { background: var(--navy-mid); color: #fff; }

.btn-secondary {
    background: var(--parchment);
    color: var(--navy);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--parch-dark); color: var(--navy); }

.btn-gold {
    background: var(--gold);
    color: var(--navy);
    font-weight: 600;
}
.btn-gold:hover { background: var(--gold-light); color: var(--navy); }

.btn-danger {
    background: #fdecea;
    color: var(--danger);
    border: 1px solid #e8b4b0;
}
.btn-danger:hover { background: #fbd5d2; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn[disabled],
.btn[aria-busy="true"] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================
   Login-Seite
   ============================================================ */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--parchment);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(201, 168, 76, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(26, 39, 68, 0.05) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    padding: 32px 32px 24px;
    text-align: center;
    border-bottom: 1px solid var(--border-soft);
    background: linear-gradient(180deg, var(--white) 0%, var(--parchment) 100%);
}

.login-logo {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 42px;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -2px;
    line-height: 1;
}

.login-logo .dot { color: var(--gold); }

.login-subtitle {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
    margin-top: 4px;
}

.login-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-soft);
    margin-top: 14px;
}

.login-body { padding: 28px 32px 32px; }

.login-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--navy);
    margin: 0 0 6px 0;
}

.login-hint {
    font-size: 13px;
    color: var(--text-mid);
    margin: 0 0 24px 0;
}

.login-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-soft);
    text-align: center;
    font-size: 12px;
    color: var(--text-soft);
}

.login-footer a {
    color: var(--gold);
    font-weight: 500;
}

/* ============================================================
   Form-Felder
   ============================================================ */
.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-mid);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="tel"],
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}

.form-field .error-text {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-error {
    background: #fdecea;
    border-color: #e8b4b0;
    color: var(--danger);
}

.alert-success {
    background: #e8f5ef;
    border-color: #a8d4c0;
    color: var(--success);
}

.alert-info {
    background: var(--gold-pale);
    border-color: var(--gold-light);
    color: var(--navy);
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
    position: fixed;
    top: max(env(safe-area-inset-top), 20px);
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--navy);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 10000;
    opacity: 0;
    transition: all 0.25s;
    max-width: 90vw;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--navy); }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-mid);
    background: var(--white);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 18px;
    color: var(--navy);
    margin: 0 0 8px 0;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-mid);
    margin: 0 0 20px 0;
}

/* ============================================================
   Dashboard-Shell
   ============================================================ */
.dash-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--parchment);
}

.dash-topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
}

.dash-brand {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.dash-logo {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -1px;
    line-height: 1;
}

.dash-logo .dot { color: var(--gold); }

.dash-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-soft);
}

.dash-user {
    margin-left: auto;
    margin-right: 12px;
    text-align: right;
    line-height: 1.3;
}

.dash-user-name {
    font-weight: 600;
    color: var(--navy);
    font-size: 14px;
}

.dash-user-meta {
    font-size: 11px;
    color: var(--text-soft);
}

.admin-tag {
    color: var(--admin);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
}

.dash-content {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.dash-greeting {
    margin-bottom: 32px;
}

.dash-greeting h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--navy);
    margin: 0 0 4px 0;
}

.dash-greeting h1 em {
    font-style: italic;
    font-weight: 400;
    color: var(--gold);
}

.dash-greeting-sub {
    color: var(--text-mid);
    font-size: 14px;
    margin: 0;
}

.dash-section {
    margin-bottom: 40px;
}

.dash-section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
}

.dash-section-head h2 {
    font-size: 16px;
    margin: 0;
    color: var(--navy);
}

.dash-section-tag {
    background: var(--admin-pale);
    color: var(--admin);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
}

/* ============================================================
   Dashboard-Spinner (während Daten laden)
   ============================================================ */
.dash-loading {
    display: flex;
    justify-content: center;
    padding: 48px;
}

.dash-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Kurs-Karten (Dashboard)
   ============================================================ */
.kurs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.kurs-card {
    background: var(--white);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.kurs-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gold);
    opacity: 0;
    transition: opacity 0.2s;
}

.kurs-card:hover {
    border-color: var(--gold-pale);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kurs-card:hover::before { opacity: 1; }

.kurs-card-bereich {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

.kurs-card-bereich-icon {
    font-size: 16px;
}

.kurs-card-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--navy);
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.kurs-card-subtitle {
    font-size: 13px;
    color: var(--text-mid);
    margin: 0 0 14px 0;
    line-height: 1.4;
}

.kurs-card-termin {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-mid);
    background: var(--parchment);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.kurs-card-termin-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--navy);
    font-weight: 500;
}

.kurs-card-progress {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
}

.kurs-card-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}

.kurs-card-progress-status {
    font-weight: 500;
}

.kurs-card-progress-status.status-completed { color: var(--success); }
.kurs-card-progress-status.status-started   { color: var(--gold); }
.kurs-card-progress-status.status-new       { color: var(--text-soft); }

.kurs-card-progress-pct {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--navy);
}

.progress-bar {
    height: 6px;
    background: var(--border-soft);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 3px;
    transition: width 0.4s ease-out;
}

/* ============================================================
   Mobile-Anpassungen
   ============================================================ */
@media (max-width: 640px) {
    .dash-topbar {
        padding: 10px 16px;
    }
    .dash-user {
        order: 3;
        width: 100%;
        text-align: left;
        margin: 0;
    }
    .dash-content {
        padding: 24px 16px 48px;
    }
    .dash-greeting h1 {
        font-size: 22px;
    }
    .kurs-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Utility
   ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
