/* =========================================================
   DAILY NUTRITION CALCULATOR V2
   PROGRESS PAGE
   ========================================================= */


/* =========================================================
   PAGE / HEADER
   Matches Calculator / Profile V2 header
   ========================================================= */

.site-header {
    padding: 12px 24px;
    background: #1e2a3a !important;
    border-bottom: 0 !important;
    box-shadow: 0 5px 20px rgba(22, 32, 51, 0.12);
}

.site-header .brand {
    min-height: 72px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Supports the newer V2 header structure */
.site-header .brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

/* New V2 logo */
.site-header .brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 50%;
    flex: 0 0 44px;
    background: #ffffff;
}

/* Supports the existing Progress/Profile brand-mark structure */
.site-header .brand-mark {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: grid;
    place-items: center;

    border-radius: 50%;
    background:
        #ffffff
        url("../assets/favicon.png")
        center / 38px 38px
        no-repeat;

    color: transparent;
    font-size: 0;
}

/* Brand text */
.site-header .brand-copy {
    min-width: 0;
}

.site-header .brand-copy h1 {
    color: #ffffff !important;
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.site-header .brand-copy h1 span {
    color: #f4b740;
}

.site-header .brand-copy p {
    color: rgba(255, 255, 255, 0.68) !important;
    margin: 4px 0 0;
    font-size: 0.72rem;
    line-height: 1.2;
}

/* Navigation */
.site-header .main-nav {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 6px;
}

.site-header .main-nav a {
    padding: 9px 13px;
    border-radius: 999px;

    color: rgba(255, 255, 255, 0.76) !important;
    background: transparent;

    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;

    transition:
        background-color 0.18s ease,
        color 0.18s ease;
}

.site-header .main-nav a:hover,
.site-header .main-nav a.active {
    background: #f4b740 !important;
    color: #1e2a3a !important;
}

/* Theme button */
.site-header .theme-toggle {
    width: auto;
    margin: 0 0 0 8px;
    padding: 9px 13px;

    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 999px !important;

    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;

    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;

    cursor: pointer;
}

.site-header .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
}


/* =========================================================
   PAGE
   ========================================================= */

.progress-main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}


/* =========================================================
   PAGE HEADING
   ========================================================= */

.progress-page-heading {
    margin-bottom: 20px;
}

.progress-page-heading h2 {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.2;
}

.progress-page-heading p {
    margin: 6px 0 0;
    max-width: 720px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}


/* =========================================================
   SECTIONS
   ========================================================= */

