/* Branchenkennzahlenvergleich für Kaminkehrer – Stylesheet
   Gestaltung orientiert sich an der Vorlage (docs/Vorlage_Homepage.pptx):
   grauer Kopfbereich mit Titel und SBB-Logo, schlichte Tabellen, Fußzeile
   mit Impressum/Datenschutz. Keine externen Schriften (Datenschutz). */

:root {
    --c-bg: #ffffff;
    --c-text: #1f1f1f;
    --c-muted: #6b6b6b;
    --c-border: #b5b5b5;
    --c-header: #d9d9d9;
    --c-header-dark: #8a8a8a;
    --c-row-alt: #f4f4f4;
    --c-emphasis: #c9c9c9;
    --c-accent: #3a3a3a;
    --c-good: #2e7d32;
    --c-bad: #c62828;
    --c-series-own: #c6e6bd;
    --c-series-national: #fbe1d4;
    --c-series-region: #a9c8ec;
    --c-error-bg: #fdecea;
    --c-error: #b71c1c;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Im iFrame des Mitgliederbereichs bestimmt der Inhalt die Höhe
   (public/js/embed.js) – 100vh wäre dort die iFrame-Höhe selbst und
   ließe das iFrame nie mehr schrumpfen. */
.is-embedded body { min-height: 0; }

.container {
    width: min(1100px, 100% - 2rem);
    margin-inline: auto;
}

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

h1 {
    font-size: 1.5rem;
    font-weight: 500;
    margin: 0 0 1rem;
}
h2 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }

p { margin: 0 0 1rem; }
.muted { color: var(--c-muted); }
.small { font-size: .875rem; }
.notice { font-weight: 500; }

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

.site-header {
    background: linear-gradient(180deg, var(--c-header) 0%, #c4c4c4 100%);
    border-bottom: 2px solid var(--c-accent);
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 0;
}
.site-header__title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--c-text);
    text-decoration: none;
}
.site-header__logo {
    height: 64px;
    width: 64px;
    border-radius: 50%;
    background: #fff;
    flex: 0 0 auto;
}

.site-main {
    flex: 1;
    padding: 1.5rem 0 2rem;
}

.site-footer {
    border-top: 2px solid var(--c-accent);
    padding: 1rem 0;
    font-size: .9rem;
}
.site-footer__nav { display: flex; gap: 1.5rem; }
.site-footer__nav a { font-weight: 600; text-decoration: none; }
.site-footer__nav a:hover { text-decoration: underline; }

/* Buttons ----------------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: .6rem 1.4rem;
    border: 1px solid var(--c-accent);
    border-radius: 6px;
    background: var(--c-accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.3;
}
.btn:hover { background: #222; }
.btn--secondary {
    background: #fff;
    color: var(--c-accent);
}
.btn--secondary:hover { background: #f0f0f0; }
.btn--arrow {
    position: relative;
    min-width: 12rem;
    text-align: center;
    background: linear-gradient(180deg, #bdbdbd, #8f8f8f);
    border-color: #7a7a7a;
    color: var(--c-text);
    padding-right: 2.6rem;
}
.btn--arrow::after {
    content: "➜";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
}
.btn--arrow:hover { background: linear-gradient(180deg, #c9c9c9, #9a9a9a); }

.choice {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: space-around;
    margin: 2rem 0;
}

/* Forms ------------------------------------------------------------------- */

.form { max-width: 860px; }

.field {
    display: grid;
    grid-template-columns: minmax(12rem, 16rem) minmax(12rem, 18rem) 1fr;
    gap: .25rem 1.5rem;
    align-items: start;
    margin-bottom: 1.1rem;
}
.field__label {
    padding-top: .45rem;
    font-weight: 500;
}
.field__control { display: flex; flex-direction: column; gap: .35rem; }
.field__hint { padding-top: .45rem; font-style: italic; }

