/* ==========================================================================
   Modul-Verwaltung — Business Admin Theme
   Hochschule Merseburg
   ========================================================================== */

/* ---- Design tokens ---- */
:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;

    --sidebar-bg: #0f172a;
    --sidebar-bg-2: #111c33;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #64748b;
    --sidebar-active: #1d4ed8;

    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;

    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --success: #16a34a;
    --success-soft: #dcfce7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --info: #0891b2;
    --info-soft: #cffafe;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.18);

    --sidebar-w: 260px;
    --topbar-h: 64px;
}

/* ---- Reset & base ---- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.55;
    color: var(--text);
    background-color: var(--bg);
    font-size: 15px;
}

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

h1, h2, h3, h4 { color: var(--text); font-weight: 600; line-height: 1.25; }

/* ==========================================================================
   App shell: sidebar + main
   ========================================================================== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    background-image: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg));
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.sidebar-brand .brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
}

.sidebar-brand .brand-text strong {
    display: block;
    color: #fff;
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.sidebar-brand .brand-text span {
    display: block;
    font-size: 0.72rem;
    color: var(--sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex: 1;
}

.nav-section-label {
    padding: 0.5rem 0.75rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-muted);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.15rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-nav a .nav-icon {
    font-size: 1.05rem;
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    background-color: rgba(148, 163, 184, 0.12);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-footer {
    padding: 0.9rem 1rem 1.2rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 0.72rem;
    color: var(--sidebar-muted);
}

/* ---- Main column ---- */
.app-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Topbar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.topbar-title h1 {
    font-size: 1.15rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title .breadcrumb { margin: 0; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}
.sidebar-toggle:hover { background: var(--surface-2); }

/* ---- User menu ---- */
.user-menu { position: relative; }

.user-trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.5rem 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    color: var(--text-2);
    font: inherit;
}
.user-trigger:hover { background: var(--surface-2); }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-trigger .user-name {
    font-size: 0.88rem;
    font-weight: 500;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-trigger .caret { font-size: 0.7rem; color: var(--muted); }

.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    display: none;
}
.user-menu.open .user-dropdown { display: block; }

.user-dropdown .dd-head {
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.3rem;
}
.user-dropdown .dd-head strong { display: block; font-size: 0.9rem; }
.user-dropdown .dd-head span { font-size: 0.78rem; color: var(--muted); }

.user-dropdown button,
.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: none;
    background: none;
    border-radius: 6px;
    font: inherit;
    font-size: 0.88rem;
    color: var(--text-2);
    text-align: left;
    cursor: pointer;
}
.user-dropdown button:hover,
.user-dropdown a:hover { background: var(--surface-2); text-decoration: none; color: var(--danger); }

/* ---- Content ---- */
.content {
    flex: 1;
    padding: 1.75rem;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.page-head {
    margin-bottom: 1.5rem;
}
.page-head h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}
.page-head p { color: var(--muted); font-size: 0.95rem; }

.app-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.75rem;
    color: var(--muted);
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: var(--surface);
}

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

.card > h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card > h2:only-child { margin-bottom: 0; }

.card-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background-color: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    padding: 0.55rem 1.05rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    white-space: nowrap;
}
.btn:hover { background-color: var(--primary-dark); text-decoration: none; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35); }

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-2);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background-color: var(--surface-2); box-shadow: none; }

