/* =========================================================
   Schulportal - Global Styles
   Professional Design System (BEM)
   ========================================================= */

:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-success: #22c55e;
    --color-success-hover: #16a34a;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;

    --color-text: #1f2937;
    --color-text-secondary: #374151;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3af;
    --color-focus-ring: #4f46e5;

    --color-bg: #f3f4f6;
    --color-bg-white: #ffffff;
    --color-border: #e5e7eb;
    --color-border-dark: #d1d5db;

    --radius-sm: 0.25rem;
    --radius: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);

    --color-header-bg: #1e293b;
    --color-header-text: #f8fafc;
    --color-sidebar-bg: #ffffff;
    --color-sidebar-border: #e5e7eb;
    --color-nav-item: #374151;
    --color-nav-hover: #f3f4f6;
    --color-nav-section-border: #f3f4f6;
    --color-nav-muted: #9ca3af;
    --color-table-header: #f9fafb;
    --color-table-row-border: #f3f4f6;
    --color-table-hover: #fafbfc;
    --color-input-focus-shadow: rgba(79, 70, 229, 0.1);
    --color-badge-danger-bg: #fef2f2;
    --color-badge-danger-text: #991b1b;
    --color-badge-success-bg: #f0fdf4;
    --color-badge-success-text: #166534;
    --color-badge-warning-bg: #fffbeb;
    --color-badge-warning-text: #92400e;
    --color-badge-info-bg: #eff6ff;
    --color-badge-info-text: #1e40af;
    --color-login-error-bg: #fef2f2;
    --color-login-error-text: #991b1b;
    --color-login-error-border: #fecaca;
}

/* =========================================================
   Dark Theme
   ========================================================= */
[data-theme="dark"] {
    --color-primary: #818cf8;
    --color-primary-hover: #6366f1;
    --color-primary-light: rgba(129, 140, 248, 0.15);
    --color-danger: #f87171;
    --color-danger-hover: #ef4444;
    --color-success: #4ade80;
    --color-success-hover: #22c55e;
    --color-warning: #fbbf24;
    --color-info: #60a5fa;

    --color-text: #e2e8f0;
    --color-text-secondary: #cbd5e1;
    --color-text-muted: #94a3b8;
    --color-text-light: #64748b;

    --color-bg: #1a1f2e;
    --color-bg-white: #242b3d;
    --color-border: #3b4459;
    --color-border-dark: #4e5873;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.3);

    --color-header-bg: #151a27;
    --color-header-text: #e2e8f0;
    --color-sidebar-bg: #1e2536;
    --color-sidebar-border: #3b4459;
    --color-nav-item: #cbd5e1;
    --color-nav-hover: #2e3650;
    --color-nav-section-border: #3b4459;
    --color-nav-muted: #7a8599;
    --color-table-header: #1e2536;
    --color-table-row-border: #3b4459;
    --color-table-hover: #2e3650;
    --color-input-focus-shadow: rgba(129, 140, 248, 0.3);
    --color-focus-ring: #818cf8;
    --color-badge-danger-bg: rgba(248, 113, 113, 0.15);
    --color-badge-danger-text: #fca5a5;
    --color-badge-success-bg: rgba(74, 222, 128, 0.15);
    --color-badge-success-text: #86efac;
    --color-badge-warning-bg: rgba(251, 191, 36, 0.15);
    --color-badge-warning-text: #fde68a;
    --color-badge-info-bg: rgba(96, 165, 250, 0.15);
    --color-badge-info-text: #93c5fd;
    --color-login-error-bg: rgba(248, 113, 113, 0.15);
    --color-login-error-text: #fca5a5;
    --color-login-error-border: #7f1d1d;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }
img { max-width: 100%; }

/* =========================================================
   WCAG 2.1 AA – Accessibility
   ========================================================= */

/* Skip-to-content link */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.875rem;
}
.skip-to-content:focus {
    left: 0;
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

/* Focus indicators – WCAG 2.4.7 */
:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-input-focus-shadow);
}
button:focus:not(:focus-visible), a:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion – WCAG 2.3.3 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Screen-reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Typography */
h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.25; color: var(--color-text); }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; color: var(--color-text); }
h3 { font-size: 1.0625rem; font-weight: 600; line-height: 1.4; color: var(--color-text); }
h4 { font-size: 0.9375rem; font-weight: 600; line-height: 1.4; color: var(--color-text-secondary); }

