﻿.calendar-wrap {
    width: 100%;
    margin-top: 18px;
}

.calendar-wrap .calendar {
    padding: 14px;
}

:root {
    --bg: #0b0b0d;
    --card: #0f1720;
    --muted: #9aa4b2;
    --accent: #ff4d4f;
    --glass: rgba(255, 255, 255, 0.03);
    --white: #ffffff;
    --font-sans: 'Segoe UI', Roboto, system-ui, -apple-system, 'Helvetica Neue', Arial;
    /* responsive sizing for bars */
    --bar-width: clamp(60px, 16vw, 110px);
    --bar-gap: clamp(6px, 2.5vw, 16px);
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%;
    background: var(--bg, #071018);
    background-color: var(--bg, #071018);
    color-scheme: dark;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100%;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #071018 0%, #0b0b0d 100%);
    color: var(--white);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px
}

/* ensure main area can grow to fill viewport so side-columns can match height */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main {
    flex: 1 1 auto;
}

.header {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.header h1 {
    font-size: 46px;
    margin: 0;
    letter-spacing: -1px;
    text-align: center;
    ;
}

.header .subtitle {
    margin: 0;
    color: var(--muted)
}

.main {
    display: flex;
    gap: 24px;
    /* stretch columns so left and controls match height */
    align-items: stretch;
    margin-top: 18px;
}

.main .left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    /* allow children to shrink/overflow properly */
}

.main .controls {
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    /* enable child (weekly) to flex */
}

.bars {
    display: flex;
    gap: var(--bar-gap);
    flex: 1;
    align-items: end;
    justify-content: center;
    padding-bottom: 48px;
}

.bar {
    width: var(--bar-width);
    height: 420px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45)
}

.bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px
}

.bar-wrap .label {
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 0.5px;
    pointer-events: auto;
    color: var(--white);
}

/* soft filled area under weekly lines */
.week-chart .chart-fill {
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

.bar .max {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    color: var(--muted);
    font-size: 13px;
    z-index: 1
}

.bar .min {
    display: none
}

.bar .value {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 10px;
    font-weight: 900;
    color: var(--white);
    background: rgba(0, 0, 0, 0.28);
    pointer-events: none;
    font-size: 16px;
    z-index: 3
}

.fill {
    position: relative;
    z-index: 2;
    height: 0%;
    width: 100%;
    border-radius: 8px 8px 0 0;
    transition: height 250ms cubic-bezier(.2, .9, .2, 1)
}

.tooltip {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--card);
    border-radius: 6px;
    font-weight: 700;
    color: var(--white);
    pointer-events: none;
    white-space: nowrap
}

