/*
 * "Spätschicht" — Designsystem der Rezept- & Koch-Abstimmungs-App.
 * Warmes Aubergine-Dunkel, Safran-Gold-Akzent, weiche Glas-Panels.
 * Bewusst EIN committeter dunkler Look (kein Light/Dark-Toggle) - alle
 * Farben werden hier explizit gesetzt, nichts wird von Bootstrap geerbt
 * (Bootstrap-CSS ist absichtlich nicht mehr eingebunden, siehe layout.php;
 * nur Bootstraps JS wird für die Modal-Logik weiterverwendet).
 */

:root {
    --ground: #241B26;
    --surface: #2E2331;
    --surface-2: #382C3C;
    --surface-3: #43354A;
    --ink: #F1E9E3;
    --ink-dim: #B8A8AE;
    --accent: #E8A33D;
    --accent-ink: #241B26;
    --accent-2: #7A5C6E;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --radius-pill: 999px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    position: relative;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    color: var(--ink);
    margin: 0 0 0.35em;
    text-wrap: balance;
    letter-spacing: -0.01em;
}

h1 { font-weight: 700; font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); }
h2 { font-weight: 600; font-size: clamp(1.3rem, 1.1rem + 1vw, 1.6rem); }
h3 { font-weight: 600; font-size: 1.05rem; }

p {
    color: var(--ink-dim);
    margin: 0 0 1em;
    max-width: 65ch;
}

a {
    color: inherit;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: 1rem;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

::selection {
    background: var(--accent);
    color: var(--accent-ink);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    html { scroll-behavior: auto; }
}

/* ---------- Ambient glow blooms hinter den Panels ---------- */
.ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.ambient::before, .ambient::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
}
.ambient::before {
    width: 56vmax; height: 56vmax; top: -18vmax; right: -14vmax;
    background: radial-gradient(circle, rgba(232, 163, 61, 0.30), transparent 70%);
}
.ambient::after {
    width: 60vmax; height: 60vmax; bottom: -24vmax; left: -18vmax;
    background: radial-gradient(circle, rgba(122, 92, 110, 0.38), transparent 70%);
}

/* =========================================================
   Utilities (kleines, gezieltes Set - ersetzt Bootstraps
   Layout-Utility-Klassen, die weiterhin in den Views verwendet
   werden; siehe Abschnitt "Politur" des Umsetzungsplans)
   ========================================================= */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 clamp(18px, 4vw, 48px); }
.container-fluid { width: 100%; padding: 0 8px; }

