html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

body > section,
body > .navbar,
body > footer {
    flex-shrink: 0;
}

#stats {
    flex: 1 0 auto;
    position: relative; /* NEU! */
}
/* ===== Grid für alle Statistik-Tabellen ===== */
.stats-container {
    display: grid;
    /* statt 300px nun mindestens 350px pro Spalte */
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5em;

    /* maximaler Gesamtbreite, zentriert */
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1em;
}

/* Table Wrapper bleibt wie gehabt */
.table-wrapper {
    background-color: rgba(30, 30, 30, 0.8);
    border-radius: 8px;
    overflow: hidden;
}

/* Gemeinsame Tabellen-Regeln */
table {
    width: 100%;
    border-collapse: collapse;
    color: white;
}
th,
td {
    padding: 15px;
    text-align: left;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    vertical-align: middle;
}
/* Caption oben bündig zum Header */
caption {
    caption-side: top;
    display: table-caption;
    padding: 10px 15px;
    font-size: 1.1em;
    font-weight: bold;
    color: #f1f1f1;
    background-color: #4a4a4a;
    text-align: left;
    margin-bottom: 0;
}
/* Icon in der Caption */
caption .fa-caption-icon {
    margin-right: 8px;
    color: #e0b800;
    font-size: 1.2em;
    vertical-align: middle;
}
/* Header-Zellen: nur eine gelbe Linie darunter */
thead th {
    background-color: #4a4a4a;
    color: white;
    font-weight: bold;
    border-bottom: 2px solid #e0b800;
}

td.name-cell img {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    margin-right: 8px;
}
/* Wert-Spalte (alle Tabellen: 4. oder 3. Spalte je nach Tabelle) */
/* wir heben in jedem Table die letzte Spalte gelb hervor */
table td:last-child {
    color: #e0b800;
    font-family: Consolas, monospace;
}
/* Medaillen für Platz 1–3 */
.medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.9em;
    font-weight: bold;
}
.medal-gold {
    background-color: rgba(224, 184, 0, 0.2);
    color: #e0b800;
}
.medal-silver {
    background-color: rgba(192, 192, 192, 0.2);
    color: #c0c0c0;
}
.medal-bronze {
    background-color: rgba(205, 127, 50, 0.2);
    color: #cd7f32;
}
/* Hover-Effekt */
tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Mobile: Tabellen untereinander */
@media (max-width: 768px) {
    .stats-container {
        grid-template-columns: 1fr;
    }
}