.input, select {
    width: 100%;
    padding: .45rem .6rem;
    font: inherit;
    border: 1px solid var(--c-accent);
    border-radius: 6px;
    background: #fff;
    text-align: right;
}
.input:focus, select:focus { outline: 2px solid #5a8dd6; outline-offset: 1px; }

/* Bundeslandauswahl: Namen linksbündig, anders als die Beträge daneben */
.select--region { text-align: left; }
.field.is-invalid .select--region {
    border-color: var(--c-error);
    border-width: 2px;
    background: var(--c-error-bg);
}

/* Fehlerhaftes Feld: rote Umrandung und Meldung direkt unter der Eingabe */
.field.is-invalid .field__label { color: var(--c-error); }
.field.is-invalid .input {
    border-color: var(--c-error);
    border-width: 2px;
    background: var(--c-error-bg);
}
.field__error {
    margin: 0;
    color: var(--c-error);
    font-size: .9rem;
    font-weight: 500;
}
.input--calc {
    display: block;
    background: #e6e6e6;
    color: var(--c-text);
    text-align: center;
    font-weight: 500;
}
.input--calc[data-has-value="1"] { text-align: right; }

.slider {
    width: 100%;
    margin: 0;
    accent-color: var(--c-accent);
    cursor: pointer;
}

.form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.5rem;
}
.form__actions .btn[hidden] { display: none; }

.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
}
.alert--error {
    background: var(--c-error-bg);
    color: var(--c-error);
    border: 1px solid var(--c-error);
}
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* Stepped form (detailliert) */
.steps {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
}
.steps__item {
    font: inherit;
    font-size: .9rem;
    padding: .35rem .8rem;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}
.steps__item[aria-current="step"] {
    background: var(--c-accent);
    border-color: var(--c-accent);
    color: #fff;
}
.step {
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 1rem 1.25rem .25rem;
    margin: 0 0 1.25rem;
}
.step__title { font-weight: 600; padding: 0 .4rem; }
.js .form--stepped .step[hidden] { display: none; }
.js .form--stepped .step { border: 0; padding: 0; }
.js .form--stepped .step__title {
    display: block;
    width: 100%;
    font-size: 1.1rem;
    padding: 0 0 .75rem;
}

/* Tables ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; margin-bottom: 1rem; }

.table {
    border-collapse: collapse;
    width: 100%;
    font-size: .95rem;
}
.table th, .table td {
    border: 1px solid var(--c-border);
    padding: .4rem .6rem;
    vertical-align: middle;
}
.table thead th {
    background: var(--c-row-alt);
    font-weight: 600;
    text-align: center;
    font-size: .85rem;
}
.table tbody th { text-align: left; font-weight: 500; white-space: nowrap; }
.table--dense th, .table--dense td { padding: .25rem .5rem; font-size: .88rem; }
.table tbody tr:nth-child(even) td, .table tbody tr:nth-child(even) th { background: var(--c-row-alt); }
.table .row--emphasis th, .table .row--emphasis td { background: var(--c-emphasis) !important; font-weight: 600; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.center { text-align: center; }

.verdict {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    line-height: 1.5em;
    text-align: center;
    border-radius: 50%;
    font-size: 1rem;
    color: #fff;
}
.verdict--good { background: var(--c-good); }
.verdict--good::before { content: "▲"; font-size: .75em; }
.verdict--bad { background: var(--c-bad); }
.verdict--bad::before { content: "▼"; font-size: .75em; }
.verdict--none { background: transparent; color: var(--c-muted); }
.verdict--none::before { content: "–"; }
.legend .verdict { vertical-align: middle; margin-right: .2rem; }

/* Results ----------------------------------------------------------------- */

.result-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.result-head h1 { margin: 0; }
.pdf-form { margin: 0; }
.btn.is-busy { opacity: .7; cursor: progress; }
.result-section { margin-bottom: 2rem; }
.result-footer { margin-top: 2rem; border-top: 1px solid var(--c-border); padding-top: 1rem; }

.chart {
    position: relative;
    height: 260px;
    max-width: 900px;
}
.chart--tall { height: 380px; }

/* BWA Beispiel + Lightbox ------------------------------------------------- */

.bwa-figure { margin: 0 0 1.5rem; }
.bwa-figure__img {
    display: block;
    max-width: 520px;
    width: 100%;
    border: 1px solid var(--c-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    cursor: zoom-in;
}
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 100;
    cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox__img {
    max-width: 100%;
    max-height: 100%;
    background: #fff;
    box-shadow: 0 4px 30px rgba(0, 0, 0, .5);
}
.lightbox__close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    font-size: 2.5rem;
    line-height: 1;
    color: #fff;
    background: none;
    border: 0;
    cursor: pointer;
}