.d-flex { display: flex; }
.d-inline { display: inline; }
.d-block { display: block; }
.d-none { display: none; }
@media (min-width: 768px) {
    .d-md-flex { display: flex; }
    .d-md-none { display: none; }
}
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.justify-content-around { justify-content: space-around; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.flex-wrap { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.ms-1 { margin-left: 0.25rem; }
.me-1 { margin-right: 0.25rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-5 { padding-top: 3rem; padding-bottom: 3rem; }
.px-4 { padding-left: 1.5rem; padding-right: 1.5rem; }
.pb-5 { padding-bottom: 3rem; }
.ps-0 { padding-left: 0; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.text-center { text-align: center; }
.text-muted { color: var(--ink-dim); }
.text-primary { color: var(--accent); }
.text-danger { color: var(--accent-2); }
.text-success { color: var(--accent); }
.text-decoration-none { text-decoration: none; }
.text-body { color: var(--ink); }
.small { font-size: 0.875em; }
.fw-semibold { font-weight: 600; }

.rounded-pill { border-radius: var(--radius-pill); }
.rounded-4 { border-radius: var(--radius-lg); }
.border-0 { border: none !important; }
.border-top { border-top: 1px solid var(--surface-2); }
.border-bottom { border-bottom: 1px solid var(--surface-2); }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.list-unstyled { list-style: none; padding-left: 0; margin: 0; }

.h3, .h5, .h6 { font-family: var(--font-display); font-weight: 600; }
.h3 { font-size: 1.4rem; }
.h5 { font-size: 1.15rem; }
.h6 { font-size: 1rem; }
.display-4 { font-size: 3rem; line-height: 1; }

/* ---------- Karten-Grids (Rezepte/Listen-Übersicht) ---------- */
.grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    margin-top: 20px;
}

/* Zutatenzeile im Formular (Name / Menge / Einheit / Entfernen) */
.ingredient-field-row {
    display: grid;
    grid-template-columns: 1fr 80px 130px auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}
.ingredient-field-row select { padding-right: 8px; }
@media (max-width: 479.98px) {
    .ingredient-field-row { grid-template-columns: 1fr 1fr; }
    .ingredient-field-row select { grid-column: 1 / -1; }
    .ingredient-field-row .field-remove { grid-column: 1 / -1; justify-self: end; }
}

/* =========================================================
   Navigation
   ========================================================= */
.nav-top {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 18px clamp(20px, 4vw, 48px);
    background: rgba(46, 35, 49, 0.72);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--surface-2);
    position: sticky; top: 0; z-index: 5;
}
.brand {
    font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; text-decoration: none;
    display: flex; align-items: center; gap: 0.5em;
}
.brand::before {
    content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 12px 2px rgba(232, 163, 61, 0.7);
}
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-link {
    text-decoration: none; color: var(--ink-dim); font-weight: 600; font-size: 0.95rem;
    padding: 6px 2px; border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-link.is-active-nav { color: var(--accent); border-color: var(--accent); }
.nav-link:hover { color: var(--ink); }

.nav-bottom {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    background: rgba(46, 35, 49, 0.9);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--surface-2);
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    justify-content: space-around;
}
.nav-bottom .nav-link {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 0.78rem; border: none; padding: 4px 10px; border-radius: var(--radius-sm);
}
.nav-bottom .nav-link .dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.nav-bottom .nav-link.is-active-nav .dot { background: var(--accent); box-shadow: 0 0 8px 1px rgba(232, 163, 61, 0.7); }

@media (min-width: 768px) {
    .nav-top { display: flex; }
    .nav-bottom { display: none; }
    body { padding-bottom: 0; }
}
@media (max-width: 767.98px) {
    body { padding-bottom: calc(3.5rem + env(safe-area-inset-bottom)); }
}

main.app-main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px clamp(18px, 4vw, 48px) 40px;
    position: relative;
    z-index: 1;
}

/* =========================================================
   Buttons & Chips
   ========================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
    border: none; cursor: pointer; text-decoration: none;
    font-weight: 700; font-size: 0.95rem; padding: 12px 22px; border-radius: var(--radius-pill);
    transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px -8px rgba(232, 163, 61, 0.6); }
.btn-primary:hover { box-shadow: 0 10px 28px -6px rgba(232, 163, 61, 0.75); }
.btn-ghost, .btn-outline-secondary { background: var(--surface-2); color: var(--ink); }
.btn-ghost:hover, .btn-outline-secondary:hover { background: var(--surface-3); }
.btn-outline, .btn-outline-danger, .btn-outline-primary {
    background: transparent; color: var(--ink-dim); border: 1px solid var(--surface-3);
}
.btn-outline:hover, .btn-outline-danger:hover, .btn-outline-primary:hover {
    color: var(--ink); border-color: var(--accent-2);
}
.btn-danger { background: var(--accent-2); color: var(--ink); }
.btn-danger:hover { background: #8a6a7e; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-link {
    background: none; border: none; color: var(--ink-dim); font-weight: 600; padding: 6px 0;
    cursor: pointer; text-decoration: none; border-radius: 0;
}
.btn-link:hover { color: var(--accent); }
.btn[disabled] { opacity: 0.5; cursor: default; }

.chip {
    display: inline-flex; align-items: center; gap: 0.4em;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em;
    padding: 5px 12px; border-radius: var(--radius-pill);
}
.chip-owner, .chip-open { background: rgba(232, 163, 61, 0.16); color: var(--accent); }
.chip-shared, .chip-closed { background: var(--surface-2); color: var(--ink-dim); }

/* =========================================================
   Formulare
   ========================================================= */
.form-label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.4rem; }

