/* =============================================================================
   BAIN-BLEU Ticketing – Grundlayout (mobile first, ohne Framework)
   ============================================================================= */

:root {
    --blue: #003d7e;
    --blue-light: #e8f1fb;
    --accent: #fec700;
    --text: #1f2933;
    --muted: #6b7785;
    --line: #dde3ea;
    --bg: #f5f7fa;
    --white: #ffffff;
    --ok: #1e7e34;
    --ok-bg: #e6f4ea;
    --err: #b3261e;
    --err-bg: #fdecea;
    --info-bg: #e8f1fb;
    --radius: 5px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .04);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

img { max-width: 100%; height: auto; }
a { color: var(--blue); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 1rem; color: var(--blue); }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }
.muted { color: var(--muted); }
.small { font-size: .85em; color: var(--muted); }
.inline { display: inline; }

/* ---------- Kopf / Fuss ---------- */

.site-header { background: var(--white); border-bottom: 3px solid var(--blue); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.brand img { display: block; width: 100px; height: auto; }
.header-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: .95rem; }
.header-nav a { text-decoration: none; }
.lang-switch { display: inline-flex; gap: 8px; padding-left: 12px; border-left: 1px solid var(--line); }
.lang-switch strong { color: var(--blue); }

.site-footer { background: var(--blue); color: #cfe0f3; font-size: .85rem; padding: 16px 0; }

/* ---------- Hinweise ---------- */

.alert { padding: 12px 14px; margin: 0 0 16px; border-left: 10px solid; }
.alert-success { background: var(--ok-bg); border-color: var(--ok); }
.alert-error { background: var(--err-bg); border-color: var(--err); }
.alert-info { background: var(--info-bg); border-color: var(--blue); }

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

.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.narrow { max-width: 460px; margin: 0 auto; }

.form label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 14px; }
.form input, .form select, .form textarea {
    display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
    font: inherit; font-weight: 400; color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; background: var(--white);
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }

.btn {
    display: inline-block; padding: 12px 20px; border: 1px solid var(--blue); border-radius: 8px;
    background: var(--white); color: var(--blue); font: inherit; font-weight: 600;
    text-decoration: none; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--blue); color: var(--white); width: 100%; }