/* Legal pages -------------------------------------------------------------- */

.legal { max-width: 820px; }

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

@media (max-width: 760px) {
    .site-header__title { font-size: 1.05rem; }
    .site-header__logo { height: 48px; width: 48px; }
    .field { grid-template-columns: 1fr; gap: .2rem; }
    .field__label { padding-top: 0; }
    .field__hint { padding-top: 0; }
    .chart--tall { height: 320px; }
}

/* Print -------------------------------------------------------------------- */

.print-only { display: none; }

@media print {
    @page { size: A4 landscape; margin: 12mm; }
    body { font-size: 11pt; color: #000; }
    .no-print { display: none !important; }
    .print-only { display: block; }
    .container { width: 100%; }
    .site-header { background: #e5e5e5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .site-main { padding: .5rem 0; }
    .table { font-size: 9.5pt; }
    .table--dense th, .table--dense td { font-size: 8.5pt; padding: .15rem .4rem; }
    .table thead th, .table tbody tr:nth-child(even) td, .table tbody tr:nth-child(even) th, .row--emphasis th, .row--emphasis td, .verdict {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .page-break-before { break-before: page; page-break-before: always; }
    .chart { height: 240px; max-width: 100%; }
    .chart--tall { height: 300px; }
    .result-section { break-inside: avoid; }
    .site-footer { font-size: 8pt; }
    a { text-decoration: none; color: inherit; }
}

/* Feedback ----------------------------------------------------------------- */

.feedback-panel {
    margin-top: 2rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: var(--c-row-alt);
}
.feedback-panel:focus { outline: none; }
.feedback-panel__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.feedback-panel__head h2 { margin-top: 0; }
.feedback-panel__close {
    border: 0;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--c-muted);
}
.feedback-panel__close:hover { color: var(--c-text); }

.feedback-form { max-width: 760px; }
.feedback-form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
.feedback-field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.feedback-field .field__label { padding-top: 0; }
.input--text { text-align: left; font: inherit; }
textarea.input--text { resize: vertical; }
.feedback-field.is-invalid .input,
.feedback-field.is-invalid .feedback-drop {
    border-color: var(--c-error);
    border-width: 2px;
    background: var(--c-error-bg);
}
/* Honeypot: aus dem Blick, aber nicht display:none (manche Bots prüfen das) */
.feedback-form__hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.feedback-drop {
    border: 1px dashed var(--c-border);
    border-radius: 6px;
    background: #fff;
    padding: .75rem 1rem;
}
.feedback-drop.is-dragover { border-color: var(--c-accent); background: #eef3fa; }
.feedback-drop__text { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.feedback-drop__hint { display: none; }
.has-attachments-js .feedback-drop__hint { display: inline; }
.feedback-drop__pick { position: relative; overflow: hidden; }
.has-attachments-js .feedback-drop__pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
kbd {
    font: inherit;
    font-size: .85em;
    padding: 0 .3em;
    border: 1px solid var(--c-border);
    border-radius: 3px;
    background: var(--c-row-alt);
}

.feedback-files { list-style: none; margin: 0; padding: 0; }
.feedback-files__item { display: flex; align-items: center; gap: .75rem; margin-top: .5rem; }
.feedback-files__thumb { width: 64px; height: 48px; object-fit: cover; border: 1px solid var(--c-border); border-radius: 3px; }
.feedback-files__name { flex: 1; word-break: break-all; }
.feedback-files__remove {
    border: 0;
    background: none;
    color: var(--c-bad);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
}

.thanks { padding: .5rem 0; }
.thanks:focus { outline: none; }

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

.stats-filter { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: end; margin-bottom: .5rem; }
.stats-filter label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
.stats-filter select { text-align: left; min-width: 12rem; }
.stats-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stats-tile { border: 1px solid var(--c-border); border-radius: 8px; padding: 1rem; }
.stats-tile__value { font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stats-tile__label { font-weight: 500; }
.stats-section { margin-top: 2rem; }
.stats-table { min-width: 32rem; }

@media (max-width: 760px) {
    .feedback-form__grid { grid-template-columns: 1fr; }
    .feedback-panel { padding: 1rem; }
}
