/* DinoManager – schlichtes Layout; Farbschema hell, dunkel oder automatisch (Umschalter im Kopfbereich) */
:root {
    --bg: #f6f5f1;
    --surface: #ffffff;
    --text: #1f2421;
    --muted: #66706a;
    --border: #d8dcd6;
    --accent: #2f6f4f;
    --accent-text: #ffffff;
    --notice-bg: #e6f2ea;
    --error: #a3262a;
    --error-bg: #fbeaea;
    --warn: #8a5a00;
    --radius: 6px;
    color-scheme: light dark;
}

/* Automatisch: dunkel, wenn das System es wünscht und nicht "Hell" gewählt ist */
@media (prefers-color-scheme: dark) {
    :root:not(.theme-light) {
        --bg: #161a18;
        --surface: #1f2522;
        --text: #e6ebe7;
        --muted: #9aa59e;
        --border: #34403a;
        --accent: #5fb487;
        --accent-text: #0e1411;
        --notice-bg: #1d3328;
        --error: #f08a8d;
        --error-bg: #3a1f21;
        --warn: #e0b04f;
    }
}

/* Gewählt: dunkel bzw. hell unabhängig von der Systemeinstellung */
:root.theme-dark {
    --bg: #161a18;
    --surface: #1f2522;
    --text: #e6ebe7;
    --muted: #9aa59e;
    --border: #34403a;
    --accent: #5fb487;
    --accent-text: #0e1411;
    --notice-bg: #1d3328;
    --error: #f08a8d;
    --error-bg: #3a1f21;
    --warn: #e0b04f;
    color-scheme: dark;
}

:root.theme-light { color-scheme: light; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--accent); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    padding: .75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }

.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.content { max-width: 64rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 .75rem; }

.form { display: grid; gap: .35rem; max-width: 26rem; }
.form label { font-weight: 600; margin-top: .5rem; }
.form .check { font-weight: 400; display: flex; gap: .5rem; align-items: center; }

input[type=text], input[type=password], input:not([type]) {
    font: inherit;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

button, .button {
    font: inherit;
    display: inline-block;
    margin-top: .75rem;
    padding: .5rem 1rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-text);
    cursor: pointer;
    text-decoration: none;
}

button.secondary, .button.secondary { background: transparent; color: var(--accent); }

button.link {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    text-decoration: underline;
}

form.inline { display: inline; }

.actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.hint, .muted { color: var(--muted); font-size: .9rem; margin: .25rem 0; }

.notice {
    background: var(--notice-bg);
    border-left: 4px solid var(--accent);
    padding: .6rem .9rem;
    border-radius: var(--radius);
}

.errors:empty { display: none; }
.errors, .validation-summary-errors {
    color: var(--error);
    background: var(--error-bg);
    border-left: 4px solid var(--error);
    padding: .5rem .9rem;
    border-radius: var(--radius);
}
.errors ul { margin: 0; padding-left: 1.1rem; }
.validation-summary-valid { display: none; }

.error, .field-validation-error { color: var(--error); font-size: .9rem; }
.warn { color: var(--warn); }

.steps { padding-left: 1.25rem; color: var(--muted); }
.steps .current { color: var(--text); font-weight: 600; }
.steps .done { text-decoration: line-through; }

.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid th, .grid td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid th { font-size: .85rem; color: var(--muted); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; word-break: break-all; }

/* Spieleransicht */
.content:has(.creatures) { max-width: 80rem; }
h1 .muted { font-weight: 400; font-size: 1.1rem; }
.facts.compact { margin-bottom: 1rem; }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: 1rem 0; }
.tabs a {
    padding: .45rem .9rem;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}
