/* ============================================================
   eCaupo Umfrage – zentrales Stylesheet
   Farben kommen als CSS-Variablen aus den Admin-Einstellungen
   (inline in <head> gesetzt, hier nur Fallbacks).
   ============================================================ */

:root {
    --c-primary:     #2f6fed;
    --c-header-bg:   #ffffff;
    --c-header-text: #1c2733;
    --c-page-bg:     #f4f6f8;

    --c-text:   #1c2733;
    --c-muted:  #6b7683;
    --c-border: #dde3ea;
    --c-card:   #ffffff;
    --c-danger: #c0392b;
    --c-ok:     #1e8e4e;
    --radius:   10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--c-text);
    background: var(--c-page-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

main.wrap { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }

a { color: var(--c-primary); }

code {
    background: var(--c-page-bg);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    padding: 0 0.3em;
    font-size: 0.9em;
}

hr { border: none; border-top: 1px solid var(--c-border); margin: 1rem 0; }

.muted { color: var(--c-muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* ---------------- Header & Footer ---------------- */

.site-header {
    background: var(--c-header-bg);
    color: var(--c-header-text);
    border-bottom: 1px solid var(--c-border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.brand { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.brand img { max-height: 48px; max-width: 220px; display: block; }
.brand-text { font-size: 1.2rem; font-weight: 700; }

.main-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.main-nav a { color: var(--c-header-text); text-decoration: none; font-weight: 500; }
.main-nav a:hover { color: var(--c-primary); }

.admin-nav {
    background: #22303f;
    color: #fff;
    font-size: 0.95rem;
}
.admin-nav .wrap {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}
.admin-nav a { color: #fff; text-decoration: none; }
.admin-nav a:hover { text-decoration: underline; }
.admin-nav-right { margin-left: auto; color: #b8c4d0; }
.admin-nav-right a { color: #fff; }

.site-footer {
    background: var(--c-header-bg);
    color: var(--c-header-text);
    border-top: 1px solid var(--c-border);
    padding: 1rem 0;
    font-size: 0.9rem;
    text-align: center;
}

/* ---------------- Karten & Meldungen ---------------- */

.card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }

.flash {
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
}
.flash-success { background: #e4f5eb; color: #14522f; border: 1px solid #bfe5cd; }
.flash-error   { background: #fdeceb; color: #7c221a; border: 1px solid #f3c3bf; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.page-head h1 { margin: 0; }

/* ---------------- Formulare ---------------- */

.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.95rem; }
.field small { display: block; margin-top: 0.3rem; }

.field-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 200px; }

.field-check { display: flex; align-items: center; gap: 0.5rem; }
.field-check span { margin: 0; font-weight: 600; font-size: 0.95rem; }

input[type="text"], input[type="email"], input[type="url"], input[type="password"],
input[type="number"], select, textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    font: inherit;
    color: inherit;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 6px;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--c-primary);
    outline-offset: 0;
    border-color: var(--c-primary);
}
textarea { resize: vertical; }

input[type="color"] {
    width: 60px; height: 38px; padding: 2px;
    border: 1px solid var(--c-border); border-radius: 6px; background: #fff; cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--c-primary); width: 1.1rem; height: 1.1rem; }

.field-error input, .field-error textarea, .field-error select { border-color: var(--c-danger); }
.error-text { display: block; color: var(--c-danger); font-style: normal; font-size: 0.9rem; margin-top: 0.3rem; }

fieldset.type-fields {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem 1rem;
    margin: 0 0 1rem;
}
fieldset.type-fields legend { font-weight: 600; padding: 0 0.4rem; font-size: 0.95rem; }

.option-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.option-row input[type="text"] { flex: 1; }

.form-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

/* ---------------- Buttons & Badges ---------------- */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--c-text);
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }

.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { filter: brightness(0.92); color: #fff; }

.btn-danger { color: var(--c-danger); }
.btn-danger:hover { border-color: var(--c-danger); color: var(--c-danger); background: #fdeceb; }

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn-lg { padding: 0.7rem 1.6rem; font-size: 1.05rem; }
.btn[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }
button[disabled] { opacity: 0.4; cursor: default; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 99px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
}
.badge-on  { background: #e4f5eb; color: var(--c-ok); border-color: #bfe5cd; }
.badge-off { background: #f0f2f5; color: var(--c-muted); border-color: var(--c-border); }

/* ---------------- Tabellen ---------------- */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--c-border);
    vertical-align: top;
}
.table thead th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--c-muted); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions { white-space: nowrap; }
.table .actions form { margin: 0; }
.row-active td { background: #f2f7ff; }

.table-scroll { overflow-x: auto; }

.pagination { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.pagination a, .page-current {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    text-decoration: none;
    background: #fff;
}
.page-current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; font-weight: 600; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tab {
    padding: 0.45rem 1rem;
    border: 1px solid var(--c-border);
    border-radius: 99px;
    background: #fff;
    text-decoration: none;
    color: var(--c-text);
    font-weight: 600;
    font-size: 0.95rem;
}
.tab-active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ---------------- Öffentliche Umfrage ---------------- */

.survey-card h1 { margin-bottom: 0.5rem; }
.survey-intro { color: var(--c-muted); margin-bottom: 1.5rem; }

.question {
    padding: 1.1rem 0;
    border-top: 1px solid var(--c-border);
}
.question-title { font-weight: 600; margin-bottom: 0.25rem; }
.question-title .req { color: var(--c-danger); }
.question-desc { color: var(--c-muted); font-size: 0.92rem; margin-bottom: 0.5rem; }
.question-input { margin-top: 0.5rem; }

.question.has-error { border-left: 4px solid var(--c-danger); padding-left: 1rem; }
.question-error {
    color: var(--c-danger);
    font-size: 0.92rem;
    font-weight: 600;
    margin: 0.25rem 0 0.5rem;
}

.choice {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    padding: 0.3rem 0;
    cursor: pointer;
}

.thanks h1 { color: var(--c-ok); }

/* Sterne: DOM-Reihenfolge 5..1, row-reverse zeigt 1..5;
   :checked ~ label färbt alle Sterne links der Auswahl. */
.stars { display: inline-flex; flex-direction: row-reverse; }
.stars input { position: absolute; opacity: 0; width: 0; height: 0; }
.stars label {
    font-size: 2rem;
    line-height: 1;
    padding: 0 0.15rem;
    color: #cfd6dd;
    cursor: pointer;
    user-select: none;
}
.stars label:hover,
.stars label:hover ~ label,
.stars input:checked ~ label { color: #f5a623; }
.stars input:focus-visible + label { outline: 2px solid var(--c-primary); border-radius: 4px; }

/* ---------------- Statistik ---------------- */

.stat-title { margin-bottom: 0.25rem; }
.stat-avg { font-size: 1.05rem; }

.stat-bars { display: grid; gap: 0.45rem; margin-top: 0.75rem; }
.stat-row { display: grid; grid-template-columns: minmax(120px, 1fr) 3fr auto; gap: 0.75rem; align-items: center; }
.stat-label { font-size: 0.95rem; overflow-wrap: anywhere; }
.stat-bar { background: var(--c-page-bg); border-radius: 99px; height: 14px; overflow: hidden; }
.stat-bar-fill { background: var(--c-primary); height: 100%; border-radius: 99px; min-width: 2px; }
.stat-value { font-size: 0.9rem; color: var(--c-muted); white-space: nowrap; }

.text-answers { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.text-answers li { margin-bottom: 0.5rem; }

.logo-preview { max-height: 80px; max-width: 300px; border: 1px solid var(--c-border); border-radius: 6px; padding: 6px; background: #fff; }

/* ---------------- Responsive ---------------- */

@media (max-width: 640px) {
    body { font-size: 15px; }
    .card { padding: 1rem; }
    .field-row { flex-direction: column; gap: 0; }
    .stat-row { grid-template-columns: 1fr; gap: 0.2rem; }
    .stat-value { text-align: left; }
    .header-inner { justify-content: center; }
}