.form-control,
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="search"], input[type="number"], input[type="file"], textarea, select {
    width: 100%; padding: 12px 16px; border-radius: var(--radius-md);
    border: 1px solid var(--surface-3); background: var(--surface); color: var(--ink);
    transition: border-color 0.15s ease;
}
.form-control::placeholder, input::placeholder { color: var(--ink-dim); }
.form-control:focus, input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--accent);
}
.form-control.is-invalid, input.is-invalid { border-color: var(--accent-2); }
.invalid-feedback { display: block; color: var(--accent-2); font-size: 0.85rem; margin-top: 0.3rem; }
.form-text { color: var(--ink-dim); font-size: 0.85rem; margin-top: 0.3rem; }

input[type="search"] { border-radius: var(--radius-pill); max-width: 360px; }

.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check-input {
    width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent);
    background: var(--surface); border: 1px solid var(--surface-3); border-radius: 5px;
}
.form-check-label { color: var(--ink); font-size: 0.92rem; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group .btn { border-radius: 0 var(--radius-md) var(--radius-md) 0; }

/* Bild-Vorschau (Rezeptformular) */
#image-preview { border-radius: var(--radius-md); }

/* ---------- Banner / Hinweise ---------- */
.banner {
    padding: 14px 18px; border-radius: var(--radius-md); margin-bottom: 1rem;
    background: var(--surface-2); color: var(--ink);
}
.banner-danger { color: var(--accent-2); }
.banner-info { color: var(--ink); }

/* =========================================================
   Karten
   ========================================================= */
.panel {
    background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius-lg);
    overflow: hidden;
}
.card {
    display: block; text-decoration: none; color: inherit; height: 100%;
    background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius-md);
    overflow: hidden;
}
a.card { cursor: pointer; }

.photo { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; display: block; background: var(--surface-2); }
.photo-empty {
    aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--ink-dim); font-size: 0.85rem;
}

.card-body { padding: 14px 16px 16px; }
.card-body h3 { margin: 0; }

.card-actions {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px 16px;
}

/* ---------- Rezept-Detail ---------- */
.detail-hero { border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 22px; }
.detail-hero .photo, .detail-hero .photo-empty { aspect-ratio: 16 / 8; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.detail-actions { display: flex; gap: 10px; flex-shrink: 0; }

.ingredient-list { list-style: none; margin: 0; padding: 0; max-width: 420px; }
.ingredient-row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 12px 4px; border-bottom: 1px solid var(--surface-2);
    font-variant-numeric: tabular-nums;
}
.ingredient-row:last-child { border-bottom: none; }
.ingredient-row .amount { color: var(--ink-dim); font-weight: 600; }