/* =========================================================
   Forms
   ========================================================= */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-input-focus-shadow);
}
.form-input::placeholder { color: var(--color-text-light); }
.form-textarea { min-height: 5rem; resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.form-error { font-size: 0.8125rem; color: var(--color-danger); margin-top: 0.25rem; }
.form-input--error { border-color: var(--color-danger); }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); color: #fff; }

.btn--secondary { background: var(--color-bg-white); color: var(--color-text-secondary); border-color: var(--color-border); }
.btn--secondary:hover { background: var(--color-bg); color: var(--color-text-secondary); }

.btn--danger { background: var(--color-danger); color: #fff; }
.btn--danger:hover { background: var(--color-danger-hover); color: #fff; }

.btn--success { background: var(--color-success); color: #fff; }
.btn--success:hover { background: var(--color-success-hover); color: #fff; }

.btn--sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn--icon { padding: 0.375rem; border-radius: var(--radius); }

/* =========================================================
   Tables
   ========================================================= */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.table th {
    background: var(--color-table-header);
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-table-row-border);
    font-size: 0.875rem;
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--color-table-hover); }

/* =========================================================
   Cards
   ========================================================= */
.card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.card__title { font-size: 1rem; font-weight: 600; color: var(--color-text); }
.card__body { padding: 1.25rem; }

/* =========================================================
   Badges
   ========================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    line-height: 1.5;
}
.badge--primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge--danger { background: var(--color-badge-danger-bg); color: var(--color-badge-danger-text); }
.badge--success { background: var(--color-badge-success-bg); color: var(--color-badge-success-text); }
.badge--warning { background: var(--color-badge-warning-bg); color: var(--color-badge-warning-text); }
.badge--info { background: var(--color-badge-info-bg); color: var(--color-badge-info-text); }

/* =========================================================
   Modals
   ========================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.modal__header h3 { font-size: 1.0625rem; font-weight: 600; }
.modal__body { padding: 1.5rem; }
.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   Page Header
   ========================================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header h1 { font-size: 1.375rem; }

/* =========================================================
   Empty & Loading States
   ========================================================= */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-muted);
}
.empty-state__icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state__title { font-size: 1rem; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 0.25rem; }
.empty-state__text { font-size: 0.875rem; }

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
    gap: 0.75rem;
    color: var(--color-text-muted);
}
.loading__spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Login Page
   ========================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 1rem;
}
.login-card {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 24rem;
    padding: 2.5rem 2rem;
}
.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-logo__icon {
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    margin-bottom: 0.75rem;
}
.login-logo__title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
}
.login-logo__subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}
.login-error {
    background: var(--color-login-error-bg);
    color: var(--color-login-error-text);
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-login-error-border);
}

/* =========================================================
   Not Found
   ========================================================= */
.not-found {
    text-align: center;
    padding: 4rem 1.5rem;
}
.not-found h1 { font-size: 4rem; font-weight: 800; color: var(--color-text-light); }
.not-found p { color: var(--color-text-muted); margin: 0.5rem 0 1.5rem; }

/* =========================================================
   Utilities
   ========================================================= */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }

/* =========================================================
   Dark Theme – Aggressive Global Overrides
   Overrides ALL hardcoded colors in scoped Blazor <style> blocks.
   ========================================================= */

[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="dark"] body {
    background: var(--color-bg) !important;
    color: var(--color-text) !important;
}

/* ===========================================
   NUCLEAR: Force dark on ALL content elements
   =========================================== */

/* All text elements → light text */
[data-theme="dark"] .portal__content h1,
[data-theme="dark"] .portal__content h2,
[data-theme="dark"] .portal__content h3,
[data-theme="dark"] .portal__content h4,
[data-theme="dark"] .portal__content h5,
[data-theme="dark"] .portal__content h6,
[data-theme="dark"] .portal__content p,
[data-theme="dark"] .portal__content label,
[data-theme="dark"] .portal__content li,
[data-theme="dark"] .portal__content dt,
[data-theme="dark"] .portal__content dd,
[data-theme="dark"] .portal__content td,
[data-theme="dark"] .portal__content th,
[data-theme="dark"] .portal__content legend,
[data-theme="dark"] .portal__content figcaption,
[data-theme="dark"] .portal__content blockquote {
    color: var(--color-text) !important;
}