/* Pagination-Buttons unter jeder Tabelle */
.pagination {
    display: flex;
    justify-content: flex-end;
    padding: 10px;
}
.pagination button {
    background-color: #2e2e2e;
    color: white;
    border: none;
    padding: 8px 12px;
    margin-left: 5px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.pagination button:disabled {
    opacity: 0.5;
    cursor: default;
}
.pagination button:not(:disabled):hover {
    background-color: #3e3e3e;
}

.table-wrapper {
    position: relative;
}

/* Spinner über der Tabelle absolut positionieren */
.table-wrapper {
    position: relative;
}
.table-wrapper .loading {
    position: absolute;
    top: 50%;
    left: 50%;
    /* Start: zentriert und ohne Rotation */
    transform: translate(-50%, -50%) rotate(0deg);
    width: 24px;
    height: 24px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #e0b800;
    border-radius: 50%;
    z-index: 10;
    /* Animation: kombiniere translate+rotate in den Keyframes */
    animation: spin 1s linear infinite;
    margin: 0; /* auf Nummer sicher */
}

/* Keyframes: translate+rotate gemeinsam animieren */
@keyframes spin {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Overlay, das den Tabellen hintergrund abdunkelt */
.table-wrapper .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9; /* unter dem Spinner (z-index 10) */
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

/* Spinner bleibt unverändert, nur der z-index */
.table-wrapper .loading {
    z-index: 10;
}

/* Verhindere Zeilen-Umbrechen in allen Statistik-Tabellen */
.stats-container .table-wrapper table th,
.stats-container .table-wrapper table td {
    white-space: nowrap;
}

/* Erlaube nur horizontales Scrollen, statt dass Zeilen sich verschieben */
.stats-container .table-wrapper {
    overflow-x: auto;
}

/* Flex-Wrapper IMMER innerhalb der TDs */
.name-cell {
    display: flex;
    align-items: center;
}
.name-cell img {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    margin-right: 8px;
}

/* Sicherstellen, dass alle Zellen als Table-Cell gerendert werden */
table {
    border-collapse: collapse;
    border-spacing: 0;
}
th,
td {
    vertical-align: middle;
}

/* Nur den Daten-Zellen (td) die Zahl zentriert ausrichten */
.stats-container .table-wrapper table td:first-child {
    text-align: center;
}

/* Dem Header (th) nur die Breite geben, aber die normale Padding behalten */
.stats-container .table-wrapper table th:first-child {
    width: 40px;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5em;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1em;
    box-sizing: border-box;
}

/* Server-König über alle Spalten hinweg */
#wrapper-server-king {
    grid-column: 1 / -1;
    margin-bottom: 1.5em; /* Abstand zu den folgenden Tabellen */
}

/* Info-Icon in der Caption */
.info-icon {
    margin-left: 8px;
    color: #e0b800;
    cursor: pointer;
    float: right; /* rechts oben in der Caption */
    font-size: 1em;
}

/* Modal-Overlay */
.modal {
    display: none; /* versteckt */
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: #2e2e2e;
    color: #f1f1f1;
    padding: 1.5em;
    border-radius: 8px;
    max-width: 400px;
    margin: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 0.5em;
    right: 0.8em;
    font-size: 1.2em;
    cursor: pointer;
}
.modal-content h2 {
    margin-top: 0;
}
.modal-content ul {
    padding-left: 1.2em;
}

/* ===== dezentes Highlight für Server-König ===== */
#wrapper-server-king {
    grid-column: 1 / -1; /* volle Breite des Grids */
    background-color: rgba(224, 184, 0, 0.08);
    border: 1px solid rgba(224, 184, 0, 0.5);
    border-radius: 8px;
    padding: 0.5em;
    margin-bottom: 1.5em;
}
#stats-table-king caption {
    background-color: #3a3a3a;
    color: #e0b800;
    font-size: 1.2em;
    border-bottom: none;
}
#stats-table-king thead th {
    background-color: #3a3a3a;
    color: #e0b800;
    border-bottom: 1px solid rgba(224, 184, 0, 0.8);
}
#stats-table-king td:last-child {
    color: #e0b800;
    font-weight: bold;
}
#stats-table-king tbody tr:hover {
    background-color: rgba(224, 184, 0, 0.15);
}

/* Extra-Luft im Server-König-Modal */
#king-info-modal .modal-content p,
#king-info-modal .modal-content ul,
#king-info-modal .modal-content li {
    line-height: 1.6;
}

.search-container {
    grid-column: 1 / -1; /* volle Breite über alle Spalten */
    margin-bottom: 1em;
    text-align: right; /* Suchfeld rechtsbündig */
}
.search-input {
    width: 300px; /* feste Breite wie Haupt-Suche */
    max-width: 100%; /* nicht über Container hinausragen */
    padding: 0.75rem 1rem; /* Innenabstand (oben/unten 0.75rem, links/rechts 1rem) */
    font-size: 1.1rem; /* etwas größere Schrift */
    height: 2.5rem; /* definierte Höhe */
    border-radius: 6px; /* gleicher Radius */
    border: 2px solid #ccc; /* gleicher Rahmen */
    background-color: #1e1e1e;
    color: #fff;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

/* Suchpanel-Design (im Stil Deiner Tabellen) */
.search-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    width: 100%;
    margin: 0 auto;
    padding: 1em;
    position: relative;
    align-items: center;
    background: rgba(30, 30, 30, 0.8);
    box-sizing: border-box;
}

