/* KAIT Spark – Stylesheet
 * Modernes, klares Design mit Sidebar-Layout.
 */

:root {
    --color-bg: #f4f6fb;
    --color-surface: #ffffff;
    --color-surface-2: #f8fafc;
    --color-border: #e2e8f0;
    --color-text: #0f172a;
    --color-muted: #64748b;
    --color-primary: #4f46e5;
    --color-primary-dark: #4338ca;
    --color-primary-soft: #eef2ff;
    --color-success: #16a34a;
    --color-success-soft: #dcfce7;
    --color-danger: #dc2626;
    --color-danger-soft: #fee2e2;
    --color-warning: #d97706;
    --color-warning-soft: #fef3c7;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
    --sidebar-width: 240px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

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

/* ---- Layout ---- */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #0f172a;
    color: #cbd5e1;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -.02em;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar .brand .dot {
    width: 10px; height: 10px;
    background: var(--color-primary);
    border-radius: 2px;
    display: inline-block;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    color: #cbd5e1;
    border-radius: var(--radius-sm);
    margin-bottom: .15rem;
    font-weight: 500;
}
.sidebar nav a:hover {
    background: rgba(255,255,255,0.06);
    text-decoration: none;
    color: #fff;
}
.sidebar nav a.active {
    background: var(--color-primary);
    color: #fff;
}
.sidebar nav .section {
    text-transform: uppercase;
    font-size: .7rem;
    color: #64748b;
    margin: 1rem .75rem .35rem;
    letter-spacing: .04em;
}

.sidebar .user-card {
    margin-top: auto;
    padding: .75rem;
    background: rgba(255,255,255,.05);
    border-radius: var(--radius-sm);
    font-size: .85rem;
}

.main {
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar h1 {
    font-size: 1.15rem;
    margin: 0;
}

.content {
    padding: 1.5rem;
    flex: 1;
}

/* ---- Cards / Tables ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card h2 { margin-top: 0; }

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

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}
.kpi .label { color: var(--color-muted); font-size: .85rem; margin-bottom: .25rem; }
.kpi .value { font-size: 1.6rem; font-weight: 700; }

.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.table th, .table td {
    text-align: left;
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.table th {
    background: var(--color-surface-2);
    color: var(--color-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .03em;
}
.table tbody tr:hover { background: var(--color-surface-2); }
.table td.actions { white-space: nowrap; text-align: right; }
.table .id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--color-muted); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: .5rem .9rem;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--color-surface-2); }
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-danger {
    background: var(--color-surface);
    color: var(--color-danger);
    border-color: var(--color-danger-soft);
}
.btn-danger:hover { background: var(--color-danger-soft); }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ---- Forms ---- */
.form { display: grid; gap: .9rem; }

.form label,
.form .field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-size: .85rem;
    color: var(--color-text);
    font-weight: 500;
}

.form input[type=text],
.form input[type=email],
.form input[type=password],
.form input[type=tel],
.form input[type=number],
.form input[type=date],
.form select,
.form textarea {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: .55rem .75rem;
    font: inherit;
    background: #fff;
    color: var(--color-text);
}

.form textarea { min-height: 120px; resize: vertical; }

.form input:focus,
.form select:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.form-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-top: .5rem;
}

/* ---- Alerts ---- */
.alert {
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid;
}
.alert p { margin: .15rem 0; }
.alert-error    { background: var(--color-danger-soft);  border-color: #fecaca; color: #991b1b; }
.alert-success  { background: var(--color-success-soft); border-color: #bbf7d0; color: #166534; }
.alert-info     { background: var(--color-primary-soft); border-color: #c7d2fe; color: #3730a3; }
.alert-warning  { background: var(--color-warning-soft); border-color: #fde68a; color: #92400e; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-active   { background: var(--color-success-soft); color: #166534; }
.badge-inactive { background: var(--color-danger-soft);  color: #991b1b; }
.badge-valid    { background: var(--color-success-soft); color: #166534; }
.badge-invalid  { background: var(--color-danger-soft);  color: #991b1b; }
.badge-neutral  { background: var(--color-surface-2);    color: var(--color-muted); border: 1px solid var(--color-border); }

/* ---- Auth pages ---- */
.auth-page {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #8b5cf6 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.auth-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .25);
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 420px;
}
.auth-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}
.auth-card .form button {
    width: 100%;
    justify-content: center;
}

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--color-muted);
}

/* ---- Search ---- */
.search-box {
    display: flex;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: .35rem .75rem;
}
.search-box input {
    border: none;
    outline: none;
    background: transparent;
    padding: .35rem 0;
    font: inherit;
    flex: 1;
}

/* ---- Progress ---- */
.progress {
    background: var(--color-surface-2);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}
.progress > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #8b5cf6);
    border-radius: 999px;
}

/* ---- Course view ---- */
.course-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}
@media (max-width: 768px) { .course-layout { grid-template-columns: 1fr; } }

.chapter-list {
    list-style: none;
    margin: 0; padding: 0;
}
.chapter-list li a {
    display: block;
    padding: .65rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    border: 1px solid transparent;
}
.chapter-list li a:hover { background: var(--color-surface-2); text-decoration: none; }
.chapter-list li a.current {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-weight: 600;
    border-color: #c7d2fe;
}
.chapter-list li a .num {
    display: inline-block;
    width: 1.5rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

.chapter-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    min-height: 60vh;
}
.chapter-nav {
    display: flex; justify-content: space-between;
    margin-top: 1.5rem;
}

/* ---- Certificate ---- */
.certificate {
    background: #fff;
    border: 8px double #b45309;
    border-radius: 4px;
    padding: 3rem;
    margin: 1rem auto;
    max-width: 780px;
    text-align: center;
    box-shadow: var(--shadow-md);
}
.certificate h1 {
    font-family: Georgia, serif;
    font-size: 2.25rem;
    color: #92400e;
    margin-bottom: 1.5rem;
}
.certificate .name {
    font-size: 1.8rem;
    font-family: Georgia, serif;
    margin: 1.5rem 0;
    border-bottom: 1px solid #b45309;
    display: inline-block;
    padding: 0 2rem .25rem;
}
.certificate .course {
    font-size: 1.25rem;
    margin: 1rem 0;
}
.certificate .date {
    color: var(--color-muted);
    margin-top: 2rem;
}

/* ---- Misc ---- */
.empty {
    padding: 2rem;
    text-align: center;
    color: var(--color-muted);
}
.row-flex { display: flex; gap: .5rem; align-items: center; }
.toolbar  { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