/* ---------- Listen ---------- */
.list-card-body { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.list-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.list-meta { color: var(--ink-dim); font-size: 0.88rem; font-variant-numeric: tabular-nums; }

/* ---------- Listendetail ---------- */
.list-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.members { display: flex; align-items: center; gap: 12px; margin: 14px 0 22px; flex-wrap: wrap; }
.avatar-stack { display: flex; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: var(--accent-ink); border: 2px solid var(--ground);
    margin-left: -10px; background: var(--accent);
}
.avatar:first-child { margin-left: 0; }
.avatar:nth-of-type(3n+2) { background: #c9b8ae; }
.avatar:nth-of-type(3n+3) { background: #8fae8f; }
.members-names { color: var(--ink-dim); font-size: 0.9rem; }
.members-names strong { color: var(--ink); font-weight: 700; }

.member-list { list-style: none; margin: 0; padding: 0; max-width: 480px; }
.member-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 4px; border-bottom: 1px solid var(--surface-2);
}
.member-row:last-child { border-bottom: none; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; }

.poll-teaser {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius-md);
    padding: 16px 18px; margin: 22px 0 26px; text-decoration: none; color: inherit;
    transition: border-color 0.15s ease;
}
.poll-teaser:hover { border-color: var(--accent); }
.poll-teaser strong { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; }

/* =========================================================
   Abstimmen
   ========================================================= */
.vote-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin: 22px 0 26px; }
.vote-checkbox { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
.vote-label { display: block; cursor: pointer; border-radius: var(--radius-md); }
.vote-card {
    border: 1px solid var(--surface-2); border-radius: var(--radius-md); overflow: hidden;
    background: var(--surface); transition: box-shadow 0.15s ease, border-color 0.15s ease;
    position: relative;
}
.vote-checkbox:checked + .vote-card {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent), 0 0 28px -4px rgba(232, 163, 61, 0.55);
}
.vote-checkbox:focus-visible + .vote-card { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- Ergebnisse / Zwischenstand ---------- */
.tally-list { display: flex; flex-direction: column; gap: 14px; max-width: 560px; margin: 20px 0 26px; }
.tally-row {
    background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius-md);
    padding: 16px 18px; text-decoration: none; color: inherit; display: block;
    transition: border-color 0.15s ease;
}
a.tally-row:hover { border-color: var(--accent-2); }
.tally-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tally-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tally-count { color: var(--ink-dim); font-variant-numeric: tabular-nums; font-weight: 700; }
.badge-winner {
    background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; font-weight: 800;
    letter-spacing: 0.03em; text-transform: uppercase; padding: 3px 10px; border-radius: var(--radius-pill);
}
.my-vote { color: var(--accent); font-size: 0.85rem; font-weight: 700; }
.bar-track { height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--radius-pill); background: var(--accent); box-shadow: 0 0 12px 1px rgba(232, 163, 61, 0.6); }

.back-link { display: inline-flex; align-items: center; gap: 0.4em; margin-top: 6px; }

/* =========================================================
   Modal (Bootstrap-JS steuert .show/.fade - Aussehen hier neu definiert)
   ========================================================= */
.modal {
    position: fixed; inset: 0; z-index: 1055; display: none;
    outline: 0; overflow-x: hidden; overflow-y: auto;
}
.modal.show { display: block; }
.modal-backdrop {
    position: fixed; inset: 0; z-index: 1050; background: rgba(15, 10, 16, 0.6);
}
.modal-backdrop.show { opacity: 1; }
.modal-dialog {
    position: relative; width: auto; margin: 1.75rem auto; max-width: 480px;
    display: flex; align-items: center; min-height: calc(100% - 3.5rem);
    transform: translateY(-20px); transition: transform 0.2s ease-out;
}
.modal.show .modal-dialog { transform: none; }
.modal-content {
    width: 100%; background: var(--surface); border: 1px solid var(--surface-2);
    border-radius: var(--radius-lg); padding: 8px;
}
.modal-header, .modal-footer { display: flex; align-items: center; padding: 14px 18px; gap: 10px; }
.modal-header { justify-content: space-between; }
.modal-footer { justify-content: flex-end; }
.modal-title { margin: 0; }
.modal-body { padding: 6px 18px 14px; color: var(--ink-dim); }
.btn-close {
    width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--surface-2);
    color: var(--ink-dim); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.btn-close:hover { background: var(--surface-3); color: var(--ink); }
.btn-close::before { content: "\00d7"; }

@media (max-width: 575.98px) {
    .modal-dialog { margin: 0; align-items: flex-end; min-height: 100%; max-width: 100%; }
    .modal-content { border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
    .modal-dialog { transform: translateY(100%); }
    .modal.show .modal-dialog { transform: translateY(0); }
}

/* =========================================================
   Fehlerseiten / Leerzustände
   ========================================================= */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .display-4 { margin-bottom: 0.75rem; }

@media (max-width: 479.98px) {
    .detail-actions { width: 100%; }
    .detail-actions .btn { flex: 1; }
}