.progress-section {
    margin-bottom: 22px;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.section-number {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;

    display: grid;
    place-items: center;

    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;

    font-size: 0.78rem;
    font-weight: 700;
}

.section-heading h2 {
    margin: 1px 0 0;
    font-size: 1.15rem;
    line-height: 1.3;
}

.section-description {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}


/* =========================================================
   TOP BAR
   ========================================================= */

.progress-top-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;

    padding: 12px;
    margin-bottom: 12px;

    border: 1px solid var(--border, #e4e7ec);
    border-radius: 12px;

    background: var(--surface, #ffffff);
}

.date-picker-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.date-picker-field label,
.history-field > label {
    color: var(--text);
    font-size: 0.76rem;
    font-weight: 600;
}

.date-picker-field input,
.history-field input,
.history-field textarea {
    box-sizing: border-box;

    border: 1px solid var(--border, #d9dee7);
    border-radius: 7px;

    background: var(--surface, #ffffff);
    color: var(--text);

    font: inherit;
    outline: none;
}

.date-picker-field input {
    width: 150px;
    height: 36px;
    padding: 0 9px;
    font-size: 0.82rem;
}

.date-picker-field input:focus,
.history-field input:focus,
.history-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(15, 175, 143, 0.1);
}

.progress-counter {
    min-width: 92px;
    padding: 3px 8px;
}

.progress-counter strong {
    display: block;
    font-size: 1rem;
    line-height: 1.2;
}

.progress-counter span,
.progress-selected-date span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.3;
}

.progress-selected-date {
    margin-left: auto;
    min-width: 125px;
    padding-left: 12px;
    border-left: 1px solid var(--border, #e4e7ec);
}

.progress-selected-date strong {
    display: block;
    font-size: 0.86rem;
}


/* =========================================================
   DAILY ENTRY
   ========================================================= */

.daily-progress-layout {
    display: grid;
    grid-template-columns:
        minmax(0, 1.35fr)
        minmax(300px, 0.85fr);

    gap: 12px;
    align-items: stretch;
}

.today-progress-card {
    min-width: 0;
    padding: 16px;

    border: 1px solid var(--border, #e4e7ec);
    border-radius: 12px;

    background: var(--surface, #ffffff);
}

.today-card-heading {
    margin-bottom: 14px;
}

.today-card-heading h3 {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.3;
}

.today-card-heading p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.4;
}


/* =========================================================
   BASIC ENTRY
   ========================================================= */

.basic-entry-grid {
    display: grid;

    grid-template-columns:
        150px
        minmax(110px, 1fr)
        minmax(110px, 1fr);

    gap: 12px;
    align-items: start;
}

.history-field {
    min-width: 0;
}

.history-field > label {
    display: block;
    margin-bottom: 5px;
}

.history-field small {
    display: block;
    margin-top: 4px;

    color: var(--muted);
    font-size: 0.65rem;
    line-height: 1.3;
}


/* =========================================================
   WEIGHT
   ========================================================= */

.weight-input-wrapper {
    position: relative;
    width: 125px;
}

.weight-input-wrapper input {
    box-sizing: border-box;

    width: 125px;
    min-width: 125px;
    height: 34px;

    padding: 0 30px 0 9px;

    font-size: 0.82rem;
}

.weight-unit {
    position: absolute;
    top: 50%;
    right: 9px;

    transform: translateY(-50%);

    color: var(--muted);
    font-size: 0.7rem;

    pointer-events: none;
}


/* =========================================================
   RADIO CHOICES
   ========================================================= */

.history-choice-group {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
}

.history-choice {
    display: inline-flex;
    align-items: center;
    gap: 4px;

    min-height: 30px;
    padding: 0 8px;

    border: 1px solid var(--border, #d9dee7);
    border-radius: 7px;

    cursor: pointer;

    font-size: 0.73rem;
}

.history-choice input {
    width: auto;
    height: auto;
    margin: 0;
}


/* =========================================================
   NUTRITION
   ========================================================= */

.form-subsection {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border, #e4e7ec);
}

.form-subsection-heading {
    margin-bottom: 9px;
}

.form-subsection-heading h4 {
    margin: 0;
    font-size: 0.8rem;
}

.form-subsection-heading p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.68rem;
}

.nutrition-input-grid {
    display: grid;

    grid-template-columns:
        repeat(3, 105px)
        minmax(130px, 1fr)
        120px;

    gap: 10px;
    align-items: start;
}

.nutrition-number-field,
.extra-item-calories-field {
    min-width: 0;
}

.nutrition-input-wrapper {
    position: relative;
    width: 100px;
}

.nutrition-input-wrapper input {
    width: 100%;
    height: 34px;

    padding: 0 34px 0 8px;

    font-size: 0.8rem;
}

.nutrition-input-wrapper span {
    position: absolute;
    top: 50%;
    right: 7px;

    transform: translateY(-50%);

    color: var(--muted);
    font-size: 0.64rem;

    pointer-events: none;
}

.extra-item-name-field input {
    width: 100%;
    height: 34px;

    padding: 0 8px;

    font-size: 0.8rem;
}

.extra-item-calories-field .nutrition-input-wrapper {
    width: 105px;
}


/* =========================================================
   NOTES
   ========================================================= */

.history-notes {
    margin-top: 12px;
}

.history-notes textarea {
    display: block;

    width: 100%;
    min-height: 58px;

    resize: vertical;

    padding: 8px 9px;

    font-size: 0.78rem;
    line-height: 1.4;
}


/* =========================================================
   ACTIONS
   ========================================================= */

.entry-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 11px;
}

.history-save-button,
.secondary-button {
    min-height: 34px;
    padding: 0 13px;

    border-radius: 7px;

    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;

    cursor: pointer;
}

.history-save-button {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.secondary-button {
    border: 1px solid var(--border, #d9dee7);
    background: var(--surface, #ffffff);
    color: var(--text);
}

.secondary-button:hover {
    background: var(--mint);
    color: var(--primary-dark);
}

.save-message {
    min-height: 15px;
    margin: 7px 0 0;
    font-size: 0.7rem;
}

.save-message.success {
    color: var(--success);
}

.save-message.error {
    color: var(--error);
}


/* =========================================================
   SELECTED DAY
   ========================================================= */

.selected-day-card {
    display: flex;
    flex-direction: column;
}

.today-summary-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 8px;
}

.today-summary-item {
    min-width: 0;

    padding: 10px;

    border: 1px solid var(--border, #e4e7ec);
    border-radius: 9px;

    background: var(--bg, #f6f8fb);
}

.today-summary-item span {
    display: block;

    color: var(--muted);
    font-size: 0.66rem;
    line-height: 1.2;
}

.today-summary-item strong {
    display: block;

    margin-top: 3px;

    font-size: 0.95rem;
    line-height: 1.2;
}

.today-summary-item small {
    display: block;

    margin-top: 3px;

    color: var(--muted);
    font-size: 0.62rem;
    line-height: 1.25;
}


/* =========================================================
   TRENDS
   ========================================================= */

.progress-trends-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 12px;
}

.progress-trend-card {
    min-width: 0;

    padding: 13px;

    border: 1px solid var(--border, #e4e7ec);
    border-radius: 12px;

    background: var(--surface, #ffffff);
}

.progress-trend-card.trend-wide {
    grid-column: span 2;
}

.progress-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 10px;
    margin-bottom: 7px;
}

.progress-card-heading h3 {
    margin: 0;

    font-size: 0.86rem;
    line-height: 1.25;
}

.progress-card-heading p {
    margin: 2px 0 0;

    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.3;
}

.small-control {
    flex: 0 0 auto;

    padding: 3px 7px;

    border: 1px solid var(--border, #d9dee7);
    border-radius: 6px;

    color: var(--muted);
    font-size: 0.62rem;
}


/* =========================================================
   CHARTS
   ========================================================= */

.chart-container {
    position: relative;

    width: 100%;
    height: 175px;
}

.chart-container-large {
    height: 205px;
}

.chart-container canvas {
    display: block;

    width: 100% !important;
    height: 100% !important;
}

.chart-empty-state {
    position: absolute;
    inset: 0;

    display: grid;
    place-items: center;

    padding: 20px;

    color: var(--muted);

    text-align: center;
    font-size: 0.72rem;
}


/* =========================================================
   CHART COLORS
   Used by progress.js / Chart.js
   ========================================================= */

:root {
    --chart-weight: #f4b740;
    --chart-bmi: #4f8cff;
    --chart-bmr: #9b6cff;
    --chart-calories: #00a98f;

    --chart-protein: #4f8cff;
    --chart-carbs: #35b56a;
    --chart-fat: #f08a3c;

    --chart-diet: #35b56a;
    --chart-workout: #9b6cff;

    --chart-grid: rgba(100, 116, 139, 0.16);
    --chart-label: #667085;
}

html[data-theme="dark"] {
    --chart-weight: #ffd166;
    --chart-bmi: #72a7ff;
    --chart-bmr: #b58aff;
    --chart-calories: #29d3b5;

    --chart-protein: #72a7ff;
    --chart-carbs: #55d982;
    --chart-fat: #ffab6b;

    --chart-diet: #55d982;
    --chart-workout: #b58aff;

    --chart-grid: rgba(255, 255, 255, 0.12);
    --chart-label: #aab4c3;
}


/* =========================================================
   HISTORY
   ========================================================= */

.custom-history-card {
    display: grid;

    grid-template-columns:
        minmax(200px, 1fr)
        auto;

    gap: 12px 20px;
    align-items: end;

    padding: 14px;

    border: 1px solid var(--border, #e4e7ec);
    border-radius: 12px;

    background: var(--surface, #ffffff);
}

.custom-history-info h3 {
    margin: 0;
    font-size: 0.9rem;
}

.custom-history-info p {
    margin: 3px 0 0;

    color: var(--muted);
    font-size: 0.72rem;
}

.custom-history-controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.history-result {
    grid-column: 1 / -1;

    min-height: 34px;

    padding: 8px 10px;

    border-radius: 7px;

    background: var(--bg, #f6f8fb);
    color: var(--muted);

    font-size: 0.72rem;
}


/* =========================================================
   FOOTER
   ========================================================= */

footer {
    padding: 22px 16px;
    text-align: center;
}

footer p {
    margin: 0;

    color: var(--muted);
    font-size: 0.7rem;
}


/* =========================================================
   DARK MODE — PROGRESS CONTENT
   ========================================================= */

html[data-theme="dark"] .progress-top-bar,
html[data-theme="dark"] .today-progress-card,
html[data-theme="dark"] .progress-trend-card,
html[data-theme="dark"] .custom-history-card {
    border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .today-summary-item,
html[data-theme="dark"] .history-result {
    background: rgba(255, 255, 255, 0.035);
}

html[data-theme="dark"] .date-picker-field input,
html[data-theme="dark"] .history-field input,
html[data-theme="dark"] .history-field textarea {
    background: var(--surface);
    color: var(--text);

    border-color: rgba(255, 255, 255, 0.12);
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {

    .progress-main {
        width: min(100% - 24px, 760px);
        padding-top: 22px;
    }

    .daily-progress-layout {
        grid-template-columns: 1fr;
    }

    .nutrition-input-grid {
        grid-template-columns:
            repeat(3, 105px)
            minmax(150px, 1fr);
    }

    .extra-item-calories-field {
        grid-column: 4;
    }

    .progress-top-bar {
        flex-wrap: wrap;
        align-items: center;
    }

    .progress-selected-date {
        margin-left: 0;
    }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .site-header {
        padding: 12px 14px;
    }

    .site-header .brand {
        min-height: 0;
        flex-wrap: wrap;
    }

    .site-header .brand-copy {
        flex: 1 1 auto;
    }

    .site-header .main-nav {
        order: 3;

        width: 100%;
        margin-left: 0;

        justify-content: center;

        padding-top: 7px;

        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .site-header .theme-toggle {
        margin-left: auto;
    }

    .progress-main {
        width: calc(100% - 18px);
        padding-top: 18px;
        padding-bottom: 30px;
    }

    .progress-page-heading {
        margin-bottom: 16px;
    }

    .progress-page-heading h2 {
        font-size: 1.45rem;
    }

    .section-heading {
        margin-bottom: 9px;
    }

    .section-heading h2 {
        font-size: 1rem;
    }

    .progress-top-bar {
        display: grid;

        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 9px;
    }

    .date-picker-field input {
        width: 100%;
    }

    .progress-selected-date {
        grid-column: 1 / -1;

        padding: 8px 0 0;

        border-left: 0;
        border-top: 1px solid var(--border, #e4e7ec);
    }

    .basic-entry-grid {
        grid-template-columns: 1fr 1fr;
    }

    .weight-field {
        grid-column: 1 / -1;
    }

    .nutrition-input-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .nutrition-input-wrapper {
        width: 105px;
    }

    .extra-item-name-field {
        grid-column: 1 / -1;
    }

    .extra-item-name-field input {
        max-width: 260px;
    }

    .extra-item-calories-field {
        grid-column: auto;
    }

    .progress-trends-grid {
        grid-template-columns: 1fr;
    }

    .progress-trend-card.trend-wide {
        grid-column: auto;
    }

    .chart-container {
        height: 165px;
    }

    .chart-container-large {
        height: 185px;
    }

    .custom-history-card {
        grid-template-columns: 1fr;
    }

    .custom-history-controls {
        flex-wrap: wrap;
    }

    .custom-history-controls .date-picker-field {
        flex: 1 1 130px;
    }
}


/* =========================================================
   VERY SMALL SCREENS
   ========================================================= */

@media (max-width: 400px) {

    .site-header .brand-logo,
    .site-header .brand-mark {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .site-header .brand-mark {
        background-size: 33px 33px;
    }

    .site-header .brand-copy h1 {
        font-size: 0.95rem;
    }

    .site-header .brand-copy p {
        font-size: 0.65rem;
    }

    .site-header .main-nav {
        gap: 2px;
        overflow-x: auto;
        justify-content: flex-start;
    }

    .site-header .main-nav a {
        padding: 7px 9px;
        font-size: 10px;
    }

    .site-header .theme-toggle {
        padding: 7px 9px;
        font-size: 10px;
    }

    .basic-entry-grid {
        grid-template-columns: 1fr;
    }

    .weight-field {
        grid-column: auto;
    }

    .history-choice-group {
        width: max-content;
    }

    .nutrition-input-grid {
        grid-template-columns: 1fr 1fr;
    }

    .entry-actions {
        flex-wrap: wrap;
    }

    .today-summary-grid {
        grid-template-columns: 1fr 1fr;
    }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}