/* All spans/divs/small/strong in content → inherit (EXCEPT badges/status) */
[data-theme="dark"] .portal__content span:not([class*="badge"]):not([class*="status"]):not([class*="tag"]):not([class*="chip"]):not([class*="dot"]):not([class*="icon"]),
[data-theme="dark"] .portal__content small,
[data-theme="dark"] .portal__content strong,
[data-theme="dark"] .portal__content em,
[data-theme="dark"] .portal__content b {
    color: inherit !important;
}

[data-theme="dark"] .portal__content div:not([class*="badge"]):not([class*="status"]):not([class*="dot"]) {
    color: inherit !important;
}

/* Links keep primary color */
[data-theme="dark"] .portal__content a:not([class*="btn"]):not([class*="nav"]) {
    color: var(--color-primary) !important;
}

/* All backgrounds in content → dark (EXCEPT badges/status) */
[data-theme="dark"] .portal__content div:not([class*="badge"]):not([class*="status"]):not([class*="dot"]):not([class*="icon"]):not([class*="spinner"]),
[data-theme="dark"] .portal__content section,
[data-theme="dark"] .portal__content article,
[data-theme="dark"] .portal__content aside,
[data-theme="dark"] .portal__content form,
[data-theme="dark"] .portal__content fieldset,
[data-theme="dark"] .portal__content details {
    background-color: transparent !important;
}

/* Borders → dark */
[data-theme="dark"] .portal__content div,
[data-theme="dark"] .portal__content section,
[data-theme="dark"] .portal__content table,
[data-theme="dark"] .portal__content th,
[data-theme="dark"] .portal__content td,
[data-theme="dark"] .portal__content form,
[data-theme="dark"] .portal__content fieldset,
[data-theme="dark"] .portal__content hr {
    border-color: var(--color-border) !important;
}

/* ===========================================
   RE-APPLY: Surfaces that need a bg color
   (cards, tables, inputs, modals etc.)
   =========================================== */

/* "Card-like" containers: any div with border+radius = card */
[data-theme="dark"] .portal__content [class*="card"],
[data-theme="dark"] .portal__content [class*="panel"],
[data-theme="dark"] .portal__content [class*="section"],
[data-theme="dark"] .portal__content [class*="stat"],
[data-theme="dark"] .portal__content [class*="widget"],
[data-theme="dark"] .portal__content [class*="wrap"],
[data-theme="dark"] .portal__content [class*="box"],
[data-theme="dark"] .portal__content [class*="empty"],
[data-theme="dark"] .portal__content [class*="skeleton"],
[data-theme="dark"] .portal__content [class*="item"],
[data-theme="dark"] .portal__content [class*="event"],
[data-theme="dark"] .portal__content [class*="list"],
[data-theme="dark"] .portal__content [class*="grid"],
[data-theme="dark"] .portal__content [class*="overview"],
[data-theme="dark"] .portal__content [class*="container"],
[data-theme="dark"] .portal__content [class*="module"],
[data-theme="dark"] .portal__content [class*="detail"],
[data-theme="dark"] .portal__content [class*="row"],
[data-theme="dark"] .portal__content [class*="cell"],
[data-theme="dark"] .portal__content [class*="slot"],
[data-theme="dark"] .portal__content [class*="entry"],
[data-theme="dark"] .portal__content [class*="result"],
[data-theme="dark"] .portal__content [class*="preview"] {
    background-color: var(--color-bg-white) !important;
    border-color: var(--color-border) !important;
}

/* Table header rows */
[data-theme="dark"] .portal__content thead,
[data-theme="dark"] .portal__content th {
    background-color: var(--color-table-header) !important;
    color: var(--color-text-muted) !important;
}

[data-theme="dark"] .portal__content table,
[data-theme="dark"] .portal__content tbody {
    background-color: var(--color-bg-white) !important;
}

