/* =========================
   Basis-Theme (Light & Dark)
   ========================= */

:root {
    /* Default = light */
    --bg-main: #f3f4f6;
    --bg-page: #f9fafb;
    --bg-card: #ffffff;
    --bg-card-soft: #f3f4f6;
    --bg-table: #ffffff;
    --bg-table-alt: #f9fafb;
    --bg-table-header: #f3f4f6;

    --border-subtle: #e5e7eb;
    --border-strong: #d1d5db;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-soft: #9ca3af;
    --text-inverted: #f9fafb;

    --badge-ok-bg: #dcfce7;
    --badge-ok-border: #22c55e;
    --badge-ok-text: #166534;

    --badge-warn-bg: #fef3c7;
    --badge-warn-border: #f59e0b;
    --badge-warn-text: #92400e;

    --badge-error-bg: #fee2e2;
    --badge-error-border: #ef4444;
    --badge-error-text: #991b1b;

    --shadow-card: 0 10px 30px rgba(15, 23, 42, 0.12);
}

html[data-theme="dark"] {
    color-scheme: dark;

    --bg-main: radial-gradient(circle at top, #0f172a 0, #020617 55%);
    --bg-page: transparent;
    --bg-card: rgba(15, 23, 42, 0.92);
    --bg-card-soft: #020617;
    --bg-table: radial-gradient(circle at top, rgba(15,23,42,0.98) 0, #020617 55%);
    --bg-table-alt: rgba(15, 23, 42, 0.8);
    --bg-table-header: #020617;

    --border-subtle: #1f2937;
    --border-strong: #374151;

    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --text-soft: #6b7280;
    --text-inverted: #020617;

    --badge-ok-bg: #022c22;
    --badge-ok-border: #16a34a;
    --badge-ok-text: #bbf7d0;

    --badge-warn-bg: #451a03;
    --badge-warn-border: #f97316;
    --badge-warn-text: #fed7aa;

    --badge-error-bg: #450a0a;
    --badge-error-border: #b91c1c;
    --badge-error-text: #fecaca;

    --shadow-card: 0 18px 45px rgba(0, 0, 0, 0.8);
}

/* ============
   Grundlayout
   ============ */

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg-main);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: #38bdf8;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Breiteres Layout */
.page {
    max-width: 1320px;          /* wieder breit */
    margin: 0 auto;
    padding: 20px 16px 28px;
    background: var(--bg-page);
}

/* Header */

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

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: radial-gradient(circle at 30% 0, #22c55e 0, #0f172a 45%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dcfce7;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.7);
}

h1 {
    margin: 0;
    font-size: 1.6rem;
}
.subtitle {
    margin: 2px 0 0;
    font-size: 0.86rem;
    color: var(--text-soft);
}

.user-info-top {
    text-align: right;
    font-size: 0.82rem;
    color: var(--text-soft);
}
.user-info-top strong {
    color: var(--text-main);
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #4c1d95;
    color: #e9d5ff;
    font-size: 0.78rem;
    border: 1px solid #7c3aed;
}

/* Navigation */

.nav-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 9999px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.84rem;
    cursor: pointer;
    text-decoration: none;
}
.nav-link:hover {
    background: var(--bg-card-soft);
}
.nav-link.active {
    border-color: #22c55e;
    background: #064e3b;
    color: #bbf7d0;
}

/* Layout mit Sidebar */

.layout {
    display: grid;
    grid-template-columns: minmax(0, 2.8fr) minmax(280px, 1fr); /* mehr Platz für Hauptbereich */
    gap: 20px;
}

/* ab 1200px einspaltig (Sidebar unten) */
@media (max-width: 1200px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Karte / Panel */

.card {
    background: var(--bg-card);
    border-radius: 18px;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-card);
    padding: 16px 16px 18px;
}

.card h2 {
    margin: 0 0 6px;
    font-size: 1.05rem;
}
.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-bottom: 10px;
}

/* =========
   Buttons
   ========= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 9999px;
    border: 1px solid var(--border-subtle);
    background: #111827;
    color: #e5e7eb;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}
html[data-theme="light"] .btn {
    background: #e5e7eb;
    color: #111827;
}
.btn:hover {
    filter: brightness(1.05);
}

.btn-secondary {
    border-color: #6b7280;
    background: #020617;
}
html[data-theme="light"] .btn-secondary {
    background: #e5e7eb;
}

.btn-primary {
    border-color: #2563eb;
    background: #1d4ed8;
}

.btn-admin {
    border-color: #8b5cf6;
    background: #6d28d9;
}

.btn-warning {
    border-color: #ef4444;
    background: #7f1d1d;
    color: #fee2e2;
}
html[data-theme="light"] .btn-warning {
    background: #fee2e2;
    color: #991b1b;
}

.btn-success {
    border-color: #22c55e;
    background: #14532d;
    color: #bbf7d0;
}
html[data-theme="light"] .btn-success {
    background: #dcfce7;
    color: #166534;
}

.btn-logout {
    border-color: #f97316;
    background: #7c2d12;
    color: #fed7aa;
}
html[data-theme="light"] .btn-logout {
    background: #f97316;
    color: #fff;
}

.btn-small {
    font-size: 0.78rem;
    padding: 4px 10px;
}
.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card-soft);
    font-size: 0.8rem;
    cursor: pointer;
}

/* =======
   Messages
   ======= */

.message {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
}
.message.error {
    background: #7f1d1d;
    color: #fecaca;
    border: 1px solid #b91c1c;
}
html[data-theme="light"] .message.error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #ef4444;
}