.controls {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    background: linear-gradient(90deg, var(--accent), #ff8a00);
    color: #111;
    border: none;
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer
}

.records {
    background: var(--card);
    padding: 12px;
    border-radius: 10px;
    min-height: 80px
}

.history {
    background: var(--card);
    padding: 10px;
    border-radius: 10px;
    overflow: auto;
}

.history .entry {
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 8px;
}

.history .date {
    opacity: 0.8;
    font-weight: 700
}

.import-status {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px
}

.footer {
    opacity: 0.6;
    margin-top: 18px;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
    font-style: italic;
}

/* distinct colors per exercise */
.bar.pushups .fill {
    background: linear-gradient(180deg, #ff4d4f, #ff7582)
}

.bar.crunches .fill {
    background: linear-gradient(180deg, #6bde67, #3ad56e)
}

.bar.squats .fill {
    background: linear-gradient(180deg, #6fd6ff, #3aa9ff)
}

.bar.steps .fill {
    background: linear-gradient(180deg, #ffd36b, #ffb74d)
}

/* hover guide line */
.guide {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none
}

@media (max-width:900px) {
    .bar {
        width: 76px;
        height: 340px
    }

    .header h1 {
        font-size: 34px
    }
}

@media (max-width:600px) {
    .main {
        flex-direction: column
    }

    .controls {
        width: 100%
    }

    /* mobile stacking order: bars, calendar, controls */
    .main .left {
        order: 0
    }

    .calendar-wrap {
        order: 1
    }

    .controls {
        order: 2
    }

    /* keep bars in one row (no wrap) and allow horizontal scroll on very small screens */
    .bars {
        gap: 12px;
        justify-content: center;
        flex-wrap: nowrap;
        padding-bottom: 24px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch
    }

    .bar {
        width: 72px;
        height: 260px;
        padding: 10px;
        margin: 0 6px;
    }

    .bar-wrap {
        margin: 0px
    }

    .bar .value {
        font-size: 13px;
        padding: 6px 8px
    }

    /* scale down calendar rings on small screens */
    .cal-day .rings svg {
        width: 48px;
        height: 48px
    }

    .cal-day {
        min-height: 56px
    }

    /* center the main content column on small screens */
    .main {
        align-items: center;
    }

    /* constrain and center left column, controls and calendar for nicer mobile layout */
    .main .left,
    .controls,
    .calendar-wrap {
        width: 100%;
        max-width: 420px;
        margin-left: auto;
        margin-right: auto;
    }

    /* on mobile, weekly view should not flex; it should appear below controls in normal document flow */
    .controls .weekly,
    .weekly {
        flex: none;
        overflow: visible;
        max-height: none;
    }

    /* reduce app side padding on very small screens */
    .app {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* Calendar view */
.calendar {
    background: var(--card);
    padding: 10px;
    border-radius: 10px;
    color: var(--white);
}

.calendar-wrap {
    margin-top: 16px
}

.calendar-wrap .calendar {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.calendar .cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px
}

.calendar .month-title {
    font-weight: 900
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    /* enforce equal row height so all days are same size */
    grid-auto-rows: 100px;
}

.weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 6px
}

.weekday-row .wk {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    font-weight: 700
}

/* month controls in calendar header */
.month-controls {
    display: flex;
    gap: 8px;
    align-items: center
}

.btn.small {
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 8px
}

/* Calendar-specific button style: subtle grey buttons that fit the calendar card */
.calendar .month-controls .btn.small {
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.03);
    box-shadow: none;
    font-weight: 700;
}

.calendar .month-controls .btn.small:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--white);
}

/* fade-in for month content changes */
.cal-body.animate {
    animation: fadeIn 260ms ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cal-day {
    background: rgba(255, 255, 255, 0.04);
    padding: 8px;
    border-radius: 6px;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.cal-day .date-num {
    position: absolute;
    top: 6px;
    right: 8px;
    font-weight: 700;
    color: var(--muted);
    font-size: 12px
}

.cal-day.empty {
    opacity: 0.25
}

/* weekend subtle background tint */
.cal-day.weekend,
.cal-day.sat,
.cal-day.sun {
    /* subtle, slightly darker grey for weekends */
    background: rgb(255, 255, 255, 0.01);
    border-left: none;
}

.day-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    margin-top: 20px;
    padding: 0 4px
}

.day-bar {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    overflow: hidden;
    position: relative
}

.day-bar .fill {
    height: 100%;
    width: 0%;
    border-radius: 6px;
    transition: width 300ms cubic-bezier(.2, .9, .2, 1)
}

.day-bar.pushups .fill {
    background: linear-gradient(90deg, #ff4d4f, #ff7582)
}

.day-bar.crunches .fill {
    background: linear-gradient(90deg, #6bde67, #3ad56e)
}

.day-bar.squats .fill {
    background: linear-gradient(90deg, #6fd6ff, #3aa9ff)
}

.day-bar.steps .fill {
    background: linear-gradient(90deg, #ffd36b, #ffb74d)
}

.cal-day.has-data {
    /* shadow intentionally removed to keep calendar flat */
    box-shadow: none;
}

/* 1. Base style for today (Grey/Subtle) */
.cal-day.today {
    /* keep layout similar but remove strong background so it won't conflict with selected styling */
    transform: translateY(-2px);
    outline: 3px solid rgba(175, 175, 175, 0.18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 122, 84, 0.03);
    background: linear-gradient(180deg, rgba(255, 122, 84, 0.04), rgba(255, 122, 84, 0.02));
}


/* 2. Style for editing (Orange) OR when Today is being edited */
.cal-day.editing,
.cal-day.today.editing {
    transform: translateY(-2px);
    outline: 3px solid rgba(255, 122, 84, 0.18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 122, 84, 0.03);
    background: linear-gradient(180deg, rgba(255, 122, 84, 0.04), rgba(255, 122, 84, 0.02));
}

/* Modal / popup for day details */
.modal {
    position: fixed;
    inset: 0;
    /* top:0; right:0; bottom:0; left:0 */
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 2000;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-content {
    background: var(--card);
    color: var(--white);
    border-radius: 12px;
    padding: 18px;
    width: min(520px, calc(100% - 40px));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.modal-content h2 {
    margin: 0 0 8px 0;
    font-size: 20px;
}

.modal-content .day-values {
    display: none;
    /* kept for backward compatibility, use .day-row below */
}

.modal-content .day-row {
    display: grid;
    grid-template-columns: 1fr 1fr 64px;
    gap: 8px 12px;
    align-items: center;
    margin-top: 12px;
}

.modal-content .label {
    font-weight: 700;
}

.modal-content .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.modal-content .modal-bar {
    height: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
}

.modal-content .modal-bar .fill {
    height: 100%;
    width: 0%;
    border-radius: 8px;
    transition: width 300ms cubic-bezier(.2, .9, .2, 1);
}

/* Reuse day-row/modal-bar styles in the records panel (more compact) */
.records .day-row {
    display: grid;
    grid-template-columns: 1fr 1fr 56px;
    gap: 6px 10px;
    align-items: center;
    margin-top: 10px;
}

.records .label {
    font-weight: 700;
}

.records .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.records .modal-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
}

.records .modal-bar .fill {
    height: 100%;
    width: 0%;
    border-radius: 8px;
    transition: width 300ms cubic-bezier(.2, .9, .2, 1);
}

/* ensure color fills apply outside modal-content too */
.records .modal-bar.pushups .fill,
.modal-bar.pushups .fill {
    background: linear-gradient(90deg, #ff4d4f, #ff7582);
}

.records .modal-bar.crunches .fill,
.modal-bar.crunches .fill {
    background: linear-gradient(90deg, #6bde67, #3ad56e);
}

.records .modal-bar.squats .fill,
.modal-bar.squats .fill {
    background: linear-gradient(90deg, #6fd6ff, #3aa9ff);
}

.records .modal-bar.steps .fill,
.modal-bar.steps .fill {
    background: linear-gradient(90deg, #ffd36b, #ffb74d);
}

/* history entry compact rows */
.history .history-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

/* Weekly view styles */
.weekly {
    background: var(--card);
    padding: 10px;
    border-radius: 10px;
    flex: 1 1 auto;
}

/* Ensure weekly panel expands to fill controls column and scrolls if needed */
.controls .weekly,
.weekly {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.weekly .week-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.weekly .week-range {
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
}

.weekly .week-title {
    font-weight: 900
}

.weekly .week-controls .btn.small {
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 8px
}

.weekly .exercise-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.weekly .ex-label {
    font-weight: 700;
    margin-bottom: 6px
}

.weekly .ex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* gap: 8px; */
}

.weekly .ex-total {
    font-weight: 800;
    color: var(--muted);
    font-size: 13px;
}

.weekly .ex-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* gap: 8px; */
    /* padding-top: 6px; */
}

.weekly .ex-footer .ex-label {
    margin: 0;
}

.weekly svg.week-chart {
    width: 100%;
    height: 160;
    overflow: visible;
}

.weekly .chart-point {
    cursor: pointer
}

.weekly .chart-legend {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px
}

.weekly .legend-item {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 13px
}

.weekly .legend-swatch {
    width: 14px;
    height: 8px;
    border-radius: 3px
}

.history .history-row {
    display: grid;
    grid-template-columns: 1fr 1fr 48px;
    gap: 6px 8px;
    align-items: center;
}

.history .history-row .label {
    font-weight: 700;
    font-size: 13px;
}

.history .history-row .day-bar {
    height: 8px;
    border-radius: 6px;
}

.history .history-row .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

/* color fills for modal bars (reuse palette) */
.modal-bar.pushups .fill {
    background: linear-gradient(90deg, #ff4d4f, #ff7582);
}

.modal-bar.crunches .fill {
    background: linear-gradient(90deg, #6bde67, #3ad56e);
}

.modal-bar.squats .fill {
    background: linear-gradient(90deg, #6fd6ff, #3aa9ff);
}

.modal-bar.steps .fill {
    background: linear-gradient(90deg, #ffd36b, #ffb74d);
}

.modal-content .day-values .label {
    font-weight: 700;
}

.modal-content .day-values .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* chart guide lines and labels for weekly view */
.week-chart .chart-max,
.week-chart .chart-min {
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 1.6;
}

.week-chart .chart-max {
    stroke-dasharray: none;
    stroke: rgba(255, 255, 255, 0.22);
}

.week-chart .chart-min {
    stroke-dasharray: 6 4;
    stroke: rgba(255, 255, 255, 0.14);
}

.week-chart .scale-label {
    font-size: 12px;
    fill: rgba(255, 255, 255, 0.9);
    font-weight: 800;
}

.modal .btn {
    margin-top: 14px;
}