[data-theme="dark"] .portal__content tr:hover td {
    background-color: var(--color-table-hover) !important;
}

/* All inputs, selects, textareas */
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--color-bg-white) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--color-text-light) !important;
}

[data-theme="dark"] select option {
    background: var(--color-bg-white) !important;
    color: var(--color-text) !important;
}

/* Modals */
[data-theme="dark"] .modal,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dialog,
[data-theme="dark"] .popup {
    background: var(--color-bg-white) !important;
    border-color: var(--color-border) !important;
}

/* Buttons */
[data-theme="dark"] .portal__content button {
    border-color: var(--color-border) !important;
}

/* Buttons with explicit colored bg stay as-is; generic buttons → dark surface */
[data-theme="dark"] .portal__content button:not([class*="primary"]):not([class*="danger"]):not([class*="success"]):not([class*="delete"]):not([class*="save"]):not([class*="add"]):not([class*="confirm"]):not([style*="background: #4f46e5"]):not([style*="background: #dc2626"]):not([style*="background: #ef4444"]) {
    background-color: var(--color-bg-white) !important;
    color: var(--color-text) !important;
}

/* Colored buttons keep white text */
[data-theme="dark"] .portal__content button[class*="primary"],
[data-theme="dark"] .portal__content button[class*="save"],
[data-theme="dark"] .portal__content button[class*="confirm"],
[data-theme="dark"] .portal__content button[class*="add"],
[data-theme="dark"] .btn--primary,
[data-theme="dark"] .btn--danger,
[data-theme="dark"] .btn--success {
    color: #fff !important;
}

/* ===========================================
   RE-APPLY: Semantic colors (badges, status)
   =========================================== */

/* ===========================================
   Badge/Status universal dark mode
   All [class*="badge"] and [class*="status"] get dark treatment,
   then specific color variants override.
   =========================================== */

/* Base: all badges get dark surface + light text by default */
[data-theme="dark"] .portal__content [class*="badge"],
[data-theme="dark"] .portal__content [class*="status-"],
[data-theme="dark"] .portal__content [class*="status--"] {
    background-color: var(--color-bg) !important;
    color: var(--color-text-muted) !important;
    border-color: var(--color-border) !important;
}

/* Green variants */
[data-theme="dark"] .portal__content [class*="success"],
[data-theme="dark"] .portal__content [class*="--ok"],
[data-theme="dark"] .portal__content [class*="--green"],
[data-theme="dark"] .portal__content [class*="--angenommen"],
[data-theme="dark"] .portal__content [class*="--vollstaendig"],
[data-theme="dark"] .portal__content [class*="--aktiv"],
[data-theme="dark"] .portal__content [class*="--active"],
[data-theme="dark"] .portal__content [class*="--enabled"],
[data-theme="dark"] .portal__content [class*="--entschuldigt"],
[data-theme="dark"] .portal__content [class*="--confirmed"],
[data-theme="dark"] .portal__content [class*="--visible"],
[data-theme="dark"] .portal__content [class*="--post"],
[data-theme="dark"] .portal__content [class*="--praktisch"],
[data-theme="dark"] .portal__content [class*="--2xx"] {
    background-color: rgba(74, 222, 128, 0.15) !important;
    color: #86efac !important;
}

/* Red variants */
[data-theme="dark"] .portal__content [class*="danger"],
[data-theme="dark"] .portal__content [class*="error"],
[data-theme="dark"] .portal__content [class*="--red"],
[data-theme="dark"] .portal__content [class*="--absage"],
[data-theme="dark"] .portal__content [class*="--fehlerhaft"],
[data-theme="dark"] .portal__content [class*="--missing"],
[data-theme="dark"] .portal__content [class*="--abgelehnt"],
[data-theme="dark"] .portal__content [class*="--overdue"],
[data-theme="dark"] .portal__content [class*="--delete"],
[data-theme="dark"] .portal__content [class*="--defekt"],
[data-theme="dark"] .portal__content [class*="--5xx"] {
    background-color: rgba(248, 113, 113, 0.15) !important;
    color: #fca5a5 !important;
}