.btn-primary:hover { background: #002a58; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; }

/* ---------- Produkte ---------- */

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.product-card {
    position: relative; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px; border-top: 6px solid var(--product-color, var(--line));
}
.product-name { font-size: 1rem; line-height: 1.25; }
.product-sub { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.product-price { margin-top: 10px; font-weight: 600; color: var(--blue); }
.badge { position: absolute; top: 8px; right: 8px; font-size: .7rem; background: var(--accent); padding: 1px 6px; border-radius: 4px; }

/* ---------- Backoffice ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 24px; }
.stat { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--blue); }
.stat-value.ok { color: var(--ok); font-size: 1.2rem; }
.stat-value.off { color: var(--err); font-size: 1.2rem; }

/* ---------- Buchung: Schritte ---------- */

.step { margin: 0 0 22px; }
.step-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.1rem; margin: 0 0 10px; }
.step-no { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: var(--white); font-size: .9rem; }
.btn-small { padding: 7px 12px; font-size: .9rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.big { font-size: 1.25rem; }

/* Tagesauswahl */
.date-strip { display: flex; align-items: stretch; gap: 6px; }
.date-strip .days { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day, .day-nav {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 6px 2px; border-radius: 8px; background: var(--white); box-shadow: var(--shadow);
    text-decoration: none; color: var(--text); line-height: 1.1; min-height: 56px;
}
.day-nav { width: 34px; font-size: 1.4rem; color: var(--blue); }
.day-nav.disabled { opacity: .3; }
.day .dow { font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.day .dom { font-size: 1.15rem; font-weight: 700; }
.day .mon { font-size: .7rem; color: var(--muted); }
.day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.day.active { background: var(--blue); color: var(--white); }
.day.active .dow, .day.active .mon { color: #cfe0f3; }
.date-pick { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.date-pick input[type=date] { padding: 7px 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; }

/* Auswahlkarten (Produkt, Personen) */
.choice-grid { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice {
    position: relative; display: flex; flex-direction: column; gap: 4px; cursor: pointer;
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px; border: 2px solid transparent;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.choice.checked { border-color: var(--blue); background: var(--blue-light); }
/* Produkt-Boxen ganzflächig in der Produktfarbe (Farbe im Backoffice unter Produits) */
.product-choice { background: var(--product-color, var(--white)); color: var(--text); border: 3px solid transparent; transition: transform .1s, box-shadow .1s; }
.product-choice .product-sub { color: inherit; opacity: .85; }
.product-choice.on-dark { color: var(--white); }
.product-choice:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.product-choice.checked { background: var(--product-color, var(--blue-light)); border-color: var(--text); box-shadow: inset 0 0 0 2px var(--white), 0 4px 14px rgba(0, 0, 0, .18); }
.product-choice.checked::after {
    content: '✓'; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center; background: var(--white); color: var(--text); font-size: .8rem; font-weight: 700;
}
.product-choice .badge { top: auto; bottom: 6px; }
.persons .choice { flex-direction: row; justify-content: space-between; align-items: center; }

/* Eintrittszeiten */
/* Eintrittszeiten: 5 Spalten (Handy/Tablet), 10 Spalten (Desktop) */
.slot-grid { display: grid; gap: 6px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.slot-form { margin: 0; }
.slot {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 10px 4px; border-radius: 8px; font: inherit; border: 1px solid var(--line);
}
.slot-free { background: var(--ok-bg); border-color: #9bd3a8; color: var(--ok); cursor: pointer; }
.slot-free:hover, .slot-free:focus { background: var(--ok); color: var(--white); }
.slot-selected { background: var(--accent); border-color: #d9a900; color: var(--text); }
.slot-full { background: #eef1f4; color: #9aa5b1; }
.slot-time { font-size: 1.1rem; font-weight: 700; }
.slot-label { font-size: .78rem; }

/* Zusammenfassung, Formulare */
.two-col { display: grid; gap: 16px; }
.summary { width: 100%; border-collapse: collapse; }
.summary th, .summary td { text-align: left; vertical-align: top; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.summary th { width: 40%; font-weight: 400; color: var(--muted); font-size: .9rem; }
.booking-no { font-size: 1.2rem; color: var(--blue); letter-spacing: .03em; }
.row-2, .row-3 { display: grid; gap: 0 12px; }
.check { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 400 !important; }
.check input { width: auto !important; margin-top: 4px !important; }
.terms { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 6px 0 14px; }
.terms summary { cursor: pointer; font-weight: 600; }
.terms-text { font-size: .9rem; }
.terms-text ul { padding-left: 18px; margin: 8px 0; }
.pay-options { display: grid; gap: 16px; align-content: start; }
.pay-option h2 { margin-top: 0; display: inline; font-size: 1.1rem; }
details.pay-option summary { cursor: pointer; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.card.highlight { border: 2px solid var(--accent); }

@media (min-width: 640px) {
    .choice-grid.products { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .choice-grid.persons { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .row-2 { grid-template-columns: 1fr 1fr; }
    .row-3 { grid-template-columns: 140px 1fr 1fr; }
    .day .dom { font-size: 1.3rem; }
}

@media (min-width: 960px) {
    .choice-grid.products { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
    .choice-grid.persons { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .persons .choice { flex-direction: column; align-items: flex-start; gap: 2px; }
    .slot-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
    /* 10 Produkte nebeneinander: kompaktere Boxen */
    .product-choice { padding: 8px 7px; }
    .product-choice .product-name { font-size: .8rem; line-height: 1.2; overflow-wrap: anywhere; }
    .product-choice .product-sub { font-size: .7rem; }
    .product-choice.checked::after { width: 18px; height: 18px; font-size: .7rem; top: 3px; right: 3px; }
    .two-col { grid-template-columns: 1fr 1fr; align-items: start; }
}

/* ---------- Backoffice ---------- */

.admin-nav { background: var(--white); border-bottom: 1px solid var(--line); overflow-x: auto; }
.admin-nav .wrap { display: flex; gap: 2px; white-space: nowrap; }
.admin-nav a { padding: 10px 12px; text-decoration: none; font-size: .92rem; border-bottom: 3px solid transparent; }
.admin-nav a.active { border-bottom-color: var(--accent); font-weight: 600; }
.main.wide { max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.day-switch { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.day-switch input[type=date] { padding: 6px 8px; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
.card + .card, section.card { margin-top: 16px; }
.card h3 { margin: 18px 0 8px; font-size: 1rem; }
.small-value { font-size: 1.15rem; }
.nowrap { white-space: nowrap; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table tfoot th { border-top: 2px solid var(--line); }
.table tr.inactive td { opacity: .55; }
.table.numbers td:not(:first-child), .table.numbers th:not(:first-child) { text-align: right; white-space: nowrap; }

.status { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: .75rem; font-weight: 600; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.status-paid { background: var(--ok-bg); color: var(--ok); }
.status-to_pay { background: #fff4d6; color: #8a6100; }
.status-paid_local { background: #e3f2fd; color: #0d5ea8; }
.status-hold { background: #f3e8ff; color: #6b21a8; }
.status-cancelled, .status-expired { background: var(--err-bg); color: var(--err); }
.status-block { background: #333; color: #fff; }
.status-voucher { background: #fde68a; color: #6b4e00; }

.day-product { border-left: 6px solid var(--product-color, var(--line)); }
.day-product-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-product-head h2 { margin: 0; font-size: 1.1rem; }
.day-table tr.empty td { color: var(--muted); }
.day-table td.occ { min-width: 110px; }
.bar { display: block; height: 6px; background: #eef1f4; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); }
.bar span.high { background: #e0a800; }
.bar span.full { background: var(--err); }
.day-booking { padding: 3px 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.day-booking.arrived a strong { text-decoration: line-through; text-decoration-color: var(--ok); }
.tick { width: 26px; height: 26px; border: 2px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ok); font-weight: 700; cursor: pointer; padding: 0; }
.tick[aria-pressed=true] { border-color: var(--ok); background: var(--ok-bg); }
.toggle { min-width: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); cursor: pointer; color: var(--muted); }
.toggle.on { background: var(--ok-bg); color: var(--ok); border-color: #9bd3a8; }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }

.filter-form { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: end; }
.filter-form label { font-size: .85rem; font-weight: 600; }
.filter-form input, .filter-form select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.filter-buttons { display: flex; gap: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 8px 0; }
.inline-form label { margin: 0; font-size: .9rem; }
.inline-form input:not([type=checkbox]):not([type=radio]), .inline-form select { width: auto; display: inline-block; margin-top: 0; padding: 7px 9px; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
.form .inline-form input:not([type=checkbox]):not([type=radio]) { width: auto; display: inline-block; margin-top: 0; }
.narrow-input { max-width: 90px; }
.wrap-form { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.btn-danger { color: var(--err); border-color: #e7a5a0; }
.btn-ok { background: var(--ok-bg); color: var(--ok); border-color: #9bd3a8; }
.action-row { margin: 14px 0; }
.slot-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; }
label.slot { cursor: pointer; position: relative; }
label.slot input { position: absolute; opacity: 0; }
label.slot:has(input:checked) { background: var(--accent); color: var(--text); border-color: #d9a900; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; color: var(--blue); }
.day-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; }
.day-check { margin: 0 !important; }
.row-5 { display: grid; gap: 0 12px; }
.setting-row { display: grid; gap: 6px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.setting-row input { margin-top: 0 !important; }

@media (min-width: 640px) {
    .filter-form { grid-template-columns: 2fr 1fr 1fr 1.5fr 1.2fr auto; }
    .slot-grid.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .row-5 { grid-template-columns: repeat(5, 1fr); }
    .setting-row { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
    .slot-grid.compact { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

/* ---------- Grössere Bildschirme ---------- */

@media (min-width: 640px) {
    h1 { font-size: 2rem; }
    .brand img { width: 125px; }
    .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .btn-primary { width: auto; }
}

@media (min-width: 960px) {
    .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.persons .choice strong { white-space: nowrap; }
.card > h2:first-child, .card > .summary:first-child { margin-top: 0; }
.two-col > .card, .pay-options > .card { margin-top: 0; }
.form label.slot { display: flex; margin: 0; }
/* Farbfeld: muss die allgemeine .form .inline-form input-Regel (width:auto) übersteuern */
.inline-form input[type=color], .form .inline-form input[type=color] { width: 56px; min-width: 56px; height: 38px; padding: 3px; cursor: pointer; vertical-align: middle; }
.row-3.messages { grid-template-columns: 1fr; }
@media (min-width: 640px) { .row-3.messages { grid-template-columns: 1fr 1fr 1fr; } }
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--err); color: var(--white); font-size: .72rem; font-weight: 700; text-align: center; }
.pipeline-pending { border: 2px solid #e0a800; }
.table tr.running td { background: #faf5ff; }
.pipeline-confirm { margin: 0; flex-wrap: nowrap; }
.pipeline-confirm select { max-width: 170px; }

/* Handy: Personen (2 Spalten) untereinander statt nebeneinander, Zeiten kompakt (5 Spalten) */
@media (max-width: 639px) {
    .persons .choice { flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; }
    .slot { padding: 8px 2px; }
    .slot-time { font-size: .95rem; }
    .slot-label { font-size: .68rem; }
}
.slot-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Auswahl ohne Neuladen (assets/js/app.js): kurzer Ladezustand */
[data-live] { transition: opacity .15s; }
[data-live].is-loading .step:not(:first-child), [data-live].is-loading .slot-grid { opacity: .5; cursor: progress; }

/* Knopf "Heute" in der Datumsleiste */
.btn-today { background: var(--ok); border-color: var(--ok); color: var(--white); }
.btn-today:hover, .btn-today:focus { background: #176428; border-color: #176428; color: var(--white); }
/* Heute ist bereits gewählt → inaktiv (grau) */
.btn-today.is-current, .btn-today.is-current:hover { background: #e3e7ec; border-color: #d0d6dd; color: #8a96a3; cursor: default; }

/* Übersicht Buchungen: Umschalter und Ansicht nach Zeit */
.view-switch { display: flex; gap: 6px; margin: 0 0 14px; }
.time-table .time-head th { background: var(--blue-light); color: var(--blue); font-size: .9rem; text-transform: none; letter-spacing: 0; padding: 8px; }
.time-table tr.arrived td a strong { text-decoration: line-through; text-decoration-color: var(--ok); }

/* Kurzer Hinweis unten am Bildschirm (z. B. Speichern fehlgeschlagen) */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; max-width: 90vw;
         background: var(--err); color: var(--white); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.tick[disabled] { opacity: .6; cursor: progress; }

/* Besondere Tage: Eintrag im Bearbeitungsmodus */
tr.is-editing td { background: #fff6d6; }
.wrap-form.is-editing { background: #fff6d6; border: 1px solid #f0d77a; border-left: 10px solid #e0b92f; padding: 12px 14px; }
.wrap-form.is-editing h3 { margin: 0 0 6px; font-size: 1rem; }
#special-form, #rule-form { scroll-margin-top: 80px; }

/* Benutzer: Rolle direkt in der Liste */
.role-form select { width: auto; margin: 0; padding: 5px 8px; font: inherit; font-size: .9rem; border: 1px solid var(--line); border-radius: var(--radius); }

/* Rechte-Matrix */
.rights-table th.center, .rights-table td.center { text-align: center; width: 110px; }
.rights-table input[type=checkbox] { width: 20px; height: 20px; margin: 0; }
.rights-table td.fixed { color: var(--muted, #6b7785); }
.rights-table tr.fixed-row td { background: var(--bg); }

/* Nicht verfügbar: nächste Angebotstage */
.next-days { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.next-days span { width: 100%; font-weight: 600; }
.next-days .btn { background: #fff; }
