/* ------------------------------------------------------------------
   Mealo design tokens. Soft, warm and calm: off-white background,
   sage green as the main color, apricot as a warm accent.
   ------------------------------------------------------------------ */
:root {
    --m-bg: #F7F5F0;
    --m-surface: #FFFFFF;
    --m-text: #2B2F2C;
    --m-muted: #7D847F;
    --m-faint: #A9AEA9;
    --m-line: #ECE8E1;

    --m-primary: #4F8A6B;
    --m-primary-dark: #3D6F55;
    --m-primary-soft: #E7F1EB;
    --m-accent: #E9A15B;
    --m-accent-soft: #FCEFE1;

    --m-kcal: #D9963A;
    --m-kcal-soft: #FBF1DF;
    --m-protein: #B97A55;
    --m-protein-soft: #F7EDE6;
    --m-veg: #5E9E5A;
    --m-veg-soft: #E9F3E7;

    --m-danger: #C2564B;

    --m-radius: 20px;
    --m-radius-sm: 14px;
    --m-shadow: 0 1px 2px rgba(43, 47, 44, 0.04), 0 4px 16px rgba(43, 47, 44, 0.05);
    --m-nav-height: 68px;
}

html, body {
    font-family: 'Rubik', 'Segoe UI', Arial, sans-serif;
    background: var(--m-bg);
    color: var(--m-text);
    -webkit-tap-highlight-color: transparent;
}

h1:focus {
    outline: none;
}

/* Room for the floating bottom navigation, so the last row is never hidden behind it. */
.mealo-main {
    min-height: 100vh;
    padding-bottom: calc(var(--m-nav-height) + 40px + env(safe-area-inset-bottom));
    /* MudBlazor reserves room for a top app bar; Mealo has none. */
    padding-top: env(safe-area-inset-top) !important;
}

/* ---------- Page header ---------- */
.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 8px 4px 16px;
}

.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 0 18px;
}

.day-title {
    text-align: center;
    flex: 1;
}

.day-kicker {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--m-primary);
    letter-spacing: 0.02em;
    min-height: 1.1em;
}

.day-title h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin: 2px 0 0;
}

.today-link {
    background: none;
    border: none;
    color: var(--m-primary);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--m-surface);
    box-shadow: var(--m-shadow);
    color: var(--m-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* ---------- Cards ---------- */
.m-card {
    background: var(--m-surface);
    border-radius: var(--m-radius);
    box-shadow: var(--m-shadow);
    padding: 18px;
    margin-bottom: 14px;
}

.m-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.m-hint {
    color: var(--m-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0 0 12px;
}

/* ---------- Day summary ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat {
    border-radius: var(--m-radius-sm);
    padding: 12px 6px 10px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--m-muted);
    margin-top: 2px;
}

.stat-icon {
    font-size: 1.05rem;
    display: block;
    margin-bottom: 2px;
}

.stat-kcal { background: var(--m-kcal-soft); }
.stat-protein { background: var(--m-protein-soft); }
.stat-veg { background: var(--m-veg-soft); }

.meal-strip {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
    font-size: 1.3rem;
    line-height: 1;
}

.summary-note {
    text-align: center;
    color: var(--m-muted);
    font-size: 0.8rem;
    margin-top: 10px;
}

/* ---------- Composer ---------- */
.add-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border: none;
    border-radius: var(--m-radius);
    background: var(--m-surface);
    box-shadow: var(--m-shadow);
    color: var(--m-muted);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 18px;
    text-align: start;
}

.add-button-plus {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--m-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

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

.m-chip {
    border: 1px solid var(--m-line);
    background: var(--m-surface);
    color: var(--m-text);
    border-radius: 999px;
    padding: 7px 14px;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.m-chip.selected {
    background: var(--m-primary-soft);
    border-color: var(--m-primary);
    color: var(--m-primary-dark);
    font-weight: 500;
}

.composer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.time-input {
    border: 1px solid var(--m-line);
    border-radius: var(--m-radius-sm);
    padding: 8px 12px;
    font: inherit;
    color: var(--m-text);
    background: var(--m-surface);
}

.composer-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}

/* ---------- Entries ---------- */
.section-label {
    color: var(--m-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin: 6px 6px 10px;
}

.entry-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--m-surface);
    border-radius: var(--m-radius);
    box-shadow: var(--m-shadow);
    padding: 14px 14px 14px 8px;
    margin-bottom: 12px;
}

.entry-card.planned {
    background: transparent;
    box-shadow: none;
    border: 1.5px dashed var(--m-line);
}

.rating-bubble {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    background: #F1EFEA;
}

.entry-body {
    flex: 1;
    min-width: 0;
}

.entry-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--m-muted);
}