/* Yellow/Orange variants */
[data-theme="dark"] .portal__content [class*="warning"],
[data-theme="dark"] .portal__content [class*="--pending"],
[data-theme="dark"] .portal__content [class*="--yellow"],
[data-theme="dark"] .portal__content [class*="--orange"],
[data-theme="dark"] .portal__content [class*="--warteliste"],
[data-theme="dark"] .portal__content [class*="--bearbeitung"],
[data-theme="dark"] .portal__content [class*="--unread"],
[data-theme="dark"] .portal__content [class*="--geprueft"],
[data-theme="dark"] .portal__content [class*="--patch"],
[data-theme="dark"] .portal__content [class*="--reparatur"],
[data-theme="dark"] .portal__content [class*="--4xx"],
[data-theme="dark"] .portal__content [class*="--unvollstaendig"] {
    background-color: rgba(251, 191, 36, 0.15) !important;
    color: #fde68a !important;
}

/* Blue variants */
[data-theme="dark"] .portal__content [class*="--info"],
[data-theme="dark"] .portal__content [class*="--blue"],
[data-theme="dark"] .portal__content [class*="--beworben"],
[data-theme="dark"] .portal__content [class*="--bearbeitet"],
[data-theme="dark"] .portal__content [class*="--gemeldet"],
[data-theme="dark"] .portal__content [class*="--upload"],
[data-theme="dark"] .portal__content [class*="--put"],
[data-theme="dark"] .portal__content [class*="--class"],
[data-theme="dark"] .portal__content [class*="--muendlich"],
[data-theme="dark"] .portal__content [class*="--3xx"],
[data-theme="dark"] .portal__content [class*="level-info"] {
    background-color: rgba(96, 165, 250, 0.15) !important;
    color: #93c5fd !important;
}

/* Purple variants */
[data-theme="dark"] .portal__content [class*="--purple"],
[data-theme="dark"] .portal__content [class*="--praesentation"],
[data-theme="dark"] .portal__content [class*="--veranstaltung"],
[data-theme="dark"] .portal__content [class*="--subject"],
[data-theme="dark"] .portal__content [class*="--klausur"] {
    background-color: rgba(167, 139, 250, 0.15) !important;
    color: #c4b5fd !important;
}

/* Neutral/gray variants */
[data-theme="dark"] .portal__content [class*="--default"],
[data-theme="dark"] .portal__content [class*="--neutral"],
[data-theme="dark"] .portal__content [class*="--sonstiges"],
[data-theme="dark"] .portal__content [class*="--archived"],
[data-theme="dark"] .portal__content [class*="--disabled"],
[data-theme="dark"] .portal__content [class*="--inactive"],
[data-theme="dark"] .portal__content [class*="--gray"],
[data-theme="dark"] .portal__content [class*="--grey"],
[data-theme="dark"] .portal__content [class*="--get"],
[data-theme="dark"] .portal__content [class*="--ausgemustert"] {
    background-color: var(--color-bg) !important;
    color: var(--color-text-muted) !important;
}

/* Counter/pill badges (scoped __count classes with hardcoded light bg) */
[data-theme="dark"] .portal__content [class*="__count"],
[data-theme="dark"] .portal__content [class*="-count"],
[data-theme="dark"] .portal__content [class*="-legal"],
[data-theme="dark"] .portal__content [class*="-badge"],
[data-theme="dark"] .portal__content [class*="id-badge"] {
    background-color: var(--color-bg) !important;
    color: var(--color-text-muted) !important;
    border-color: var(--color-border) !important;
}

/* Scoped badge color overrides — these badges have scoped styles with light-mode colors.
   We match common class patterns and force dark-mode colors with !important. */
[data-theme="dark"] .portal__content [class*="-badge--level-info"],
[data-theme="dark"] .portal__content [class*="-badge--method-put"],
[data-theme="dark"] .portal__content [class*="-badge--update"],
[data-theme="dark"] .portal__content [class*="-badge--entity"],
[data-theme="dark"] .portal__content [class*="-badge--user"],
[data-theme="dark"] .portal__content [class*="-badge--sachbearbeiter"] {
    background-color: rgba(96, 165, 250, 0.15) !important;
    color: #93c5fd !important;
}

