/* Kurse_Oberstufe/static/styles.css
   Stylesheet für die Kursübersicht-Webapp.
   Enthält Basis-Layout, Formulare, Tabellen und Detail-Ansicht.
*/

/* ---- Grundlegendes ---- */
:root {
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --muted: #6b7280;
    --text: #0f172a;
    --accent: #2563eb;
    --border: #e6eefc;
    --surface-border: #eef2f7;
    --radius: 8px;
    --shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
    --max-width: 1100px;
    --mono:
        ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono",
        "Courier New", monospace;
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.45;
    font-size: 16px;
}

/* Hauptcontainer */
main,
.container {
    max-width: var(--max-width);
    margin: 28px auto;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Header */
header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}
header h1 {
    margin: 0;
    font-size: 1.45rem;
}
header .meta {
    color: var(--muted);
    font-size: 0.95rem;
}

/* ---- Formulare / Filter ---- */
form.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

form.filters label {
    font-size: 0.85rem;
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
}
input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    background: #fff;
    transition:
        box-shadow 0.12s ease,
        border-color 0.12s ease;
    font-size: 0.95rem;
    color: var(--text);
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.15);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.06);
}

/* Controls in the filter form */
.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}
button,
.button {
    /* normalize buttons and anchor-buttons to match exactly */
    display: inline-flex;
    box-sizing: border-box;
    vertical-align: middle;
    align-items: center;
    justify-content: center;

    /* fixed visual height + horizontal padding for identical sizing */
    height: 40px;
    padding: 0 14px;

    /* inherit typography from surrounding context to avoid baseline shifts */
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1;
    gap: 6px;

    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;

    /* reset native button appearance (important for consistent rendering across browsers) */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    transition:
        transform 0.06s ease,
        box-shadow 0.08s ease;
}
button:hover,
.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.08);
}
a.reset,
.reset {
    display: inline-flex;
    box-sizing: border-box;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1;
    background: #6b7280;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* smaller utility text */
.small {
    font-size: 0.88rem;
    color: var(--muted);
}
.muted {
    color: var(--muted);
}

/* ---- Tabelle ---- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    background: transparent;
}
thead th {
    text-align: left;
    padding: 10px 12px;
    background: linear-gradient(180deg, #fff, #fafafa);
    border-bottom: 1px solid var(--surface-border);
    font-weight: 700;
    font-size: 0.95rem;
}
tbody td {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
    font-size: 0.95rem;
}
tbody tr:hover {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.03), transparent);
}
a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Truncate long cells elegantly */
td .small-note {
    display: block;
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 6px;
}

/* ---- Pagination / Meta ---- */
.meta {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    flex-wrap: wrap;
}
.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ---- Detailseite ---- */
.grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 18px;
    align-items: start;
}
.card {
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    padding: 14px;
    box-shadow: none;
}
aside.card {
    border-left: 2px solid rgba(37, 99, 235, 0.06);
}
pre {
    white-space: pre-wrap;
    font-family: var(--mono);
    background: #fbfdff;
    border: 1px solid #f3f7ff;
    padding: 12px;
    border-radius: 8px;
    color: var(--text);
}

/* Detail fields */
.field {
    margin-bottom: 12px;
}
.label {
    font-weight: 700;
    color: #111;
    font-size: 0.95rem;
    margin-bottom: 6px;
}
.value {
    color: var(--text);
    font-size: 0.95rem;
}

/* Action buttons in detail */
.actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
a.ghost {
    background: transparent;
    border: 1px solid #dbeafe;
    color: var(--accent);
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
}

/* Back link */
.back {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--accent);
    text-decoration: none;
}
.back:hover {
    text-decoration: underline;
}

/* ---- Responsive ---- */
@media (max-width: 980px) {
    .grid {
        grid-template-columns: 1fr;
    }
    .card + .card {
        margin-top: 10px;
    }
    form.filters {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    main,
    .container {
        margin: 18px;
        padding: 14px;
    }
}

/* ---- Accessibility / Print ---- */
@media print {
    body {
        background: #fff;
        color: #000;
    }
    main,
    .container {
        box-shadow: none;
        border-radius: 0;
        padding: 6px;
    }
    nav,
    .controls,
    form.filters,
    .actions {
        display: none;
    }
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 90%;
        color: #444;
    }
}

/* ---- Tiny helpers ---- */
.kv {
    display: flex;
    gap: 6px;
    align-items: center;
}
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.82rem;
    border: 1px solid rgba(37, 99, 235, 0.06);
}
.center {
    text-align: center;
}

