/* =============================================================================
   BodyPilot · Page layout
   Mobile-first. Sidebar + Dashboard-Cards aktivieren sich ab 1024 px.
   ========================================================================= */

#app { min-height: 100vh; min-height: 100dvh; }


/* ─────────────────────────────────────────────────────────────────────────
   APP-SHELL
   ───────────────────────────────────────────────────────────────────────── */

.bp-app-shell {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}
.bp-sidebar { display: none; }
.bp-content { width: 100%; min-width: 0; }

/* Mobile: vertikales Padding für jeden Page-Container (außer Auth-Bare-Layouts) */
.bp-app-shell:not(.bp-app-shell--bare) .bp-content .container {
    padding-top: 24px;
    padding-bottom: 96px;
}


/* ─────────────────────────────────────────────────────────────────────────
   Today (Mobile + Desktop) — Cards mit klarer vertikaler Rhythmik
   ───────────────────────────────────────────────────────────────────────── */

.bp-today-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.bp-today-summary {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Hero-Card (Ringe + Bilanz) auf Mobile */
.bp-today-summary > .bp-hero {
    background: var(--surface-1);
    border-radius: var(--radius-xl);
    padding: 20px 18px;
}
.bp-today-summary > .bp-hero .bp-macro-legend { margin-top: 20px; }

/* Stats-Row (Wasser · Streak · Recovery · Schlaf) */
.bp-today-summary > .bp-mini-stats-grid {
    margin-top: 0;     /* Gap kommt vom äusseren flex */
}

/* Mahlzeiten-Card */
.bp-today-meals {
    background: var(--surface-1);
    border-radius: var(--radius-xl);
    padding: 18px;
    position: relative;
}
@media (min-width: 640px) {
    .bp-today-summary > .bp-hero { padding: 24px; }
    .bp-today-meals { padding: 20px; }
}
.bp-today-meals .bp-section-header {
    margin-bottom: 12px;
}
.bp-today-meals .bp-meal-row:last-of-type {
    border-bottom: 0;
}
.bp-today-meals .bp-quick-add-bar {
    margin-top: 16px;
}


/* ─────────────────────────────────────────────────────────────────────────
   Stats-Page (Mobile + Desktop)
   ───────────────────────────────────────────────────────────────────────── */

.bp-stats-section {
    margin-top: 16px;
    padding: 20px;
    background: var(--surface-1);
    border-radius: var(--radius-xl);
}
.bp-stats-section .bp-section-header { margin-bottom: 16px; }

.bp-weekly-heatmap-labels {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 10px;
    text-align: center;
    font-size: 10px;
    line-height: 1.4;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}


/* ─────────────────────────────────────────────────────────────────────────
   Account-Page
   Mobile: Single-Column-Stack via _section-Cards (haben margin-bottom).
   Desktop: 2-Spalten-Grid.
   ───────────────────────────────────────────────────────────────────────── */

.bp-card--account {
    background: var(--surface-1);
    border-radius: var(--radius-xl);
    padding: 24px;
}

.bp-account-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.bp-account-section--wide { width: 100%; }


/* ─────────────────────────────────────────────────────────────────────────
   AUTH-PAGES (Login · Register · Verify · Reset)
   Mobile: schmaler Card-Stack, vertikal mittig auf der Page.
   Desktop: zentriert in flex-Container, eigene Card-Surface.
   ───────────────────────────────────────────────────────────────────────── */

.bp-app-shell--bare .bp-content {
    background: var(--surface-0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
}
.bp-app-shell--bare .bp-content > * {
    width: 100%;
    max-width: 440px;
}

.bp-auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Auth-Container: Card-Surface */
.bp-app-shell--bare[data-bare="auth"] .bp-content .container {
    background: var(--surface-1);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    width: 100%;
    max-width: 100%;
}

/* Wizard / Scanner / Verify: nur zentriert, ohne extra Card */
.bp-app-shell--bare:not([data-bare="auth"]) .bp-content .container {
    width: 100%;
    max-width: 100%;
}


/* ─────────────────────────────────────────────────────────────────────────
   DESKTOP (≥ 1024 px) — Sidebar + Dashboard
   ───────────────────────────────────────────────────────────────────────── */

@media (min-width: 1024px) {

    .bp-app-shell:not(.bp-app-shell--bare) {
        grid-template-columns: 256px minmax(0, 1fr);
    }

    /* ── Sidebar ──────────────────────────────────────────────────────── */
    .bp-sidebar {
        display: flex;
        flex-direction: column;
        background: var(--surface-0);
        border-right: 1px solid var(--divider-strong);
        padding: 32px 20px 24px;
        position: sticky;
        top: 0;
        height: 100vh;
        height: 100dvh;
        gap: 8px;
    }

    .bp-sidebar__brand {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 18px;
        font-weight: var(--weight-medium);
        letter-spacing: var(--tracking-tight);
        color: var(--text-primary);
        padding: 0 8px;
        margin-bottom: 32px;
    }
    .bp-sidebar__brand-mark { display: inline-flex; }

    .bp-sidebar__nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
    }
    .bp-sidebar__link {
        position: relative;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        border-radius: var(--radius-md);
        color: var(--text-secondary);
        font-size: var(--text-medium);
        font-weight: var(--weight-medium);
        transition: background var(--duration-fast) var(--ease-out),
                    color var(--duration-fast) var(--ease-out);
        cursor: pointer;
    }
    .bp-sidebar__link svg { flex-shrink: 0; color: currentColor; opacity: 0.85; }
    .bp-sidebar__link:hover {
        background: var(--surface-1);
        color: var(--text-primary);
    }
    .bp-sidebar__link[aria-current="page"] {
        background: var(--surface-2);
        color: var(--text-primary);
    }
    .bp-sidebar__link[aria-current="page"]::before {
        content: '';
        position: absolute;
        left: 0;
        top: 10px;
        bottom: 10px;
        width: 3px;
        border-radius: 2px;
        background: var(--text-primary);
    }
    .bp-sidebar__footer {
        margin-top: auto;
        padding-top: 18px;
        border-top: 1px solid var(--divider-subtle);
    }


    /* ── Content (alle nicht-bare Pages) ──────────────────────────────── */
    .bp-content .container {
        max-width: 1200px;
        padding: 48px 56px 96px;
    }

    .bp-content .bp-header-bar { margin-bottom: 32px; }
    .bp-content .bp-header-bar__title { font-size: 32px; letter-spacing: -0.02em; }
    .bp-content .bp-header-bar__actions { display: none; }


    /* ── Today: Dashboard-Layout ─────────────────────────────────────── */
    .bp-today-grid { gap: 24px; }
    .bp-today-summary { gap: 24px; }

    .bp-today-summary > .bp-hero {
        padding: 40px 48px;
        align-items: center;
        gap: 64px;
    }
    .bp-today-summary > .bp-hero .bp-hero__value { font-size: 52px; }
    .bp-today-summary > .bp-hero .bp-macro-legend { margin-top: 24px; gap: 32px; }
    .bp-today-summary > .bp-hero .bp-macro-legend__value { font-size: 18px; }

    /* 4 Stats nebeneinander */
    .bp-today-summary > .bp-mini-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 16px;
    }
    .bp-mini-stat-card { padding: 20px; }
    .bp-today-summary .bp-mini-stat-card__value { font-size: 28px; }

    /* Mahlzeiten-Card mit mehr Luft */
    .bp-today-meals {
        padding: 28px 32px;
    }
    .bp-today-meals .bp-meal-row { padding: 16px 0; }
    /* QuickAdd auf Desktop: rechts oben in der Mahlzeiten-Card */
    .bp-today-meals .bp-quick-add-bar {
        position: absolute;
        right: 28px;
        top: 24px;
        margin-top: 0;
        grid-template-columns: repeat(3, auto);
        gap: 8px;
        width: auto;
    }
    .bp-today-meals .bp-quick-add-btn {
        padding: 10px 16px;
        flex-direction: row;
        gap: 8px;
        font-size: 13px;
    }


    /* ── Stats-Page (Desktop) ─────────────────────────────────────────── */
    .bp-content .bp-mini-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 16px;
    }
    .bp-stats-section { padding: 28px 32px; margin-top: 20px; }
    .bp-weekly-heatmap { max-width: 720px; }
    .bp-weekly-heatmap-labels { max-width: 720px; }


    /* ── Account: 2-Spalten-Grid ─────────────────────────────────────── */
    .bp-account-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        align-items: start;
    }
    .bp-account-grid > .bp-account-section--wide {
        grid-column: 1 / -1;
    }


    /* ── Auth-Pages (Desktop) ─────────────────────────────────────────── */
    .bp-app-shell--bare .bp-content > * {
        max-width: 600px;
    }
    .bp-app-shell--bare[data-bare="auth"] .bp-content > * {
        max-width: 440px;
    }
    .bp-app-shell--bare[data-bare="auth"] .bp-content .container {
        padding: 48px 40px;
    }
}


/* ─────────────────────────────────────────────────────────────────────────
   Mobile-Polish (kleiner als 1024 px)
   ───────────────────────────────────────────────────────────────────────── */

@media (max-width: 1023px) {
    .bp-sidebar { display: none !important; }
    .bp-content .bp-header-bar__title { font-size: var(--text-large); }
}
