/* PFAD: wein/public/assets/app.css – Weinkeller, gemeinsames Stylesheet */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bordeaux-dark: #3a1020;
    --bordeaux-deep: #55182e;
    --bordeaux:      #7b2340;
    --bordeaux-mid:  #9c3355;
    --bordeaux-pale: #f6e9ee;
    --gold:          #b8892b;
    --gold-light:    #e3c168;
    --gruen:         #2f7a4f;
    --rot:           #b3261e;
    --rot-pale:      #fdecea;

    --bg:            #f7f3f1;
    --card:          #ffffff;
    --text:          #23161b;
    --text-muted:    #7d6c72;
    --border:        #e3d8dc;

    --shadow-sm:     0 1px 3px rgba(58,16,32,.10);
    --shadow-md:     0 4px 18px rgba(58,16,32,.14);
    --shadow-lg:     0 12px 40px rgba(58,16,32,.22);
    --radius:        12px;
    --radius-sm:     8px;

    --topbar-h:      56px;
    /* Platz fuer Handys mit Notch / Gestenleiste */
    --safe-top:      env(safe-area-inset-top, 0px);
    --safe-bottom:   env(safe-area-inset-bottom, 0px);
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.45;
    overscroll-behavior-y: contain;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) 12px 0;
    background: linear-gradient(135deg, var(--bordeaux-dark), var(--bordeaux));
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 200;
    box-shadow: var(--shadow-sm);
}
.topbar h1 {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: .3px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-btn {
    background: rgba(255,255,255,.12);
    border: 0;
    color: #fff;
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}
.topbar-btn:hover { background: rgba(255,255,255,.22); }
.topbar-btn:disabled { opacity: .45; cursor: default; }

/* Sync-Ampel */
.sync-punkt {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--gold-light);
    flex: 0 0 auto;
    box-shadow: 0 0 0 3px rgba(255,255,255,.13);
}
.sync-punkt.online  { background: #5bd48a; }
.sync-punkt.offline { background: #d9d0d3; }
.sync-punkt.aktiv   { background: var(--gold-light); animation: pulsieren 1s infinite; }
.sync-punkt.fehler  { background: #ff8a80; }
@keyframes pulsieren { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ── Grundlayout ─────────────────────────────────────────────────────────── */
main {
    padding: calc(var(--topbar-h) + var(--safe-top) + 12px) 12px
             calc(84px + var(--safe-bottom));
    max-width: 900px;
    margin: 0 auto;
}

.leer {
    text-align: center;
    color: var(--text-muted);
    padding: 56px 20px;
}
.leer .gross { font-size: 3rem; display: block; margin-bottom: 12px; opacity: .5; }

/* ── Suchleiste / Filter ─────────────────────────────────────────────────── */
.filterzeile {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.filterzeile input[type=search] { flex: 1 1 180px; }
.filterzeile select { flex: 0 1 auto; width: auto; }

/* ── Weinkarten ──────────────────────────────────────────────────────────── */
.wein-liste { display: flex; flex-direction: column; gap: 10px; }

.wein-karte {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    overflow: hidden;
    cursor: pointer;
    border-left: 4px solid var(--border);
    transition: box-shadow .15s, transform .15s;
}
.wein-karte:active { transform: scale(.99); }
.wein-karte:hover  { box-shadow: var(--shadow-md); }

.wein-karte[data-art="Rot"]        { border-left-color: var(--bordeaux); }
.wein-karte[data-art="Weiss"]      { border-left-color: var(--gold-light); }
.wein-karte[data-art="Rose"]       { border-left-color: #e79bb0; }
.wein-karte[data-art="Schaumwein"] { border-left-color: #9fc5d8; }
.wein-karte[data-art="Suesswein"]  { border-left-color: var(--gold); }

.wein-foto {
    width: 82px;
    flex: 0 0 82px;
    background: var(--bordeaux-pale) center/cover no-repeat;
    display: grid;
    place-items: center;
    color: var(--bordeaux-mid);
    font-size: 1.6rem;
}
.wein-text { padding: 10px 12px; flex: 1; min-width: 0; }
.wein-text h3 {
    font-size: .98rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wein-meta {
    font-size: .8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.wein-fuss {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: .78rem;
    color: var(--text-muted);
}

.sterne { color: var(--gold); letter-spacing: 1px; font-size: .85rem; }
.sterne .leer-stern { color: #ddd2d6; }

.badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    background: var(--bordeaux-pale);
    color: var(--bordeaux);
}
.badge.offen   { background: #fff4d6; color: #8a6400; }
.badge.bestand { background: #e6f4ec; color: var(--gruen); }

/* ── Schaltflaechen ──────────────────────────────────────────────────────── */
.btn {
    border: 0;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    font-size: .93rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    background: var(--bordeaux);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}
.btn:hover    { background: var(--bordeaux-mid); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sekundaer { background: var(--card); color: var(--bordeaux); border: 1px solid var(--border); }
.btn.sekundaer:hover { background: var(--bordeaux-pale); }
.btn.gefahr   { background: var(--rot); }
.btn.breit    { width: 100%; }

/* Foto-Aufnahme, schwebend unten */
.fab {
    position: fixed;
    right: 16px;
    bottom: calc(16px + var(--safe-bottom));
    height: 58px;
    padding: 0 22px;
    border-radius: 29px;
    box-shadow: var(--shadow-lg);
    font-size: 1rem;
    z-index: 150;
}

/* ── Formulare ───────────────────────────────────────────────────────────── */
label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; }

input, select, textarea {
    width: 100%;
    padding: 10px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px;           /* 16px verhindert das Zoomen auf iOS */
    background: var(--card);
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--bordeaux-mid);
    outline-offset: -1px;
}
textarea { min-height: 78px; resize: vertical; }

.feld { margin-bottom: 12px; }
.feld-reihe { display: flex; gap: 10px; }
.feld-reihe > * { flex: 1; min-width: 0; }

fieldset {
    border: 0;
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}
legend {
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--bordeaux);
    padding: 0 0 8px;
}

/* Von der KI ausgefuellte Felder kurz hervorheben */
.ki-befuellt { background: #fffbe9; border-color: var(--gold-light); }

/* ── Sterne-Eingabe ──────────────────────────────────────────────────────── */
.sterne-wahl { display: flex; gap: 4px; }
.sterne-wahl button {
    background: none;
    border: 0;
    font-size: 1.9rem;
    line-height: 1;
    cursor: pointer;
    color: #ddd2d6;
    padding: 0;
    width: auto;
}
.sterne-wahl button.an { color: var(--gold); }

/* ── Dialoge / Ansichten ─────────────────────────────────────────────────── */
.ansicht { display: none; }
.ansicht.aktiv { display: block; }

.dialog-hg {
    position: fixed;
    inset: 0;
    background: rgba(35,10,20,.55);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 400;
}
.dialog-hg.offen { display: flex; }
.dialog {
    background: var(--bg);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 18px 14px calc(18px + var(--safe-bottom));
    box-shadow: var(--shadow-lg);
}
@media (min-width: 620px) {
    .dialog-hg { align-items: center; }
    .dialog { border-radius: 16px; }
}
.dialog h2 { font-size: 1.1rem; margin-bottom: 14px; color: var(--bordeaux-dark); }

/* ── Meldungen ───────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(84px + var(--safe-bottom));
    transform: translateX(-50%);
    background: var(--bordeaux-dark);
    color: #fff;
    padding: 11px 18px;
    border-radius: 999px;
    font-size: .87rem;
    box-shadow: var(--shadow-lg);
    z-index: 500;
    max-width: 90vw;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
}
.toast.sichtbar { opacity: 1; }
.toast.fehler   { background: var(--rot); }

.hinweis {
    background: var(--bordeaux-pale);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: .84rem;
    color: var(--bordeaux-deep);
    margin-bottom: 12px;
}
.hinweis.fehler { background: var(--rot-pale); color: #8c1d18; }

/* ── Fotovorschau im Formular ────────────────────────────────────────────── */
.foto-box {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bordeaux-pale);
    margin-bottom: 12px;
    min-height: 150px;
    display: grid;
    place-items: center;
}
.foto-box img { width: 100%; display: block; max-height: 46vh; object-fit: contain; }
.foto-box .platzhalter { color: var(--bordeaux-mid); text-align: center; padding: 26px; font-size: .87rem; }
.foto-aktionen { display: flex; gap: 8px; margin-bottom: 14px; }
.foto-aktionen .btn { flex: 1; }

/* Vorder- und Rueckenetikett nebeneinander. Jede Spalte traegt ihr eigenes
   Bild und ihre eigenen Tasten, damit klar ist, was wozu gehoert. */
.foto-paar { display: flex; gap: 8px; margin-bottom: 10px; align-items: flex-end; }
.foto-paar > * { flex: 1; min-width: 0; }
.foto-paar .foto-box { margin-bottom: 6px; min-height: 110px; }
.foto-paar .foto-box img { max-height: 30vh; }
.foto-paar .btn { width: 100%; margin-bottom: 4px; }
.foto-seite-titel {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Fortschritt der KI-Analyse */
.ki-laeuft {
    position: absolute;
    inset: 0;
    background: rgba(58,16,32,.72);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: .88rem;
    text-align: center;
    padding: 20px;
}

/* ── Detailansicht ───────────────────────────────────────────────────────── */
.detail-foto { width: 100%; border-radius: var(--radius); display: block; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.daten-tabelle { width: 100%; border-collapse: collapse; font-size: .88rem; }
.daten-tabelle th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 10px 6px 0;
    width: 42%;
    vertical-align: top;
}
.daten-tabelle td { padding: 6px 0; vertical-align: top; word-break: break-word; }
/* Zeitangaben sollen nicht mitten im Datum umbrechen. */
.daten-tabelle td.zeitpunkt { white-space: nowrap; word-break: normal; }
.daten-tabelle tr + tr th, .daten-tabelle tr + tr td { border-top: 1px solid var(--border); }
.daten-tabelle a { color: var(--bordeaux); }

.abschnitt-titel {
    font-size: .74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--bordeaux);
    margin: 18px 0 8px;
}

.bewertung-eintrag {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}
.bewertung-kopf { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-muted); flex-wrap: wrap; }
.bewertung-eintrag p { font-size: .88rem; margin-top: 5px; white-space: pre-wrap; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-seite {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(150deg, var(--bordeaux-dark), var(--bordeaux) 60%, var(--bordeaux-mid));
}
.login-karte {
    background: var(--card);
    padding: 30px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 360px;
}
.login-karte .logo { font-size: 2.6rem; text-align: center; display: block; margin-bottom: 6px; }
.login-karte h1 { font-size: 1.3rem; text-align: center; color: var(--bordeaux-dark); margin-bottom: 4px; }
.login-karte .unter { text-align: center; color: var(--text-muted); font-size: .84rem; margin-bottom: 22px; }