.entry-meta .meal-name {
    color: var(--m-primary-dark);
    font-weight: 500;
}

.rating-label {
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.72rem;
    font-weight: 500;
}

.entry-text {
    font-size: 1rem;
    line-height: 1.45;
    margin: 4px 0 6px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.entry-nums {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.82rem;
    color: var(--m-muted);
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
    text-align: start;
}

.entry-nums b {
    color: var(--m-text);
    font-weight: 500;
}

.entry-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--m-line);
}

.entry-reason {
    font-size: 0.85rem;
    color: var(--m-text);
    margin-bottom: 8px;
}

.entry-note {
    font-size: 0.8rem;
    color: var(--m-muted);
    font-style: italic;
    margin-top: 6px;
}

.item-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.85rem;
}

.item-row + .item-row {
    border-top: 1px dashed var(--m-line);
}

.item-sub {
    color: var(--m-muted);
    font-size: 0.75rem;
}

.item-nums {
    color: var(--m-muted);
    white-space: nowrap;
    text-align: end;
    font-size: 0.8rem;
}

.entry-status {
    font-size: 0.82rem;
    color: var(--m-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.entry-error {
    font-size: 0.85rem;
    color: var(--m-danger);
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--m-primary);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.ate-btn {
    border: 1px solid var(--m-primary);
    background: var(--m-primary-soft);
    color: var(--m-primary-dark);
    border-radius: 999px;
    padding: 4px 12px;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

/* ---------- Empty and coming-soon states ---------- */
.empty-state {
    text-align: center;
    padding: 36px 20px;
    color: var(--m-muted);
}

.empty-emoji {
    font-size: 2.6rem;
    display: block;
    margin-bottom: 10px;
}

.empty-title {
    color: var(--m-text);
    font-size: 1.05rem;
    font-weight: 500;
    margin-bottom: 4px;
}

/* ---------- Rating picker (edit dialog) ---------- */
.rating-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.rating-option {
    border: 1.5px solid transparent;
    border-radius: var(--m-radius-sm);
    background: #F6F4EF;
    padding: 8px 2px;
    font: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.rating-option span:first-child {
    font-size: 1.4rem;
}

.rating-option span:last-child {
    font-size: 0.68rem;
    color: var(--m-muted);
}

.rating-option.selected {
    border-color: var(--m-primary);
    background: var(--m-primary-soft);
}

/* ---------- Bottom navigation (floating) ---------- */
.mealo-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    height: var(--m-nav-height);
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    border-radius: 24px;
    box-shadow: 0 6px 24px rgba(43, 47, 44, 0.12);
    z-index: 1100;
    padding: 0 6px;
}

.mealo-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.7rem;
    color: var(--m-faint);
    text-decoration: none;
}

.mealo-nav-icon {
    width: 46px;
    height: 28px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.mealo-nav-item.active {
    color: var(--m-primary-dark);
    font-weight: 500;
}

.mealo-nav-item.active .mealo-nav-icon {
    background: var(--m-primary-soft);
}

/* ---------- MudBlazor touch-ups ---------- */
.mud-input-outlined-border {
    border-radius: var(--m-radius-sm) !important;
}

.mud-button-root {
    border-radius: 999px !important;
    text-transform: none !important;
}

.mud-dialog {
    border-radius: var(--m-radius) !important;
}

/* ---------- Blazor framework UI ---------- */
#blazor-error-ui {
    color-scheme: light only;
    background: #FFF8E1;
    bottom: calc(var(--m-nav-height) + 20px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    width: auto;
    border-radius: var(--m-radius-sm);
    box-shadow: var(--m-shadow);
    box-sizing: border-box;
    display: none;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    z-index: 1200;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        left: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "אירעה שגיאה.";
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 6rem;
    height: 6rem;
    inset: 30vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #E7E3DC;
        stroke-width: 0.5rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #4F8A6B;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    color: #7D847F;
    inset: calc(30vh + 2.6rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "טוען...");
    }