.admin-notice {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    background: var(--bg-card-soft);
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

/* ==========
   Stat-Kacheln
   ========== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); /* etwas breiter */
    gap: 12px;
    margin-bottom: 10px;
}
.stat-card {
    background: var(--bg-card-soft);
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    padding: 10px 10px 12px;
}
.stat-label {
    font-size: 0.78rem;
    color: var(--text-soft);
    margin-bottom: 4px;
}
.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
}
.stat-meta {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* Footer-Stats (werden von index.php genutzt) */

.footer-stats .stats-grid {
    gap: 8px;
}
.stat-item {
    background: var(--bg-card-soft);
    border-radius: 10px;
    padding: 6px 8px;
    border: 1px solid var(--border-subtle);
}
.stat-item .stat-label {
    font-size: 0.78rem;
    color: var(--text-soft);
}
.stat-item .stat-value {
    font-size: 0.95rem;
    font-weight: 600;
}

/* =======
   Badges
   ======= */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 500;
}

.badge-green {
    background: var(--badge-ok-bg);
    border: 1px solid var(--badge-ok-border);
    color: var(--badge-ok-text);
}
.badge-amber {
    background: var(--badge-warn-bg);
    border: 1px solid var(--badge-warn-border);
    color: var(--badge-warn-text);
}
.badge-red {
    background: var(--badge-error-bg);
    border: 1px solid var(--badge-error-border);
    color: var(--badge-error-text);
}

/* =========
   Tabelle
   ========= */

.table-container {
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    background: var(--bg-table);
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
table.table th,
table.table td {
    padding: 6px 8px;
    border-bottom: 1px solid #111827;
}
html[data-theme="light"] table.table th,
html[data-theme="light"] table.table td {
    border-bottom-color: #e5e7eb;
}
table.table th {
    text-align: left;
    background: var(--bg-table-header);
    color: var(--text-soft);
    font-weight: 500;
    white-space: nowrap;
}
table.table tbody tr:nth-child(2n) {
    background: var(--bg-table-alt);
}

/* =========
   Footer
   ========= */

footer {
    margin-top: 16px;
    padding: 10px 8px 18px;
}

.system-info-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-soft);
}

/* =========
   Sonstige
   ========= */

.hint {
    font-size: 0.84rem;
    color: var(--text-soft);
    line-height: 1.4;
    margin-top: 4px;
}
.hint code {
    background: var(--bg-card-soft);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border-subtle);
}

/* Quick-Tipps & Actions – mehr Platz in der Breite */

.quick-tips {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--bg-card-soft);
    border: 1px solid var(--border-subtle);
}
.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* breiter */
    gap: 10px;
    margin-top: 6px;
    font-size: 0.8rem;
}
.tip-item {
    color: var(--text-soft);
}

/* Aktionen-Grid (oben) */

.actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin: 18px 0 20px;
    padding: 14px;
    background: var(--bg-card-soft);
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
}
.actions .btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    min-height: 72px;
    font-size: 1rem;
}
.actions .btn small {
    font-size: 0.78rem;
}

/* Live-Suche – Grundoptik, Rest kommt aus index.php Inline-CSS */

.live-search-container {
    background: var(--bg-card-soft);
    border-radius: 14px;
    padding: 16px 14px;
    margin: 14px 0 18px;
    border: 1px solid var(--border-subtle);
}

/* Responsive */

@media (max-width: 900px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .user-info-top {
        text-align: left;
    }
    .nav-bar {
        gap: 6px;
    }
}

@media (max-width: 768px) {
    .page {
        padding: 16px 10px 20px;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    .tips-grid {
        grid-template-columns: 1fr;
    }
    .table-container {
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .nav-link {
        font-size: 0.78rem;
        padding: 4px 8px;
    }
    .header-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

/* Kleine Helfer */

mark {
    background-color: #fef3c7;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.page-header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px 10px;
    background: radial-gradient(circle at top left, #22c55e22 0, transparent 55%),
                #020617;
    border-radius: 20px 20px 0 0;
    border-bottom: 1px solid rgba(148,163,184,0.3);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.header-icon-main {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: radial-gradient(circle at top, #22c55e 0, #16a34a 60%, #166534 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #ecfdf5;
    box-shadow: 0 10px 25px rgba(22,163,74,0.7);
}
.page-header-main h1 {
    margin: 0;
    font-size: 1.6rem;
    color: #e5e7eb;
    font-weight: 800;
}
.header-subtitle {
    margin: 2px 0 0;
    color: #9ca3af;
    font-size: 0.9rem;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.user-info-top {
    text-align: right;
    color: #e5e7eb;
    font-size: 0.85rem;
}
.admin-badge-main {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fffbeb;
    font-size: 0.75rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.btn-top {
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,0.6);
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: rgba(15,23,42,0.95);
    color: #e5e7eb;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.btn-top:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(15,23,42,0.6);
}
.btn-top-secondary { }
.btn-top-theme {
    background: #facc15;
    color: #1f2933;
    border-color: #facc15;
}
.btn-top-danger {
    background: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%);
    border-color: #fecaca;
}

.nav-tabs-main {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 22px 14px;
    background: #020617;
    border-radius: 0 0 16px 16px;
    border-bottom: 1px solid rgba(148,163,184,0.35);
}
.nav-tab {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: rgba(15,23,42,0.9);
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.nav-tab:hover {
    background: rgba(30,64,175,0.6);
}
.nav-tab.active {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-color: rgba(34,197,94,0.8);
    color: #ecfdf5;
    font-weight: 600;
}

/* Mobile */
@media (max-width: 768px) {
    .page-header-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .header-right {
        align-items: flex-start;
    }
    .user-info-top {
        text-align: left;
    }
}