/* ---- Empty / No results ---- */
.empty {
    padding: 18px;
    border-radius: 8px;
    background: linear-gradient(180deg, #fff, #fcfdff);
    border: 1px dashed #eef2f7;
    color: var(--muted);
    text-align: center;
}

/* ---- Fine-tuning for small inputs in forms ---- */
input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* ---- Tables for narrow screens ---- */
@media (max-width: 640px) {
    thead {
        display: none;
    }
    tbody td {
        display: block;
        padding: 10px 8px;
    }
    tbody tr {
        margin-bottom: 12px;
        display: block;
        border: 1px solid #f1f5f9;
        border-radius: 10px;
        overflow: hidden;
    }
    td[data-label]:before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        margin-bottom: 6px;
        color: var(--muted);
    }
}

/* End of file */

/* -------------------------------------------------------------------
   Compatibility / Inline template styles (moved from templates/index.html)
   Diese Regeln kommen aus dem ursprünglichen Inline-<style> im Template.
   Sie sorgen dafür, dass die Template-HTML auch ohne weitere Struktur
   vernünftig aussieht. Wenn sich Komponenten im Projekt ändern, können
   diese Regeln angepasst oder entfernt werden.
   ------------------------------------------------------------------ */
body.template-fallback,
body {
    /* Die Inline-Vorgaben in der Vorlage (werden hier übernommen).
       Beachte: Die Projekt-Styles oben definieren bereits moderne Werte.
       Diese Regeln nehmen die ursprünglichen template-Vorgaben auf. */
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial;
    margin: 20px;
    color: #111;
}

header.template-fallback,
header {
    margin-bottom: 20px;
}

/* Form / Filter (fällt mit in die Haupt-Styles, aber hier in der selben
   Form wie im Template, um das Verhalten 1:1 zu reproduzieren) */
form.filters.template-fallback,
form.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    align-items: end;
}

form.filters.template-fallback label,
label {
    font-size: 0.9rem;
    color: #333;
    display: block;
    margin-bottom: 0; /* In Template war kein extra margin, nur font-size */
}

input[type="text"].template-fallback,
input[type="number"].template-fallback,
select.template-fallback,
input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 6px 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Controls */
.controls.template-fallback,
.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Table basics from template */
table.template-fallback,
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

th.template-fallback,
td.template-fallback,
th,
td {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

th.template-fallback,
th {
    background: #fafafa;
    font-weight: 600;
}

/* Buttons/links as in template */
a.button.template-fallback,
a.button {
    display: inline-flex;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1;
    gap: 6px;
    background: #2563eb;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

a.reset.template-fallback,
a.reset {
    background: #6b7280;
    color: white;
    display: inline-flex;
    box-sizing: border-box;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1;
    border-radius: 8px;
    text-decoration: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Fix Firefox inner padding on native buttons which can cause visual offset */
button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* Small / muted text from template */
.muted.template-fallback,
.muted {
    color: #666;
    font-size: 0.9rem;
}

.small.template-fallback,
.small {
    font-size: 0.85rem;
    color: #666;
}

/* Pagination small-screen tweak copied from template */
@media (max-width: 700px) {
    form.filters.template-fallback,
    form.filters {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* -------------------------------------------------------------------
   Styles moved from templates/detail.html
   These were previously inline in the `detail.html` template.
   Keeping them here ensures the detail view renders the same.
   ------------------------------------------------------------------ */
body {
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial;
    margin: 20px;
    color: #111;
}

.container > header,
.detail-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

/* Ensure both index and detail headers stack vertically on smaller screens */
@media (max-width: 980px) {
    .container > header,
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

h1 {
    margin: 0;
    font-size: 1.4rem;
}

.meta {
    color: #555;
    font-size: 0.95rem;
    margin-top: 6px;
}

.container {
    max-width: 1000px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

.card {
    background: #fff;
    border: 1px solid #eee;
    padding: 14px;
    border-radius: 8px;
}

.field {
    margin-bottom: 10px;
}

.label {
    font-weight: 600;
    color: #333;
    font-size: 0.92rem;
    margin-bottom: 4px;
}

.value {
    color: #111;
    font-size: 0.95rem;
}

.small {
    color: #666;
    font-size: 0.9rem;
}

.back {
    text-decoration: none;
    color: #2563eb;
    border: 1px solid transparent;
    padding: 6px 10px;
    border-radius: 6px;
}

.back:hover {
    background: #f8fafc;
    border-color: #e6eefc;
}

dl {
    margin: 0;
}

dt {
    font-weight: 700;
    margin-top: 10px;
    font-size: 0.95rem;
}

dd {
    margin: 6px 0 0 0;
    margin-bottom: 8px;
    color: #222;
}

pre {
    white-space: pre-wrap;
    font-family: inherit;
    background: #f9fafb;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #f0f0f0;
}

.actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

a.button {
    display: inline-flex;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1;
    gap: 6px;
    background: #2563eb;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

a.ghost {
    background: transparent;
    color: #2563eb;
    border: 1px solid #dbeafe;
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
}
