/*
 * Das Aussehen der Android-App, so genau wie im Browser moeglich.
 *
 * Die Farben sind eins zu eins die Rollen aus Theme.kt, die Schriftgroessen
 * die aus Type.kt. Material-3-Rollennamen bleiben erhalten — wer die App-Seite
 * aendert, findet hier dieselbe Bezeichnung wieder.
 *
 * dp und CSS-Pixel sind beide 1/160 Zoll bei Standarddichte, deshalb stehen
 * die Masse aus dem Compose-Code hier unveraendert.
 */
:root
{
    /* Die vier Farben aus dem Icon-Konzept. */
    --plate-green: #1E4739;
    --ring-track: #2F6350;
    --ring-progress: #E9A445;
    --ring-progress-light: #FFD08A;
    --plate-cream: #F5F0E6;

    --primary: #1E4739;
    --on-primary: #F5F0E6;
    --secondary: #8F5D12;
    --secondary-container: #FFD08A;
    --on-secondary-container: #13301F;

    --surface: #FBF9F4;
    --on-surface: #13301F;
    --surface-container-low: #F6F3EA;
    --surface-container: #F0EDE4;
    --surface-container-high: #EAE7DE;
    --surface-container-highest: #E4E1D8;
    --surface-variant: #DDE4DC;
    --on-surface-variant: #424A44;
    --outline: #727B74;
    --outline-variant: #C1CBC3;

    --error: #C5544A;
    --on-error: #FFFFFF;

    --protein: #2E8B6B;
    --carbs: #3E7BB8;
    --fat: #9A6BC4;

    /* Nur am Rechner sichtbar: der Grund neben der App-Spalte. */
    --frame: #D8D3C7;
    --shell-width: 460px;
}

@media (prefers-color-scheme: dark)
{
    :root
    {
        --primary: #8FD6B4;
        --on-primary: #00382A;
        --secondary: #E9A445;
        --secondary-container: #8F5D12;
        --on-secondary-container: #F5F0E6;

        --surface: #121915;
        --on-surface: #F5F0E6;
        --surface-container-low: #1A211C;
        --surface-container: #1E2520;
        --surface-container-high: #29302A;
        --surface-container-highest: #343B35;
        --surface-variant: #2A312C;
        --on-surface-variant: #C1CBC3;
        --outline: #8B948D;
        --outline-variant: #424A44;

        --error: #FFB4AB;
        --on-error: #690005;

        --protein: #9BFFD6;
        --carbs: #B6DCFF;
        --fat: #EDCBFF;

        --frame: #0A0F0C;
    }
}

*
{
    box-sizing: border-box;
}

/*
 * Das hidden-Attribut wirkt ueber "display: none" im Browser-Stylesheet — jede
 * eigene display-Regel schlaegt es. Ohne diese Zeile stand die Sperrschicht
 * dauerhaft ueber der Seite, weil sie "display: flex" mitbringt.
 */
[hidden]
{
    display: none !important;
}

