/* SupremeLearner admin — warm, education-friendly, deliberately spacious. */

:root {
    --bg: #f7f5ee;            /* warm cream background */
    --panel: #ffffff;
    --ink: #1f2024;
    --ink-soft: #3a3b41;
    --muted: #7a7882;
    --line: #ece8dc;           /* warm hairline */
    --line-soft: #f3efe5;
    --accent: #4d8c70;         /* calm sage */
    --accent-strong: #3d7a60;
    --accent-soft: #e6f0ea;
    --ok: #4d8c70;
    --warn: #c97a36;
    --warn-soft: #fbeede;
    --error: #b04848;
    --error-soft: #fae9e9;
    --shadow: 0 1px 0 rgba(40, 30, 10, 0.04), 0 8px 24px -16px rgba(40, 30, 10, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { color: var(--ink); }

button, input, select, textarea { font-family: inherit; }

/* ---------- App shell ---------- */
/* Two-row layout: a thin top header (brand + signed-in user) and a
   tall left sidebar with big circular icon buttons à la Actionbound. */
.app {
    display: grid;
    grid-template-columns: 132px 1fr;
    grid-template-rows: 56px 1fr;
    min-height: 100vh;
}

.topbar {
    grid-column: 1 / -1;
    background: var(--ink, #1f2433);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topbar .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}
.topbar .brand .dot {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-block;
}
.topbar .brand .brand-logo {
    height: 30px;
    width: auto;
    display: block;
}
.topbar .me {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.7);
    font-size: 13px;
}
.topbar .me .name { color: #fff; font-weight: 600; }
.topbar .me .signout {
    background: none; border: 0; padding: 4px 10px;
    color: rgba(255,255,255,0.7); cursor: pointer;
    font-size: 13px; border-radius: 999px;
}
.topbar .me .signout:hover { color: #fff; background: rgba(255,255,255,0.08); }

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 22px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    align-items: stretch;
}

.sidebar nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.sidebar nav a {
    /* Tile layout: big circular icon on top, label underneath. */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 4px;
    border-radius: 12px;
    color: var(--ink);
    font-weight: 500;
    font-size: 12px;
    text-align: center;
    line-height: 1.2;
    transition: background 0.12s, color 0.12s;
}
.sidebar nav a:hover { background: var(--line-soft); }
.sidebar nav a.active { background: var(--accent-soft); }
.sidebar nav a.active .icon { background: var(--accent-strong); }
.sidebar nav a.active { color: var(--accent-strong); font-weight: 600; }
.sidebar nav a .icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px rgba(31,36,51,0.10);
}
.sidebar nav a .icon svg { width: 26px; height: 26px; color: #fff; opacity: 1; }

main.content {
    padding: 32px 40px 80px;
    max-width: 1100px;
    width: 100%;
}

@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: 56px auto 1fr;
    }
    .sidebar {
        position: static; height: auto;
        padding: 12px 8px;
        flex-direction: row;
        overflow-x: auto;
    }
    .sidebar nav { flex-direction: row; gap: 8px; }
    .sidebar nav a { min-width: 84px; }
    main.content { padding: 24px; }
}

/* ---------- Headings ---------- */
h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.015em; }
h2 { margin: 36px 0 12px; font-size: 17px; font-weight: 600; letter-spacing: -0.005em; }
h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.subtitle { color: var(--muted); margin: 0 0 28px; font-size: 14px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.muted { color: var(--muted); }

/* ---------- Cards / KPI ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.kpi {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; margin-top: 4px; }

/* ---------- Class cards (teacher dashboard) ---------- */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 8px;
}

.class-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    color: var(--ink);
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.class-card:visited { color: var(--ink); }
.class-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--ink);
    transform: translateY(-1px);
}

.class-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.class-card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.class-card-arrow {
    color: var(--muted);
    font-size: 18px;
    transition: color 0.15s, transform 0.15s;
}
.class-card:hover .class-card-arrow {
    color: var(--accent);
    transform: translateX(2px);
}

.class-card-stats {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 18px;
}
.class-card-stats > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.class-card-stats dt {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 500;
    margin: 0;
}
.class-card-stats dd {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1.2;
}
.class-card-stats dd .muted { font-weight: 500; font-size: 14px; }
.class-card-stats dd.warn { color: var(--warn); }

/* ---------- Table ---------- */
table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
table.data th, table.data td {
    text-align: left;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
table.data th { background: transparent; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: rgba(247, 245, 238, 0.5); }

/* ---------- Buttons ---------- */
.button, button.primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.12s;
}
.button:hover, button.primary:hover { background: var(--accent-strong); color: white; }

.button.ghost {
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
}
.button.ghost:hover { background: var(--line-soft); color: var(--ink); }