.search-field {
    position: relative;
    display: flex;
    align-items: center;
    background: #1e1e1e;
    padding: 0.5em;
    border: 2px solid #ccc;
    border-radius: 6px;
    width: 90%;
    max-width: 400px;
}

.search-field i {
    margin-right: 0.5em;
    color: #aaa;
}

.search-field input,
.search-field select {
    background: transparent;
    border: none;
    color: white;
    font-size: 1em;
    width: 100%;
}

.search-field input:focus,
.search-field:focus-within {
    outline: none;
    border-color: #e0b800;
}

/* Grund-Styling für das Select selbst */
.search-field select {
    background-color: #1e1e1e;
    color: white;
}

/* Alle Optionen dunkelgrau mit weißem Text */
.search-field select option {
    background-color: #1e1e1e;
    color: white;
    width: 100%;
}

/* Ausgewählte Option (bei Mehrfach-Select auch gehaltene Auswahl) */
.search-field select option:checked {
    background-color: #2e2e2e;
    color: #e0b800;
}

/* Hover-Effekt für Optionen */
.search-field select option:hover {
    background-color: #2e2e2e;
    color: #e0b800;
}

.search-field select:focus {
    outline: none; /* entfernt den inneren Fokus-Rahmen */
}

/* Für den Mehrfach-Select: etwas mehr Breite */
.search-field select[multiple] {
    min-width: 12em;
}

.search-field select,
.search-field {
    position: relative; /* schon vorhanden, aber zur Sicherheit */
}

/* Reset-Button */
.search-reset {
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 12px 12px; /* oben/unten 12px, rechts/links 12px */
    font-size: 16px;
    line-height: 1; /* keine zusätzliche Höhe */
    cursor: pointer;
    margin-left: 1em;
    outline: none;
}

.search-reset:hover,
.search-reset:focus {
    background: #9e3226;
    outline: none;
}

#search-rank-min {
    margin-right: 0.5rem; /* Abstand nach Bedarf anpassen */
}

/* Toggle-Button direkt neben der Suche */
.filter-toggle {
    background-color: #e0b800; /* Goldgelb */
    border: none;
    padding: 0.6em 1.2em;
    font-size: 1em;
    border-radius: 4px;
    cursor: pointer;
    color: #1e1e1e; /* dunkler Kontrasttext */
    display: flex;
    align-items: center;
    gap: 0.3em;
}

/* Filter-Panel versteckt */
.filter-panel {
    display: none;
    flex-wrap: wrap;
    gap: 1em;
    width: 100%;
    background: rgba(30, 30, 30, 0.8);
    padding: 1em;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    margin-top: 0.5em;
}

/* Wenn “geöffnet” */
.search-panel.expanded .filter-panel {
    display: flex;
}

/* -------- Wrapper: nimmt volle Breite ein und richtet Inhalt rechts aus - */
#timestamp-wrapper {
    display: flex;
    justify-content: flex-end; /* rechts bündig */
}

/* -------- Badge selbst: bleibt unverändert, jetzt OHNE eigenes position -- */
.stats-timestamp {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;

    background: rgba(30, 30, 30, 0.85);
    color: #e0b800;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid rgba(224, 184, 0, 0.3);
    border-radius: 0 0 0 8px;
    backdrop-filter: blur(2px);
    user-select: none;
}
.stats-timestamp i {
    font-size: 1rem;
    line-height: 1;
}