[data-theme="dark"] .portal__content [class*="-badge--level-warning"],
[data-theme="dark"] .portal__content [class*="-badge--method-patch"],
[data-theme="dark"] .portal__content [class*="-badge--login"] {
    background-color: rgba(251, 191, 36, 0.15) !important;
    color: #fde68a !important;
}

[data-theme="dark"] .portal__content [class*="-badge--level-error"],
[data-theme="dark"] .portal__content [class*="-badge--method-delete"],
[data-theme="dark"] .portal__content [class*="-badge--delete"] {
    background-color: rgba(248, 113, 113, 0.15) !important;
    color: #fca5a5 !important;
}

[data-theme="dark"] .portal__content [class*="-badge--method-post"],
[data-theme="dark"] .portal__content [class*="-badge--create"],
[data-theme="dark"] .portal__content [class*="-badge--lehrkraft"] {
    background-color: rgba(74, 222, 128, 0.15) !important;
    color: #86efac !important;
}

[data-theme="dark"] .portal__content [class*="-badge--method-get"],
[data-theme="dark"] .portal__content [class*="-badge--default"] {
    background-color: var(--color-bg) !important;
    color: var(--color-text-muted) !important;
}

[data-theme="dark"] .portal__content [class*="-badge--admin"] {
    background-color: rgba(244, 114, 182, 0.15) !important;
    color: #f9a8d4 !important;
}

/* Warning/info boxes with scoped light-mode colors */
[data-theme="dark"] .portal__content [class*="-warning"] {
    background-color: rgba(251, 191, 36, 0.1) !important;
    border-color: rgba(251, 191, 36, 0.3) !important;
    color: #fde68a !important;
}

[data-theme="dark"] .portal__content [class*="-warning"] li,
[data-theme="dark"] .portal__content [class*="-warning"] p {
    color: #fde68a !important;
}

/* Inline style overrides for badges (inline style= attributes) */
[data-theme="dark"] [style*="background: #dcfce7"],
[data-theme="dark"] [style*="background: #d1fae5"],
[data-theme="dark"] [style*="background: #f0fdf4"],
[data-theme="dark"] [style*="background-color: #dcfce7"],
[data-theme="dark"] [style*="background-color: #d1fae5"] {
    background: rgba(74, 222, 128, 0.15) !important;
}

[data-theme="dark"] [style*="background: #fee2e2"],
[data-theme="dark"] [style*="background: #fef2f2"],
[data-theme="dark"] [style*="background: #fecaca"],
[data-theme="dark"] [style*="background-color: #fee2e2"],
[data-theme="dark"] [style*="background-color: #fef2f2"] {
    background: rgba(248, 113, 113, 0.15) !important;
}

[data-theme="dark"] [style*="background: #fef3c7"],
[data-theme="dark"] [style*="background: #fffbeb"],
[data-theme="dark"] [style*="background: #fef9c3"],
[data-theme="dark"] [style*="background-color: #fef3c7"] {
    background: rgba(251, 191, 36, 0.15) !important;
}

[data-theme="dark"] [style*="background: #dbeafe"],
[data-theme="dark"] [style*="background: #eff6ff"],
[data-theme="dark"] [style*="background: #eef2ff"],
[data-theme="dark"] [style*="background: #e0e7ff"],
[data-theme="dark"] [style*="background-color: #dbeafe"],
[data-theme="dark"] [style*="background-color: #eef2ff"],
[data-theme="dark"] [style*="background: #e0f2fe"] {
    background: rgba(96, 165, 250, 0.15) !important;
}

[data-theme="dark"] [style*="background: #fff7ed"],
[data-theme="dark"] [style*="background: #ffedd5"],
[data-theme="dark"] [style*="background-color: #fff7ed"] {
    background: rgba(251, 146, 60, 0.15) !important;
}

[data-theme="dark"] [style*="background: #f3e8ff"],
[data-theme="dark"] [style*="background: #ede9fe"],
[data-theme="dark"] [style*="background-color: #f3e8ff"] {
    background: rgba(167, 139, 250, 0.15) !important;
}

