/* Weekly recap card + "recap ready" banner.
   Structure mirrors diet-plan.css (bottom sheet on phones, centred dialog from
   700px up) so the two overlays feel like the same app. */

.weekly-summary-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1080;
}
.weekly-summary-overlay.d-none { display: none; }

.weekly-summary-panel {
    background: #fff;
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
}
@media (min-width: 700px) {
    .weekly-summary-overlay { align-items: center; }
    .weekly-summary-panel { border-radius: 16px; }
}

.weekly-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #8B0000;
    color: #fff;
    flex: 0 0 auto;
}
.weekly-summary-title { margin: 0; font-size: 1rem; }
.weekly-summary-header-actions { display: flex; align-items: center; gap: 10px; }
.weekly-summary-close,
.weekly-summary-refresh {
    background: none; border: none; color: #fff;
    font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.weekly-summary-refresh { font-size: 1.25rem; }
.weekly-summary-refresh:disabled { opacity: 0.5; cursor: default; }
.weekly-summary-refresh.is-spinning i {
    display: inline-block;
    animation: weekly-summary-spin 1s linear infinite;
}
@keyframes weekly-summary-spin { to { transform: rotate(360deg); } }

.weekly-summary-body {
    padding: 16px 18px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.weekly-summary-loading,
.weekly-summary-empty { color: #666; font-size: 0.92rem; text-align: center; padding: 24px 0; }
.weekly-summary-loading small { color: #999; }
.weekly-summary-back {
    display: inline-block; margin-top: 12px;
    background: none; border: 1px solid #8B0000; color: #8B0000;
    border-radius: 999px; padding: 6px 14px; font-size: 0.85rem; cursor: pointer;
}

/* ---------------------------------------------------------- period */

.weekly-summary-period { margin-bottom: 14px; }
.weekly-summary-range {
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: #8a8a8a;
}
.weekly-summary-headline { margin: 2px 0 0; font-size: 1.12rem; color: #222; }
.weekly-summary-generated { margin-top: 4px; font-size: 0.74rem; color: #a0a0a0; }

.weekly-summary-opening { font-size: 0.95rem; color: #333; margin: 0 0 16px; }
.weekly-summary-closing {
    font-size: 0.9rem; color: #555; margin: 16px 0 0;
    padding-top: 12px; border-top: 1px solid #eee;
}

/* -------------------------------------------------------- coverage */

.weekly-summary-coverage { margin-bottom: 18px; }
.weekly-summary-dots { display: flex; gap: 6px; }
.weekly-summary-dot {
    flex: 1; height: 30px; border-radius: 6px; background: #f0f0f0;
    display: flex; align-items: center; justify-content: center;
}
.weekly-summary-dot em {
    font-style: normal; font-size: 0.68rem; text-transform: uppercase; color: #999;
}
.weekly-summary-dot.complete { background: #2e7d32; }
.weekly-summary-dot.complete em { color: #fff; }
.weekly-summary-dot.partial { background: #ffd48a; }
.weekly-summary-dot.partial em { color: #7a5200; }
.weekly-summary-coverage-legend { font-size: 0.8rem; color: #777; margin-top: 6px; }

/* --------------------------------------------------------- section */

.weekly-summary-section {
    border-top: 1px solid #eee;
    padding: 14px 0 4px;
}
.weekly-summary-section-head {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.weekly-summary-section-head h6 {
    margin: 0; font-size: 0.95rem; color: #222; font-weight: 600;
}
.weekly-summary-status { width: 9px; height: 9px; border-radius: 50%; background: #ccc; }
.weekly-summary-status.is-verde  { background: #2e7d32; }
.weekly-summary-status.is-ambra  { background: #e9a13b; }
.weekly-summary-status.is-grigio { background: #bdbdbd; }

.weekly-summary-comment { font-size: 0.9rem; color: #444; margin: 0 0 10px; }
.weekly-summary-missing {
    font-size: 0.85rem; color: #6b6b6b; background: #fafafa;
    border-left: 3px solid #ddd; padding: 8px 10px; margin: 8px 0 0; border-radius: 0 6px 6px 0;
}
.weekly-summary-caveat { font-size: 0.78rem; color: #8a8a8a; margin: 10px 0 0; }

/* ---------------------------------------------------------- energy */

.weekly-summary-recap { font-size: 0.9rem; color: #333; margin: 0 0 10px; }
.weekly-summary-recap em { color: #888; font-size: 0.82rem; font-style: normal; }

.weekly-summary-days { list-style: none; margin: 0; padding: 0; }
.weekly-summary-day {
    /* 58px, not 34: at 34 every weekday was ellipsed to "Lun…"/"Mer…" on a
       phone, so the per-day bars had no readable labels. */
    display: grid; grid-template-columns: 58px 1fr auto;
    align-items: center; gap: 8px; padding: 3px 0;
}
.weekly-summary-day-name {
    font-size: 0.76rem; color: #777; text-transform: capitalize;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.weekly-summary-day-bar { background: #f0f0f0; border-radius: 4px; height: 10px; }
.weekly-summary-day-bar i { display: block; height: 100%; border-radius: 4px; background: #8B0000; }
.weekly-summary-day.is-incomplete .weekly-summary-day-bar i { background: #d8a0a0; }
.weekly-summary-day-value { font-size: 0.8rem; color: #444; min-width: 62px; text-align: right; }

/* ------------------------------------------------------- nutrients */

.weekly-summary-macros {
    list-style: none; margin: 0 0 10px; padding: 0; display: flex; gap: 8px;
}
.weekly-summary-macros li {
    flex: 1; background: #f7f7f7; border-radius: 8px; padding: 8px;
    display: flex; flex-direction: column; align-items: center;
}
.weekly-summary-macros span { font-size: 0.72rem; color: #888; }
.weekly-summary-macros strong { font-size: 0.98rem; color: #333; }

.weekly-summary-nutrients { margin: 10px 0 0; }
.weekly-summary-nutrients h6 { font-size: 0.8rem; color: #666; margin: 0 0 4px; font-weight: 600; }
.weekly-summary-nutrients ul { list-style: none; margin: 0; padding: 0; }
.weekly-summary-nutrients li {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 3px 0; font-size: 0.86rem;
}
.weekly-summary-nutrient { color: #333; }
.weekly-summary-nutrient-days { font-size: 0.76rem; color: #999; }
.weekly-summary-nutrients.is-sotto .weekly-summary-nutrient { border-left: 3px solid #e9a13b; padding-left: 7px; }
.weekly-summary-nutrients.is-sopra .weekly-summary-nutrient { border-left: 3px solid #c76a6a; padding-left: 7px; }
.weekly-summary-within { font-size: 0.82rem; color: #2e7d32; margin: 10px 0 0; }

/* -------------------------------------------------------- activity */

.weekly-summary-tiles {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px;
}
.weekly-summary-tile {
    background: #f7f7f7; border-radius: 8px; padding: 10px;
    display: flex; flex-direction: column; gap: 1px;
}
.weekly-summary-tile-value { font-size: 1.12rem; color: #222; font-weight: 600; }
.weekly-summary-tile-label { font-size: 0.8rem; color: #555; }
.weekly-summary-tile-note { font-size: 0.72rem; color: #999; }

/* ------------------------------------------------- tips and hints */

.weekly-summary-tips ul,
.weekly-summary-hints ul { list-style: none; margin: 0; padding: 0; }
.weekly-summary-tips li {
    padding: 8px 0; border-bottom: 1px dashed #eee;
    display: flex; flex-direction: column; gap: 2px;
}
.weekly-summary-tips li:last-child { border-bottom: none; }
.weekly-summary-tips strong { font-size: 0.88rem; color: #222; }
.weekly-summary-tips span { font-size: 0.86rem; color: #555; }

.weekly-summary-hint {
    background: #f6f4ef; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
}
.weekly-summary-hint strong { font-size: 0.88rem; color: #222; }
.weekly-summary-hint span { font-size: 0.85rem; color: #555; }
.weekly-summary-hint-cta {
    margin-top: 4px; background: #8B0000; color: #fff; border: none;
    border-radius: 6px; padding: 6px 12px; font-size: 0.82rem; cursor: pointer;
}

.weekly-summary-resolved { list-style: none; margin: 12px 0 0; padding: 0; }
.weekly-summary-resolved li {
    font-size: 0.85rem; color: #2e7d32; background: #f1f7f1;
    border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}

/* -------------------------------------------------------- history */

.weekly-summary-history { margin-top: 18px; padding-top: 12px; border-top: 1px solid #eee; }
.weekly-summary-history h6 { font-size: 0.82rem; color: #888; margin: 0 0 6px; font-weight: 600; }
.weekly-summary-history ul { list-style: none; margin: 0; padding: 0; }
.weekly-summary-history button {
    width: 100%; background: none; border: none; text-align: left; cursor: pointer;
    padding: 8px 0; border-bottom: 1px solid #f2f2f2;
    display: flex; flex-direction: column; gap: 1px;
}
.weekly-summary-history button span { font-size: 0.84rem; color: #333; }
.weekly-summary-history button em { font-size: 0.78rem; color: #999; font-style: normal; }

/* --------------------------------------------------------- banner */

.weekly-summary-banner {
    position: fixed;
    /* Centred by insets + auto margins rather than left:50% + translateX: with
       the translate trick the width had to come from 100vw, which counts the
       scrollbar and overflowed the viewport on a phone. */
    left: 12px;
    right: 12px;
    margin: 0 auto;
    width: auto;
    max-width: 520px;
    /* ABOVE the composer, never on top of it. At `bottom: 18px` the banner
       landed inside the chat input bar (119 px tall, two rows on phones) and on
       a phone that whole strip sits under the browser's bottom toolbar — the
       banner was being rendered where nobody could see it, which is why two
       patients went two weeks without ever opening a recap (01/09/2026).
       --ws-banner-lift is measured from the real composer by the notifier; the
       fallback clears a typical one on its own, and env() adds the iOS home
       indicator. */
    bottom: calc(var(--ws-banner-lift, 128px) + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 12px;
    background: #8B0000;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 1090;
}
.weekly-summary-banner.d-none { display: none; }
.weekly-summary-banner-text { font-size: 0.92rem; flex: 1; min-width: 0; }
.weekly-summary-banner-view {
    background: #fff; color: #8B0000; border: none;
    border-radius: 6px; padding: 5px 12px; font-weight: 600; cursor: pointer;
    white-space: nowrap;
}
.weekly-summary-banner-dismiss {
    background: none; border: none; color: #fff;
    font-size: 1.3rem; line-height: 1; cursor: pointer;
}

/* ------------------------------------------------ doctor-side header strip */

.doctor-weekly-summary { margin: 0 0 16px; }
.doctor-weekly-summary.d-none { display: none; }
.doctor-weekly-summary-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: #fff; border: 1px solid #e6e6e6; border-left: 4px solid #8B0000;
    border-radius: 10px; padding: 12px 14px;
}
.doctor-weekly-summary-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.doctor-weekly-summary-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: #999;
}
.doctor-weekly-summary-text strong {
    font-size: 0.95rem; color: #222;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doctor-weekly-summary-meta { font-size: 0.78rem; color: #888; }