.link-button {
    background: none;
    border: 0;
    color: var(--accent-strong);
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-size: 14px;
}
.link-button:hover { color: var(--ink); }
.link-button.danger { color: var(--error); }
.link-button.danger:hover { color: #842828; }

/* ---------- Forms ---------- */
.form-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 560px;
}
.form-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-card label > span { font-weight: 500; color: var(--ink-soft); }
.form-card input,
.form-card textarea,
.form-card select {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    color: var(--ink);
    background: white;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.form-card input:focus,
.form-card textarea:focus,
.form-card select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-card input:disabled { background: var(--line-soft); color: var(--muted); }
.form-card textarea { resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

label.inline-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    color: var(--ink-soft);
}
label.inline-checkbox > span { color: var(--ink-soft); font-weight: 400; }
label.inline-checkbox input { width: auto; }

.inline-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.inline-form select { padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); font-size: 13px; }
.inline-form button.primary { padding: 6px 12px; font-size: 13px; }

.error-message {
    background: var(--error-soft);
    color: var(--error);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin: 0 0 14px;
    font-size: 13px;
}

small.muted { font-size: 12px; }

/* ---------- Status colors ---------- */
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }

/* ---------- Lesson editor ---------- */
.lesson-meta { margin-bottom: 32px; }
.lesson-meta .form-card { max-width: 720px; }

.lesson-sections { margin-top: 24px; }

.points-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--muted);
}
.points-pill.ok { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-strong); }
.points-pill.warn { background: var(--warn-soft); border-color: var(--warn-soft); color: var(--warn); }

/* "+ Add section" — collapsed by default, opens a calm menu, no clutter. */
details.add-section { margin: 8px 0 24px; position: relative; }
details.add-section > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-weight: 500;
    font-size: 14px;
}
details.add-section > summary::-webkit-details-marker { display: none; }
details.add-section[open] > summary { background: var(--accent-strong); }

.add-section-menu {
    margin-top: 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px;
    max-width: 720px;
}
.add-section-menu form { margin: 0; }
.add-section-menu button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    color: var(--ink);
}
.add-section-menu button:hover { background: var(--accent-soft); }
.add-section-menu .name { font-weight: 600; font-size: 14px; }
.add-section-menu .desc { color: var(--muted); font-size: 12px; line-height: 1.4; }

.section-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-row {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: grid;
    grid-template-columns: minmax(140px, 180px) 1fr auto auto;
    gap: 16px;
    align-items: center;
    transition: border-color 0.12s;
}
.section-row:hover { border-color: var(--accent-soft); }
.section-kind { font-weight: 600; font-size: 13px; color: var(--ink); }
.section-summary { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-meta { display: flex; align-items: center; gap: 10px; }
.section-points { font-size: 13px; color: var(--muted); white-space: nowrap; }
.badge {
    background: var(--warn-soft);
    color: var(--warn);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
}
.section-actions { display: flex; gap: 12px; align-items: center; }

/* ---------- Editor split (form + preview) ---------- */
.editor-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}
@media (max-width: 1100px) {
    .editor-split { grid-template-columns: 1fr; }
}

.preview-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    position: sticky;
    top: 32px;
}
.preview-card h3 { margin: 0 0 14px; }
.preview-frame {
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    padding: 22px;
    background: var(--bg);
    min-height: 140px;
}
.preview-frame h4 { margin: 0 0 12px; font-size: 16px; }
.preview-body p { margin: 0 0 10px; }
.preview-body p:last-child { margin-bottom: 0; }
.preview-statement { font-size: 16px; margin: 0 0 16px; line-height: 1.5; }
.preview-tf-buttons { display: flex; gap: 8px; }
.preview-tf {
    border: 0;
    border-radius: 999px;
    padding: 8px 18px;
    font: inherit;
    font-weight: 500;
    cursor: default;
    color: white;
}
.preview-tf.richtig { background: var(--ok); }
.preview-tf.falsch { background: var(--error); }

.answer-choice {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.answer-choice legend { color: var(--muted); font-size: 13px; padding: 0 6px; font-weight: 500; }

/* ---------- Auth screens ---------- */
body.auth {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 380px;
    box-shadow: var(--shadow);
}
.auth-card .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    font-weight: 700;
    color: var(--ink);
}
.auth-card .brand .dot { width: 10px; height: 10px; background: var(--accent); border-radius: 50%; }
.auth-card .brand-logo { width: 156px; height: auto; display: block; margin: 0 0 20px; }
.auth-card h1 { font-size: 18px; margin: 0 0 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.auth-card label > span { color: var(--ink-soft); font-weight: 500; }
.auth-card input {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-size: 14px;
    color: var(--ink);
}
.auth-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-card button {
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 11px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
}
.auth-card button:hover { background: var(--accent-strong); }
.auth-card .error {
    background: var(--error-soft);
    color: var(--error);
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    margin: 0 0 14px;
    font-size: 13px;
}