.btn-danger { background-color: var(--danger); }
.btn-danger:hover { background-color: #b91c1c; box-shadow: 0 4px 10px rgba(220, 38, 38, 0.28); }

.btn-success { background-color: var(--success); }
.btn-success:hover { background-color: #15803d; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-icon { font-size: 1rem; line-height: 1; }

/* Compact action buttons inside table rows */
.table .btn {
    padding: 0.24rem 0.5rem;
    font-size: 0.76rem;
    margin: 0;
    line-height: 1.3;
    gap: 0.28rem;
}
.table .btn .btn-icon { font-size: 0.8rem; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-group { margin-bottom: 0.85rem; }

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--text-2);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background-color: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control::placeholder { color: #94a3b8; }
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea.form-control { min-height: 90px; resize: vertical; }

.form-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
}

/* Checkbox list (module / program selection) */
.module-selection {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.4rem;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.module-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 400;
    color: var(--text-2);
    cursor: pointer;
    margin: 0;
}
.module-checkbox:hover { background: var(--primary-soft); }
.module-checkbox input { accent-color: var(--primary); width: 16px; height: 16px; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 0.875rem;
}

.table th,
.table td {
    padding: 0.42rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    line-height: 1.35;
}

.table thead th {
    background-color: var(--surface-2);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
}

.table tbody tr { transition: background-color 0.12s ease; }
.table tbody tr:nth-child(even) { background-color: var(--surface-2); }
.table tbody tr:nth-child(even):hover { background-color: var(--primary-soft); }
.table tbody tr:hover { background-color: var(--primary-soft); }
.table tbody tr:last-child td { border-bottom: none; }

.table td .btn + .btn { margin-left: 0.35rem; }
/*
 * Zeilenaktionen.
 *
 * Die Knöpfe müssen in jeder Zeile auf derselben Höhe stehen. Ein
 * <form> um den Löschen-Knopf wäre sonst ein eigenes Flex-Element mit
 * eigener Höhe und schöbe ihn gegen die übrigen — deshalb `display:contents`:
 * Das Formular verschwindet aus dem Layout, sein Knopf reiht sich direkt ein.
 */
.row-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-wrap: nowrap;
    /* Die Knopfreihe darf nicht unter ihre Inhaltsbreite gestaucht werden —
       sonst schnitt die Zelle die Beschriftung des ersten Knopfes ab. */
    min-width: max-content;
}
.row-actions form { display: contents; }
.row-actions .btn { flex: 0 0 auto; }

/*
 * Die Aktionsspalte bekommt, was sie braucht — und nicht weniger.
 * `width: 1%` hatte sie so weit gestaucht, dass die Knöpfe einander überlappten;
 * ohne Breitenvorgabe nimmt sie ihre natürliche Breite, und die Namensspalte
 * gibt nach (sie darf umbrechen, die Knopfreihe nicht).
 */
.table td:has(.row-actions), .table th.spalte-aktionen { white-space: nowrap; }

/* Kurze Werte wie „7 Sem. · 210 CP" sollen nicht mitten im Wert umbrechen */
.spalte-kompakt { white-space: nowrap; }

/*
 * Knopf, der nur sein Sinnbild zeigt.
 *
 * Sechs beschriftete Knöpfe je Zeile sprengen jede Tabellenbreite; die Spalte
 * begann zu scrollen oder umzubrechen. Sichtbar bleiben alle Aktionen — die
 * Beschriftung steht im Titel und, für Vorlesesoftware, unsichtbar im Knopf.
 */
.btn-nur-symbol {
    width: 1.85rem;
    padding: 0.24rem 0;
    justify-content: center;
}
.btn-nur-symbol .btn-icon { font-size: 0.95rem; margin: 0; }
.table .btn-nur-symbol { padding: 0.24rem 0; }

/* ==========================================================================
   Dashboard statistics
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    background: var(--primary-soft);
    color: var(--primary);
}
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.cyan  { background: var(--info-soft);   color: var(--info); }

.stat-body { min-width: 0; }
.stat-card h3 {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 0.25rem;
}
.stat-card p {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0;
    font-weight: 500;
}

/* Two-column dashboard layout */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Quick-action list */
.quick-actions { display: flex; flex-direction: column; gap: 0.6rem; }
.quick-actions .btn { justify-content: flex-start; }

/* ==========================================================================
   Search & filters
   ========================================================================== */
.search-bar {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
.search-bar .form-control { flex: 1; }

.filters {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-select {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    min-width: 170px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.filters .btn { margin-left: auto; }
.filters .btn + .btn { margin-left: 0.5rem; }

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert {
    padding: 0.85rem 1.1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: 1px solid transparent;
}
.alert .alert-icon { font-size: 1rem; font-weight: 700; }
.alert-success { background-color: var(--success-soft); color: #14532d; border-color: #bbf7d0; }
.alert-danger  { background-color: var(--danger-soft);  color: #7f1d1d; border-color: #fecaca; }
.alert-info    { background-color: var(--info-soft);    color: #155e75; border-color: #a5f3fc; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    border-radius: 999px;
}
.badge-primary   { color: var(--primary); background-color: var(--primary-soft); }
.badge-secondary { color: var(--text-2);  background-color: var(--surface-2); border: 1px solid var(--border); }
.badge-success   { color: #14532d; background-color: var(--success-soft); }
.badge-danger    { color: #7f1d1d; background-color: var(--danger-soft); }
.badge-warning   { color: #78350f; background-color: var(--warning-soft); }

/* ==========================================================================
   Loading spinner
   ========================================================================== */
.loading { text-align: center; padding: 2rem; color: var(--muted); font-weight: 500; }
.loading::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Breadcrumb
   ========================================================================== */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--muted);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 0.4rem; color: var(--border-strong); }
.breadcrumb .current { color: var(--text-2); font-weight: 500; }

/* ==========================================================================
   Login page
   ========================================================================== */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 100% 0%, rgba(37, 99, 235, 0.12), transparent 60%),
        radial-gradient(900px 500px at 0% 100%, rgba(37, 99, 235, 0.10), transparent 55%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 2.25rem;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}
.auth-brand .brand-mark {
    width: 44px; height: 44px; border-radius: 11px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.4);
}
.auth-brand strong { display: block; font-size: 1rem; }
.auth-brand span { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.auth-card h1 { font-size: 1.35rem; margin-bottom: 0.35rem; }
.auth-card .auth-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 0.5rem; padding: 0.65rem; }
.auth-hint {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.7;
}
.auth-hint code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    font-size: 0.75rem;
    color: var(--text-2);
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.mt-1 { margin-top: 0.25rem; } .mt-2 { margin-top: 0.5rem; } .mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 1rem; } .mb-4 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 0.5rem; } .gap-3 { gap: 1rem; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.w-100 { width: 100%; }

/* ==========================================================================
   Sidebar off-canvas (mobile)
   ========================================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 39;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: flex; }
}

@media (max-width: 640px) {
    .content { padding: 1.1rem; }
    .topbar { padding: 0 1rem; }
    .user-trigger .user-name { display: none; }
    .card { padding: 1.15rem; }
    .filters .btn, .filters .btn + .btn { margin-left: 0; }
    .filters { align-items: stretch; }
    .search-bar { flex-direction: column; align-items: stretch; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; justify-content: center; }
}

/* ===== PDF viewer (PDF.js) ===== */
.pdf-viewer-card { display: flex; flex-direction: column; }
.pdf-viewer-card .card-toolbar { align-items: center; }
.pdf-viewer-title { flex: 1; margin: 0; text-align: center; }
.pdf-frame {
    width: 100%;
    height: calc(100vh - 260px);
    min-height: 420px;
    border: 1px solid var(--border, #d9dee5);
    border-radius: 8px;
    background: #525659;
}
@media (max-width: 640px) {
    .pdf-frame { height: calc(100vh - 210px); }
}

/* ==========================================================================
   Versionsvergleich
   ========================================================================== */
.diff {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    background: var(--surface);
}
.diff-line {
    display: flex;
    gap: .5rem;
    padding: .12rem .6rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.diff-marker { flex: 0 0 .9rem; color: var(--muted); user-select: none; }
.diff-add { background-color: var(--success-soft); }
.diff-add .diff-marker { color: #14532d; }
.diff-del { background-color: var(--danger-soft); }
.diff-del .diff-marker { color: #7f1d1d; }

/* ==========================================================================
   Offene Vorgänge in der Kopfzeile
   ========================================================================== */
.aufgaben-anzeige {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: .4rem .6rem;
    margin-right: .4rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-2);
}
.aufgaben-anzeige:hover { background: var(--surface-2); }
.aufgaben-zahl {
    position: absolute;
    top: .05rem;
    right: .05rem;
    min-width: 1.05rem;
    padding: 0 .25rem;
    border-radius: 999px;
    background: var(--danger, #dc2626);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.05rem;
    text-align: center;
}

/* ===================================================================
   Modulplan (Studiengangsplanung)
   Raster im Zuschnitt der Modulpläne der Hochschule: links das Semesterband,
   rechts die Kacheln. Eine Spalte entspricht einer festen Zahl Credits.
   =================================================================== */

.modulplan            { display: flex; flex-direction: column; gap: .35rem; }
.plan-zeile           { display: grid; grid-template-columns: 170px 1fr; gap: .35rem; }

.plan-semester {
    background: #0b7ac9;
    color: #fff;
    padding: .8rem .9rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: .82rem;
}
.plan-vorrat-kopf     { background: #64748b; }
.plan-semester .plan-cp   { font-weight: 500; text-transform: none; opacity: .85; font-size: .78rem; }
.plan-semester .plan-soll { font-weight: 500; text-transform: none; font-size: .74rem; color: #fde68a; }

.plan-raster {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: minmax(46px, auto);
    gap: .35rem;
    min-height: 92px;
    align-content: start;
}

.plan-kachel {
    background: #bfdfea;
    padding: .55rem .65rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
    cursor: grab;
    position: relative;
    grid-row: span 2;
    overflow: hidden;
}
.plan-kachel:active          { cursor: grabbing; }
.plan-kachel-geteilt         { grid-row: span 1; }
.plan-kachel-wahl            { background: #d9e8c9; }
.plan-kachel-schatten        { opacity: .35; }

.plan-code        { font-size: .68rem; font-weight: 700; color: #0f3b52; letter-spacing: .03em; }
.plan-titel       { font-size: .8rem; font-weight: 600; color: #123; line-height: 1.2; }
.plan-kachel-cp   { position: absolute; right: .5rem; bottom: .35rem;
                    font-size: .68rem; color: #0f3b52; opacity: .7; }

.plan-zeile-abweichend .plan-semester { background: #b45309; }

/* Vorrat: flache Liste, die Kacheln behalten ihre Breite */
.plan-vorrat      { grid-auto-rows: minmax(46px, auto); min-height: 60px; }

/* Vorrat: nach Fachbereich gegliedert, aufklappbar */
.vorrat-gruppe        { margin-bottom: .6rem; }
.vorrat-kopf {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #475569;
    padding: .35rem 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.vorrat-gruppe > .vorrat-kopf:not(summary) { cursor: default; }

/* Wahlbereiche: eine Spalte je Bereich */
.wahl-spalten {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    align-items: start;
}
.wahl-liste {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-height: 70px;
    padding: .3rem;
    background: var(--surface-2, #f1f5f9);
    border-radius: 4px;
}
.wahl-kachel {
    background: #d9e8c9;
    padding: .4rem .55rem;
    display: flex;
    flex-direction: column;
    gap: .05rem;
    cursor: grab;
}
.wahl-kachel:active   { cursor: grabbing; }
.wahl-nachschub       { max-height: 340px; overflow-y: auto; }
.wahl-nachschub .wahl-kachel { background: #e2e8f0; }

/* Verwendungshinweis auf einer Vorratskachel */
.plan-verwendung {
    position: absolute;
    right: .5rem;
    top: .4rem;
    font-size: .64rem;
    font-weight: 700;
    color: #7c2d12;
    background: #fed7aa;
    border-radius: 999px;
    padding: 0 .3rem;
}

/* Tableau-Anmutung: Fachgebietsfarben, Lehrveranstaltung, Legende */
.plan-element {
    font-size: .7rem;
    color: #334155;
    line-height: 1.15;
    opacity: .85;
}
.plan-kachel-dunkel .plan-code,
.plan-kachel-dunkel .plan-titel,
.plan-kachel-dunkel .plan-element,
.plan-kachel-dunkel .plan-kachel-cp { color: #f8fafc; }

.legende      { display: flex; flex-wrap: wrap; gap: .4rem; }
.legende-feld {
    font-size: .74rem;
    padding: .3rem .6rem;
    border: 1px solid rgba(0,0,0,.12);
    color: #1f2937;
}
.legende-dunkel { color: #f8fafc; }
.legende-wahl   { background: #d9e8c9; }

/* ==========================================================================
   Modul-Editor: Pflichtfelder und Verwendungshinweis
   ========================================================================== */

/* Stern an Feldern, die im Modulhandbuch gedruckt werden */
.pflichtfeld { color: var(--danger); font-weight: 700; margin-left: .15rem; }

/* Angabe, die nicht hier gepflegt wird — sieht bewusst nicht wie ein Feld aus */
.form-static {
    margin: 0; padding: 0.45rem 0;
    font-weight: 600; color: var(--text);
}

/* Was eine Änderung am Modul nach sich zieht — steht über dem Formular */
.hinweis-verwendung {
    margin: 0 0 1rem 0; padding: 0.7rem 0.9rem;
    border-left: 3px solid #f59e0b;
    background: rgba(245, 158, 11, 0.08);
    border-radius: 0 6px 6px 0;
    font-size: 0.88rem; line-height: 1.5;
}
.hinweis-verwendung a { margin-left: .35rem; }

/* ==========================================================================
   Bedienung ohne Maus
   ========================================================================== */

/* Nur für Screenreader — Ansagen beim Verschieben einer Kachel */
.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

kbd {
    display: inline-block; padding: 0.05rem 0.35rem;
    border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
    background: var(--surface-muted, #f1f5f9);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em;
}

/* Die gewählte Kachel muss sichtbar sein, sonst führt die Tastatur ins Blinde */
.plan-kachel:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Suchfeld in der Kopfzeile */
.kopfsuche input {
    width: 210px; max-width: 32vw;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text); font-size: 0.86rem;
}
.kopfsuche input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
@media (max-width: 700px) { .kopfsuche { display: none; } }

/* ==========================================================================
   Filterleisten
   ========================================================================== */

/*
 * Suchen und Filtern in einer Zeile.
 *
 * Als card-toolbar mit `space-between` drifteten die Felder auseinander und die
 * Beschriftung des letzten Filters landete am rechten Rand, während sein
 * Auswahlfeld in die nächste Zeile rutschte. Hier bleiben Beschriftung und Feld
 * zusammen, und der Rest wird eng gesetzt.
 */
.filterleiste {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.7rem;
    align-items: center;
    justify-content: flex-start;
}
.filterleiste label { margin: 0; font-size: 0.82rem; color: var(--muted); }
.filterleiste .form-control { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.filterleiste select.form-control { max-width: 210px; }

/* Beschriftung und Feld gehören zusammen und werden nie getrennt umbrochen */
.filterfeld { display: flex; align-items: center; gap: 0.35rem; }

/* ==========================================================================
   Formularraster
   ========================================================================== */

/*
 * Felder nebeneinander statt untereinander.
 *
 * Der Modul-Editor stapelte zwei Dutzend Felder über die volle Breite; auf einem
 * normalen Bildschirm blieb rechts die Hälfte leer und man scrollte minutenlang.
 * Das Raster füllt die Breite und bricht erst um, wenn eine Spalte unter 320 px
 * fiele.
 */
.feldraster {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 0.5rem 1.1rem;
    align-items: start;
}
.feldraster.eng { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
/* Lange Texte brauchen Zeilenlänge — hier höchstens zwei Spalten */
.feldraster.weit { grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }
.feldraster .form-group { margin-bottom: 0.35rem; }

/* Ein Feld, das die ganze Zeile beansprucht */
.feld-breit { grid-column: 1 / -1; }

/* Abschnittsüberschrift innerhalb eines Formulars */
.feldgruppe {
    grid-column: 1 / -1;
    margin: 0.6rem 0 0.1rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}
.feldgruppe:first-child { margin-top: 0; }

/*
 * Erklärung unter einem Feld.
 *
 * Vorher waren das mehrzeilige graue Blöcke, die das Formular auseinandertrieben.
 * Der Text bleibt — er erklärt Dinge, die man sonst falsch macht —, tritt aber
 * zurück: kleiner, schmaler gesetzt, ohne eigene Fläche.
 */
.feldhinweis {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--muted);
}

/* Zwei Karten nebeneinander, solange die Breite reicht */
.kartenpaar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1rem;
    align-items: start;
}
.kartenpaar > .card { margin-bottom: 0; }