/* Optional: leichter Hover-Glow */
.stats-timestamp:hover {
    background: rgba(30, 30, 30, 0.92);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

/* ============================= */
/* Offene-Beta Hinweisbox oben   */
/* ============================= */

.beta-warning {
    /* Spannt das Element über alle Spalten der stats-container */
    grid-column: 1 / -1;

    position: relative;
    display: flex;
    align-items: center;
    box-sizing: border-box; /* Padding/Rand wird in die Breite eingerechnet */

    background-color: #fff3cd; /* helle Gelbtönung */
    border: 1px solid #ffeeba; /* etwas dunklerer Rahmen */
    color: #856404; /* dunkelgelber Text */

    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px; /* Abstand nach unten zum Tabellen-Wrapper */

    font-size: 1rem;
    line-height: 1.4;
}

.beta-warning .warning-icon {
    margin-right: 10px;
    font-size: 1.2rem;
}

.beta-warning .warning-text {
    flex: 1;
}

.beta-warning .warning-close {
    position: absolute;
    top: 8px;
    right: 12px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: #856404;
}

.beta-warning .warning-close:hover {
    color: #5f421d; /* etwas dunkler beim Hover */
}

/* Keine Ergebnisse Hinweis */
.no-results-warning {
    grid-column: 1 / -1;
    display: none; /* per JS sichtbar */
    position: relative;
    align-items: center;
    background-color: #f8d7da;
    border: 1px solid #f5c2c7;
    color: #842029;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.4;
}
.no-results-warning .warning-icon {
    margin-right: 10px;
    font-size: 1.2rem;
}

#profile-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none; /* initial versteckt! */
    align-items: center;
    justify-content: center;
    flex-direction: column;
    pointer-events: none;
}

#profile-loading-overlay .loading {
    width: 48px;
    height: 48px;
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-top: 6px solid #e0b800;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1em;
    pointer-events: auto;
}

#profile-loading-overlay .loading-text {
    color: white;
    font-size: 1.2em;
    pointer-events: auto;
}

/* Autocomplete-Dropdown */
/* 1) Die search-field bleibt der relative Parent für das Dropdown */
.search-field {
    position: relative; /* bereits vorhanden, nur zur Sicherheit */
}

/* 1) Container: zwingend absolut und volle Breite des .search-field */
#autocomplete-container {
    position: absolute !important;
    top: calc(100% + 4px) !important; /* 4px Abstand unter dem Input */
    left: 0 !important;
    width: 100% !important;
    z-index: 1000 !important;
}

/* 2) Dropdown-Liste: direkt im Container, keine zweite Verschachtelung nötig */
.autocomplete-list {
    display: none; /* per JS auf block gesetzt */
    margin: 0;
    padding: 0;
    list-style: none;
    background: #222;
    border: 1px solid #444;
    border-radius: 6px;
    box-sizing: border-box;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    overflow-x: hidden;
}

/* 3) Listeneinträge: Bild + Text */
.autocomplete-list li {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 1px solid #333;
    color: #fff;
    background: transparent;
    transition: background 0.1s ease;
    overflow: hidden;
    text-overflow: ellipsis;
}
.autocomplete-list li:last-child {
    border-bottom: none;
}
.autocomplete-list li img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    margin-right: 8px;
    background: #444;
}
.autocomplete-list li:hover,
.autocomplete-list li.selected {
    background: #444;
}

/* 4) Optional schmale Scrollbar */
.autocomplete-list::-webkit-scrollbar {
    width: 6px;
}
.autocomplete-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* ---- Mehrfachauswahl für Kategorien ---- */
.multi-select {
    position: relative;
    width: 100%;
    user-select: none;
}
.multi-select-trigger {
    background: transparent;
    border: none;
    color: white;
    font-size: 1em;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.multi-select.open .multi-select-options {
    display: block;
}
.multi-select-options {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #222;
    border: 1px solid #444;
    border-radius: 6px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    text-align: left;
}
.multi-select-options label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    color: white;
    padding: 6px 8px;
    cursor: pointer;
}
.multi-select-options label:hover {
    background: #333;
}
.multi-select-options input[type="checkbox"] {
    margin-right: 0.75em;
    margin-left: 0;
}