.tabs a.active { color: var(--text); background: var(--surface); border-color: var(--border); margin-bottom: -1px; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.filters input, .filters select {
    font: inherit;
    padding: .4rem .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.filters button { margin-top: 0; }

.grid .num { text-align: right; white-space: nowrap; }
.grid th a { color: inherit; text-decoration: none; }
.grid th a:hover { text-decoration: underline; }
.creatures td, .creatures th { padding: .35rem .45rem; }
.top { color: var(--accent); }
.mut { color: var(--warn); font-size: .8rem; margin-left: .1rem; }
.bad { color: var(--error); font-weight: 600; }

.pager { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }

.log { list-style: none; padding: 0; margin: 0; }
.log li {
    display: flex;
    gap: .75rem;
    padding: .35rem .6rem;
    border-left: 4px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.log li .muted { white-space: nowrap; }
.log-red { border-left-color: #c0392b !important; }
.log-green { border-left-color: #27ae60 !important; }
.log-yellow { border-left-color: #e0a800 !important; }
.log-purple { border-left-color: #9b59b6 !important; }
.log-blue { border-left-color: #2e86c1 !important; }
.log-white { border-left-color: var(--muted) !important; }

/* Inventare (Kibble & Eier, Ressourcen) */
.grid.compact-grid { width: auto; min-width: min(100%, 28rem); }
.grid tfoot th { color: var(--text); border-top: 2px solid var(--border); border-bottom: 0; }

/* Versionsverlauf: Popup an der Versionsnummer (HTML-Popover, ohne JavaScript) */
.footer .version { font-size: inherit; color: var(--muted); }
.footer .version:hover { color: var(--accent); }
.popup {
    width: min(46rem, calc(100vw - 2rem));
    max-height: min(80vh, 48rem);
    overflow: auto;
    margin: auto;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: .95rem;
    text-align: left;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .3);
}
.popup::backdrop { background: rgba(0, 0, 0, .35); }
.popup-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .5rem; }
.release { border-top: 1px solid var(--border); padding: .5rem 0; }
.release summary { cursor: pointer; }
.release h4 { font-size: .95rem; margin: .75rem 0 .25rem; }
.release ul { margin: .25rem 0; padding-left: 1.25rem; }
.release li { margin: .2rem 0; }
.tag {
    display: inline-block;
    margin-left: .35rem;
    padding: 0 .45rem;
    border-radius: 999px;
    background: var(--notice-bg);
    color: var(--accent);
    font-size: .8rem;
}

/* Farbschema-Umschalter im Kopfbereich */
.theme-switch { display: inline-flex; gap: .15rem; }
.theme-switch button { padding: 0 .2rem; text-decoration: none; opacity: .55; font-size: 1rem; color: inherit; }
.theme-switch button:hover, .theme-switch button[aria-pressed="true"] { opacity: 1; }
.theme-switch button[aria-pressed="true"] { font-weight: 700; }

/* Karte der Server-Ansicht (SVG, Punkte mit Hinweis beim Überfahren) */
.map { margin: 1rem 0; max-width: 60rem; }
.map svg { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.map-bg { fill: var(--surface); }
.map-grid line { stroke: var(--muted); stroke-opacity: .35; stroke-width: 1; }
.map-grid text { fill: var(--muted); font-size: 14px; }
.pt { stroke: #000; stroke-opacity: .55; stroke-width: 1.5; }
.pt-low { fill: #8bc34a; }
.pt-mid { fill: #ffca28; }
.pt-high { fill: #ff7043; }
.pt-top { fill: #e53935; }
.pt-tamed { fill: #42a5f5; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; margin-top: .5rem; font-size: .9rem; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .5); vertical-align: -.1rem; }
.swatch.pt-low { background: #8bc34a; }
.swatch.pt-mid { background: #ffca28; }
.swatch.pt-high { background: #ff7043; }
.swatch.pt-top { background: #e53935; }
.swatch.pt-tamed { background: #42a5f5; }

/* Admin-Ansicht: Basen und Eier auf der Karte */
.base { stroke-width: 2; fill-opacity: .35; }
.base-active { fill: #43a047; stroke: #2e7d32; }
.base-inactive { fill: #e53935; stroke: #b71c1c; }
.pt-egg { fill: #ab47bc; }
.swatch.base-active { background: #43a047; }
.swatch.base-inactive { background: #e53935; }
.swatch.pt-egg { background: #ab47bc; }
.map a:focus-visible circle { stroke: var(--text); stroke-width: 4; }

/* Admin-Ansicht: Kennzeichen, gefährliche Aktionen, RCON-Ausgabe */
.badge { display: inline-block; padding: 0 .4rem; border-radius: var(--radius); font-size: .8rem; border: 1px solid var(--border); }
.badge.inactive { color: var(--error); border-color: var(--error); }
button.danger, .button.danger { background: var(--error); border-color: var(--error); color: #fff; }
.danger-zone { border: 1px solid var(--error); border-radius: var(--radius); padding: .5rem 1rem 1rem; margin: 1rem 0; }
.danger-zone h2 { color: var(--error); margin-top: .5rem; }
.output { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .9rem; white-space: pre-wrap; word-break: break-word; max-height: 30rem; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.wide { width: 100%; max-width: 40rem; }

@media (max-width: 40rem) {
    .grid { display: block; overflow-x: auto; }
    .log li { flex-direction: column; gap: 0; }
}