html,
body
{
    margin: 0;
    height: 100%;
    color: var(--on-surface);
    /* bodyLarge aus Type.kt. Roboto ist die Schrift der App; auf dem iPhone
       gibt es sie nicht, dort uebernimmt die Systemschrift. */
    font: 400 16px/24px Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

html
{
    background: var(--frame);
}

body
{
    display: flex;
    flex-direction: column;
    background: var(--surface);
    /* Eine App ist keine Webseite: Der Inhalt bleibt so breit wie ein Handy. */
    max-width: var(--shell-width);
    margin: 0 auto;
}

@media (min-width: 500px)
{
    body
    {
        box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 8px 40px rgba(0, 0, 0, .16);
    }
}

/* ScreenTopBar: nur Titel, keine Flaeche. Die Startseite hat gar keinen. */
.topbar
{
    display: flex;
    align-items: center;
    gap: 4px;
    padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
    background: var(--surface);
}

.topbar h1
{
    margin: 0;
    /* titleLarge */
    font: 600 22px/28px Roboto, -apple-system, sans-serif;
}

.screen
{
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* LazyColumn contentPadding = 16.dp */
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.screen > *
{
    flex-shrink: 0;
}

/*
 * Bildlaufleiste in den Farben der App. Am Handy blendet das System sie
 * ohnehin aus, am Rechner passt sie sonst nicht zum Rest.
 */
.screen,
.thumbs,
.overlay-card
{
    scrollbar-width: thin;
    scrollbar-color: var(--outline-variant) transparent;
}

.screen::-webkit-scrollbar,
.thumbs::-webkit-scrollbar,
.overlay-card::-webkit-scrollbar
{
    width: 8px;
    height: 8px;
}

.screen::-webkit-scrollbar-track,
.thumbs::-webkit-scrollbar-track,
.overlay-card::-webkit-scrollbar-track
{
    background: transparent;
}

.screen::-webkit-scrollbar-thumb,
.thumbs::-webkit-scrollbar-thumb,
.overlay-card::-webkit-scrollbar-thumb
{
    background: var(--outline-variant);
    border-radius: 4px;
}

.screen::-webkit-scrollbar-thumb:hover,
.thumbs::-webkit-scrollbar-thumb:hover,
.overlay-card::-webkit-scrollbar-thumb:hover
{
    background: var(--outline);
}

/* NavigationBar */
.tabs
{
    display: flex;
    background: var(--surface-container);
    padding-bottom: env(safe-area-inset-bottom);
}

.tab
{
    flex: 1;
    border: 0;
    background: none;
    color: var(--on-surface-variant);
    font: 500 12px/16px Roboto, -apple-system, sans-serif;
    padding: 12px 0 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.tab-icon
{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 32px;
    border-radius: 16px;
    font-size: 20px;
    line-height: 1;
}

.tab.active
{
    color: var(--secondary);
}

.tab.active .tab-icon
{
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}

/* Tagesleiste: DateStrip.kt */
.daystrip
{
    display: flex;
    gap: 4px;
}

.day
{
    flex: 1;
    border: 0;
    border-radius: 12px;
    background: var(--surface-container-high);
    color: var(--on-surface);
    font: inherit;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.day small
{
    /* labelSmall */
    font: 500 11px/16px Roboto, -apple-system, sans-serif;
    color: var(--on-surface-variant);
}

.day.selected
{
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}

.day.selected small
{
    color: var(--on-secondary-container);
}

/* Rahmen um heute, damit es sich vom gewaehlten Tag unterscheidet. */
.day.today
{
    box-shadow: inset 0 0 0 2px var(--primary);
}

/* Card */
.card
{
    background: var(--surface-container-low);
    border-radius: 12px;
    padding: 16px;
}

.card.summary
{
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.row
{
    display: flex;
    align-items: center;
    gap: 8px;
}

.row.between
{
    justify-content: space-between;
}

.grow
{
    flex: 1;
    min-width: 0;
}

.muted
{
    color: var(--on-surface-variant);
    font: 500 11px/16px Roboto, -apple-system, sans-serif;
}

.error
{
    color: var(--error);
    font: 500 11px/16px Roboto, -apple-system, sans-serif;
}

/* Ringe */
.ring
{
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring-value
{
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
}

/* displayLarge, auf die Ringgroesse heruntergerechnet */
.ring-value .big
{
    font: 300 34px/36px Roboto, -apple-system, sans-serif;
    color: var(--on-surface);
}

.ring-value .big.over
{
    color: var(--error);
}

.ring-value .small
{
    font: 500 11px/13px Roboto, -apple-system, sans-serif;
    color: var(--on-surface-variant);
}

.macro-ring
{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.macro-ring figcaption,
.macro-ring .value
{
    font: 500 11px/13px Roboto, -apple-system, sans-serif;
}

.macro-rings
{
    flex: 1;
    display: flex;
    justify-content: space-around;
}

.p { color: var(--protein); }
.c { color: var(--carbs); }
.f { color: var(--fat); }

/* Mahlzeit-Ueberschrift */
.meal-head
{
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
}

/* Eintragskarte: 16dp Polster, Inhalt in einer Zeile — zusammen 77dp hoch. */
.entry
{
    background: var(--surface-container-low);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.entry-name
{
    font: 400 16px/24px Roboto, -apple-system, sans-serif;
}

.macros
{
    font: 500 11px/16px Roboto, -apple-system, sans-serif;
}

/* Formularfelder: OutlinedTextField */
label.field
{
    display: block;
}

label.field > span
{
    display: block;
    font: 500 11px/16px Roboto, -apple-system, sans-serif;
    color: var(--on-surface-variant);
    margin-bottom: 4px;
}

input,
textarea,
select
{
    width: 100%;
    color: var(--on-surface);
    background: transparent;
    border: 1px solid var(--outline);
    border-radius: 4px;
    padding: 14px 16px;
    /* Unter 16px zoomt Safari beim Fokus in das Feld hinein. */
    font: 400 16px/24px Roboto, -apple-system, sans-serif;
}

input:focus,
textarea:focus,
select:focus
{
    outline: none;
    border-color: var(--primary);
    border-width: 2px;
    padding: 13px 15px;
}

input:read-only
{
    color: var(--on-surface-variant);
}

textarea
{
    min-height: 120px;
    resize: vertical;
}

.fields
{
    display: flex;
    gap: 8px;
}

.fields > label
{
    flex: 1;
    min-width: 0;
}

button
{
    font: inherit;
}

/* Button: gefuellte Pille, labelLarge */
.btn
{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border: 0;
    border-radius: 20px;
    padding: 10px 24px;
    min-height: 40px;
    background: var(--primary);
    color: var(--on-primary);
    font: 500 14px/20px Roboto, -apple-system, sans-serif;
    text-align: center;
}

.btn.secondary
{
    background: transparent;
    color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--outline);
}

.btn.danger
{
    background: var(--error);
    color: var(--on-error);
}

.btn:disabled
{
    background: rgba(19, 48, 31, .12);
    color: rgba(19, 48, 31, .38);
    box-shadow: none;
}

@media (prefers-color-scheme: dark)
{
    .btn:disabled
    {
        background: rgba(245, 240, 230, .12);
        color: rgba(245, 240, 230, .38);
    }
}

.btn-row
{
    display: flex;
    gap: 8px;
}

.btn-row .btn
{
    flex: 1;
}

/* Zeile aus "Hinzufügen" und dem Zusammenstellen-Knopf */
/* Gemessen: Zeile 64 hoch, Knopf 48, der quadratische 72 breit und 40 hoch. */
.action-row
{
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface);
    height: 64px;
}

.action-row .btn
{
    flex: 1;
    height: 48px;
    border-radius: 24px;
    margin: 0;
}

.square-button
{
    flex: 0 0 auto;
    width: 72px;
    height: 40px;
    border: 1px solid var(--outline);
    border-radius: 20px;
    background: transparent;
    color: var(--primary);
    font-size: 18px;
    line-height: 1;
}

/* Werkzeugleiste im Erfassen-Tab: runde Knoepfe rechts */
.tool-row
{
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-container);
}

.tool-button
{
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 24px;
    background: var(--secondary-container);
    color: var(--on-secondary-container);
    font-size: 20px;
    line-height: 1;
}

.icon-button
{
    border: 0;
    background: none;
    font-size: 20px;
    color: var(--on-surface-variant);
    width: 40px;
    height: 40px;
    border-radius: 20px;
    line-height: 1;
}

/* Listenzeile mit Trennlinie, wie die Produktliste */
.list-row
{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--outline-variant);
    background: none;
    color: inherit;
    text-align: left;
    width: 100%;
    border-left: 0;
    border-right: 0;
    border-top: 0;
}

.chips
{
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* FilterChip */
.chip
{
    border: 1px solid var(--outline);
    border-radius: 8px;
    background: transparent;
    color: var(--on-surface-variant);
    font: 500 14px/20px Roboto, -apple-system, sans-serif;
    padding: 6px 16px;
    min-height: 32px;
}

.chip.selected
{
    background: var(--secondary-container);
    border-color: transparent;
    color: var(--on-secondary-container);
}

/* Meldung oben — TopNotice.kt */
.notice
{
    position: fixed;
    top: calc(env(safe-area-inset-top) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    max-width: calc(var(--shell-width) - 32px);
    /* Dieselbe Farbe wie die Knoepfe, damit die Meldung zur App gehoert
       und nicht wie ein Fremdkoerper wirkt. */
    background: var(--primary);
    color: var(--on-primary);
    border-radius: 8px;
    padding: 10px 16px;
    font: 500 14px/20px Roboto, -apple-system, sans-serif;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}

/* LoadingOverlay.kt */
.overlay
{
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/*
 * LoadingOverlay.kt: eigene Flaeche statt Text auf dem Schleier — auf
 * schwarzem Grund gibt es keine Textfarbe, die in beiden Themes lesbar bleibt.
 * Der Schleier schluckt jede Beruehrung, sonst liesse sich waehrend einer
 * Schaetzung weitertippen und die Anfrage doppelt ausloesen.
 */
.overlay-card
{
    background: var(--surface-container-high);
    color: var(--on-surface);
    border-radius: 16px;
    padding: 24px 32px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.overlay-card p
{
    margin: 0;
    font: 400 16px/24px Roboto, -apple-system, sans-serif;
}

/* AlertDialog aus Material 3 */
.dialog
{
    background: var(--surface-container-high);
    color: var(--on-surface);
    border-radius: 28px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.dialog h2
{
    margin: 0 0 16px;
    /* headlineSmall */
    font: 400 24px/32px Roboto, -apple-system, sans-serif;
}

.dialog p
{
    margin: 0 0 24px;
    /* bodyMedium */
    font: 400 14px/20px Roboto, -apple-system, sans-serif;
    color: var(--on-surface-variant);
}

/* Unten rechts nebeneinander, nicht gestapelt und nicht ueber die Breite. */
.dialog-actions
{
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.text-button
{
    border: 0;
    background: none;
    color: var(--primary);
    border-radius: 20px;
    padding: 10px 12px;
    min-height: 40px;
    font: 500 14px/20px Roboto, -apple-system, sans-serif;
}

.dialog-confirm
{
    border: 0;
    border-radius: 20px;
    padding: 10px 24px;
    min-height: 40px;
    background: var(--primary);
    color: var(--on-primary);
    font: 500 14px/20px Roboto, -apple-system, sans-serif;
}

.dialog-confirm.danger
{
    background: var(--error);
    color: var(--on-error);
}

/* CircularProgressIndicator: 40dp, 4dp Strichstaerke. */
.spinner
{
    width: 40px;
    height: 40px;
    border: 4px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-radius: 50%;
    animation: spin .9s linear infinite;
}

@keyframes spin
{
    to { transform: rotate(360deg); }
}

video
{
    width: 100%;
    border-radius: 12px;
    background: #000;
}

.thumbs
{
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.thumb
{
    position: relative;
    flex: 0 0 auto;
}

.thumb img
{
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 12px;
}

.thumb button
{
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: var(--error);
    color: var(--on-error);
    line-height: 1;
}