/* White/light backgrounds via inline styles */
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background-color: #fff"],
[data-theme="dark"] [style*="background-color: white"],
[data-theme="dark"] [style*="background: #f9fafb"],
[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background: #f3f4f6"],
[data-theme="dark"] [style*="background: #f7fafc"],
[data-theme="dark"] [style*="background-color: #f9fafb"],
[data-theme="dark"] [style*="background-color: #f3f4f6"] {
    background: var(--color-bg-white) !important;
}

/* Inline dark text → light */
[data-theme="dark"] [style*="color: #111827"],
[data-theme="dark"] [style*="color:#111827"],
[data-theme="dark"] [style*="color: #1f2937"],
[data-theme="dark"] [style*="color:#1f2937"],
[data-theme="dark"] [style*="color: #1e293b"],
[data-theme="dark"] [style*="color: #2d3748"],
[data-theme="dark"] [style*="color: #333"],
[data-theme="dark"] [style*="color:#333"] {
    color: var(--color-text) !important;
}

[data-theme="dark"] [style*="color: #374151"],
[data-theme="dark"] [style*="color:#374151"],
[data-theme="dark"] [style*="color: #4b5563"],
[data-theme="dark"] [style*="color: #475569"],
[data-theme="dark"] [style*="color: #666"],
[data-theme="dark"] [style*="color:#666"] {
    color: var(--color-text-secondary) !important;
}

[data-theme="dark"] [style*="color: #6b7280"],
[data-theme="dark"] [style*="color:#6b7280"],
[data-theme="dark"] [style*="color: #64748b"],
[data-theme="dark"] [style*="color: #718096"] {
    color: var(--color-text-muted) !important;
}

[data-theme="dark"] [style*="color: #9ca3af"],
[data-theme="dark"] [style*="color:#9ca3af"],
[data-theme="dark"] [style*="color: #d1d5db"] {
    color: var(--color-text-light) !important;
}

/* Inline semantic text colors → light versions */
[data-theme="dark"] [style*="color: #166534"],
[data-theme="dark"] [style*="color: #065f46"],
[data-theme="dark"] [style*="color: #15803d"],
[data-theme="dark"] [style*="color: #16a34a"],
[data-theme="dark"] [style*="color: #059669"] {
    color: #86efac !important;
}

[data-theme="dark"] [style*="color: #991b1b"],
[data-theme="dark"] [style*="color: #b91c1c"],
[data-theme="dark"] [style*="color: #dc2626"],
[data-theme="dark"] [style*="color: #ef4444"] {
    color: #fca5a5 !important;
}

[data-theme="dark"] [style*="color: #92400e"],
[data-theme="dark"] [style*="color: #854d0e"],
[data-theme="dark"] [style*="color: #b45309"],
[data-theme="dark"] [style*="color: #d97706"],
[data-theme="dark"] [style*="color: #a16207"] {
    color: #fde68a !important;
}

[data-theme="dark"] [style*="color: #1e40af"],
[data-theme="dark"] [style*="color: #1d4ed8"],
[data-theme="dark"] [style*="color: #2563eb"] {
    color: #93c5fd !important;
}

[data-theme="dark"] [style*="color: #ea580c"],
[data-theme="dark"] [style*="color: #c2410c"] {
    color: #fdba74 !important;
}

[data-theme="dark"] [style*="color: #6d28d9"],
[data-theme="dark"] [style*="color: #7c3aed"] {
    color: #c4b5fd !important;
}

/* Inline border overrides */
[data-theme="dark"] [style*="border: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border: 1px solid #e2e8f0"],
[data-theme="dark"] [style*="border: 1px solid #d1d5db"],
[data-theme="dark"] [style*="border-bottom: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-top: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-color: #e5e7eb"],
[data-theme="dark"] [style*="border-top: 1px solid #374151"] {
    border-color: var(--color-border) !important;
}

/* ===========================================
   Scrollbar, links, misc
   =========================================== */

[data-theme="dark"] ::-webkit-scrollbar { width: 8px; height: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--color-bg); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--color-border-dark); border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #5e6b82; }

[data-theme="dark"] hr { border-color: var(--color-border) !important; }
[data-theme="dark"] code, [data-theme="dark"] pre {
    background: var(--color-bg) !important;
    color: var(--color-text) !important;
}
