/* ============================================================================
   PROGRESS ANALYTICS — member-facing progress/charts page
   Theme: navy #0a1628 / #0f1a2e / #16223c + gold #c8a03c + white. No emoji.
   Lightweight inline-SVG charts (line + bar) styled here. Self-contained.
   ============================================================================ */

.progress-page {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 2rem 2.25rem 4rem;
    color: #fff;
    border: none;
    box-sizing: border-box;
}

.progress-page .page-header { margin-bottom: 2rem; }
.progress-page .page-header h1 {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    margin: 0 0 0.45rem;
    color: #fff;
}
.progress-page .page-subtitle {
    margin: 0;
    color: rgba(255,255,255,0.6);
    font-size: 0.98rem;
    line-height: 1.5;
}

/* Period selector */
.pg-period {
    display: flex;
    gap: 0.5rem;
    margin: 0 0 2rem;
}
.pg-period-btn {
    flex: 1 1 0;
    text-align: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.09);
    color: rgba(255,255,255,0.7);
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.55rem 0.4rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.pg-period-btn:hover { color: #fff; border-color: rgba(200,160,60,0.5); }
.pg-period-btn.active {
    background: #c8a03c;
    border-color: #c8a03c;
    color: #0a1628;
}

/* Summary stat cards */
.pg-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2.25rem;
}
@media (max-width: 760px) { .pg-stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; } }
/* Keep the four stat cards 2-up even on narrow phones (was 1-per-row, which turned the
   page into a long, sparse single column). */
@media (max-width: 420px) { .pg-stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; } }
.pg-period-empty { padding: 0.9rem 1.1rem; margin: 0 0 2rem; background: rgba(200,160,60,0.08); border: 1px solid rgba(200,160,60,0.25); border-radius: 12px; color: rgba(255,255,255,0.72); font-size: 0.9rem; line-height: 1.5; }
.pg-stat-card {
    background: #16223c;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 16px;
    padding: 1.4rem 1.4rem 1.5rem;
}
.pg-stat-val {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1.05;
    color: #c8a03c;
}
.pg-stat-val .pg-unit {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    margin-left: 0.15rem;
}
.pg-stat-lbl {
    margin-top: 0.65rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.55);
}
.pg-stat-delta { font-size: 0.76rem; font-weight: 700; margin-top: 0.5rem; }
.pg-delta-up   { color: #4ade80; }
.pg-delta-down { color: #f87171; }
.pg-delta-flat { color: rgba(255,255,255,0.45); }

/* Chart cards */
.pg-charts {
    display: grid;
    grid-template-columns: 1fr;   /* full-width cards → each infographic is large + readable */
    gap: 1.25rem;
}
@media (min-width: 1000px) {
    /* Roomy desktop: two columns so the charts aren't over-stretched. */
    .pg-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Tighter padding + gaps on mobile so the side-by-side cards don't feel cramped. */
@media (max-width: 768px) {
    .pg-charts { gap: 0.75rem; }
    .pg-card { padding: 1rem 1rem 1.15rem; }
    .pg-stat-card { padding: 1.05rem 1.05rem 1.15rem; }
    .pg-stat-val { font-size: 1.85rem; }
    /* Stack the card title above its sub-label so neither wraps awkwardly in the
       narrower side-by-side cards. */
    .pg-card-head { margin-bottom: 0.7rem; flex-direction: column; align-items: flex-start; gap: 0.1rem; }
    .pg-card-title { font-size: 1rem; }
    .pg-card-sub { font-size: 0.72rem; }
}
.pg-card {
    background: #0f1a2e;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 18px;
    padding: 1.5rem 1.6rem 1.65rem;
}
.pg-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}
.pg-card-title {
    font-size: 1.12rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}
/* Strength records card: lift chips, e1RM chart, best-lift table. */
.pg-records-card { margin-top: 1.5rem; }
.pg-rec-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.pg-rec-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.7rem; border-radius: 999px;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8); font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.pg-rec-chip span { color: #c8a03c; font-weight: 700; }
.pg-rec-chip.active { background: rgba(200,160,60,0.15); border-color: rgba(200,160,60,0.55); color: #fff; }
.pg-rec-chart { margin-bottom: 1rem; }
.pg-rec-tablewrap { overflow-x: auto; }
.pg-rec-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.pg-rec-table th { text-align: left; color: rgba(255,255,255,0.5); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.4rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.pg-rec-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.05); color: rgba(255,255,255,0.85); }
.pg-rec-table td strong { color: #c8a03c; }
.pg-card-sub {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.55);
}

/* SVG chart canvas */
.pg-chart-svg {
    width: 100%;
    height: auto;
    min-height: 290px;
    display: block;
    overflow: visible;
}
/* Clickable chart cards → tap to expand. */
.pg-card-clickable { cursor: pointer; transition: border-color 0.15s ease, transform 0.08s ease; }
.pg-card-clickable:hover { border-color: rgba(200,160,60,0.4); }
.pg-card-clickable:active { transform: scale(0.992); }
.pg-card-chev { color: #c8a03c; font-size: 1.15rem; font-weight: 700; margin-left: 0.3rem; vertical-align: -1px; }

/* Detail modal (tap-to-expand) */
.pg-detail-content { max-width: 680px; width: 96vw; max-height: 90vh; display: flex; flex-direction: column; }
.pg-detail-content .modal-body { overflow-y: auto; }
.pg-detail-content .pg-chart-svg { min-height: 320px; }
.pg-detail-close { width: 36px; height: 36px; background: transparent; border: none; color: #c8a03c; font-size: 1.7rem; line-height: 1; font-weight: 400; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.pg-detail-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1.25rem;
}
.pg-detail-stat {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 0.9rem 1rem;
}
.pg-detail-stat-val { font-size: 1.5rem; font-weight: 800; color: #fff; line-height: 1.1; }
.pg-detail-stat-lbl { font-size: 0.75rem; color: rgba(255,255,255,0.5); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; }
.pg-grid-line { stroke: rgba(255,255,255,0.06); stroke-width: 1; }
.pg-axis-label {
    fill: rgba(255,255,255,0.42);
    font-size: 9px;
    font-family: inherit;
}

/* Line chart (weight) */
.pg-line {
    fill: none;
    stroke: #c8a03c;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.pg-line-area { fill: url(#pgGoldFade); }
.pg-dot { fill: #c8a03c; stroke: #0f1a2e; stroke-width: 1.5; }

/* Bar chart (volume / sessions) */
.pg-bar { fill: #c8a03c; transition: opacity 0.15s ease; }
.pg-bar.alt { fill: #6b7fa3; }
.pg-bar:hover { opacity: 0.82; }
.pg-bar-label {
    fill: rgba(255,255,255,0.4);
    font-size: 8.5px;
    text-anchor: middle;
}

/* Legend */
.pg-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.pg-legend-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.65);
}
.pg-legend-swatch { width: 11px; height: 11px; border-radius: 3px; }

/* Empty state inside a card */
.pg-empty {
    text-align: center;
    padding: 3rem 1.25rem;
    color: rgba(255,255,255,0.45);
    font-size: 0.9rem;
    line-height: 1.5;
}
.pg-empty strong { display: block; color: rgba(255,255,255,0.72); margin-bottom: 0.4rem; font-size: 1rem; }

/* Dashboard entry-point KPI (clickable) */
.db-kpi-link {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    border-left: 1px solid rgba(255,255,255,0.08);
    transition: background 0.15s ease;
}
.db-kpi-link:hover { background: rgba(200,160,60,0.1); }
.db-kpi-link strong { color: #c8a03c !important; }

/* Adherence ring */
.pg-adherence-row {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
}
.pg-adherence-ring { flex: 0 0 auto; }
.pg-adherence-meta { flex: 1; min-width: 200px; }
.pg-adherence-pct {
    font-size: 2.4rem;
    font-weight: 800;
    color: #c8a03c;
    line-height: 1;
}
.pg-adherence-desc {
    margin-top: 0.6rem;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.65);
    line-height: 1.55;
    max-width: 620px;
}

/* Steps per week */
.pg-step-bar { fill: #5aa9e6; transition: opacity 0.15s ease; }
.pg-step-bar.pg-step-hit { fill: #2ea043; }   /* week's daily average met the goal */
.pg-step-bar:hover { opacity: 0.82; }
.pg-goal-line { stroke: #c8a03c; stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0.8; }
.pg-steps-goal { margin-top: 0.75rem; font-size: 0.82rem; color: rgba(255,255,255,0.55); }
.pg-steps-goal strong { color: #c8a03c; }

/* Nutrition adherence */
.pg-nut-block + .pg-nut-block { margin-top: 1.1rem; }
.pg-nut-label {
    display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
    font-size: 0.92rem; font-weight: 700; color: #fff; margin-bottom: 0.4rem;
}
.pg-nut-label span { font-size: 0.78rem; font-weight: 500; color: rgba(255,255,255,0.5); }
.pg-nut-bar { height: 9px; background: rgba(255,255,255,0.08); border-radius: 5px; overflow: hidden; }
.pg-nut-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #c8a03c, #e8b84b); transition: width 0.4s ease; }
.pg-nut-fill-protein { background: linear-gradient(90deg, #4f7bd6, #6b9ae6); }
.pg-nut-days { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.pg-nut-chip {
    font-size: 0.74rem; color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px; padding: 0.2rem 0.6rem;
}
.pg-nut-chip strong { color: #fff; }
.pg-nut-chip.pg-nut-on { border-color: rgba(46,160,67,0.45); }
.pg-nut-chip.pg-nut-on strong { color: #3fcf67; }
.pg-nut-chip.pg-nut-over { border-color: rgba(224,90,90,0.4); }
.pg-nut-chip.pg-nut-over strong { color: #ef6b6b; }
.pg-nut-chip.pg-nut-under { border-color: rgba(90,169,230,0.35); }
.pg-nut-chip.pg-nut-under strong { color: #5aa9e6; }
.pg-nut-foot { margin-top: 0.6rem; font-size: 0.82rem; color: rgba(255,255,255,0.55); }
.pg-nut-foot strong { color: #c8a03c; }

@media (max-width: 600px) {
    .progress-page { padding: 1.25rem 1.1rem 3rem; }
    .progress-page .page-header h1 { font-size: 1.5rem; }
    .pg-stat-val { font-size: 1.7rem; }
    .pg-card { padding: 1.25rem 1.25rem 1.4rem; }
    .pg-chart-svg { min-height: 220px; }
}

/* Drill-down daily/log breakdown lists (steps daily, weigh-in log). */
.pg-detail-subhead { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.5); font-weight: 700; margin: 1.4rem 0 0.6rem; }
.pg-daylist { display: flex; flex-direction: column; gap: 1px; }
.pg-dayrow { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.15rem; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.82rem; }
.pg-dayrow-date { flex: 0 0 96px; color: rgba(255,255,255,0.6); }
.pg-dayrow-bar { flex: 1; height: 6px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.pg-dayrow-fill { display: block; height: 100%; background: rgba(255,255,255,0.3); border-radius: 3px; }
.pg-dayrow-fill-hit { background: #c8a03c; }
.pg-dayrow-val { flex: 0 0 auto; min-width: 70px; text-align: right; font-weight: 600; color: #fff; }
.pg-dayrow-delta { font-size: 0.72rem; font-weight: 600; margin-left: 0.3rem; }
.pg-dayrow-delta.up { color: #e8794b; }
.pg-dayrow-delta.down { color: #2ea043; }

/* Mobile: open the drill-down as a full-screen PAGE (not a cramped floating modal),
   so the chart + stats + daily breakdown/log have room. Android back closes it. */
@media (max-width: 768px) {
    .pg-detail-overlay { align-items: stretch; justify-content: stretch; padding: 0; }
    .pg-detail-content {
        width: 100vw; max-width: none; height: 100dvh; max-height: none;
        border-radius: 0; border: none;
    }
    .pg-detail-content .modal-header {
        padding-top: calc(0.6rem + env(safe-area-inset-top, 24px));
        position: sticky; top: 0; background: #0f1a2e; z-index: 2; border-bottom: 1px solid rgba(255,255,255,0.07);
    }
    .pg-detail-content .modal-body { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
}
