/* ========================================
   HR Zone Tracker — Project Spark Theme
   Dark modern dashboard design
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: hsl(220, 20%, 7%);
    --bg-card: hsl(220, 18%, 11%);
    --bg-input: hsl(220, 20%, 7%);
    --bg-muted: hsl(220, 14%, 15%);
    --fg: hsl(0, 0%, 95%);
    --fg-muted: hsl(220, 10%, 55%);
    --border: hsl(220, 14%, 20%);
    --primary: hsl(4, 90%, 58%);
    --primary-hover: hsl(4, 85%, 50%);
    --accent: hsl(45, 100%, 51%);
    --success: hsl(142, 71%, 45%);
    --danger: hsl(0, 84%, 60%);
    --warning: hsl(38, 92%, 50%);
    --info: hsl(210, 80%, 55%);
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
}

a { color: var(--primary); }
a:hover { opacity: 0.85; }

/* --- Navbar --- */

.navbar {
    background: hsl(220, 20%, 5%);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    color: #fff;
    text-decoration: none;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.nav-links a {
    color: var(--fg-muted);
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #fff;
}

.btn-logout {
    color: var(--danger) !important;
}

/* --- Hamburger Menu --- */

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    gap: 5px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--fg);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

@media (max-width: 600px) {
    .hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: hsl(220, 20%, 5%);
        border-bottom: 1px solid var(--border);
        padding: 0.75rem 1.5rem;
        flex-direction: column;
        gap: 0;
    }

    .nav-links.nav-open {
        display: flex;
    }

    .nav-links a {
        margin-left: 0;
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--border);
        font-size: 0.9rem;
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    .navbar {
        position: relative;
    }
}

/* --- Container --- */

.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* --- Headings --- */

h1, h2, h3 {
    font-family: 'Oswald', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

h1 {
    margin-bottom: 1.5rem;
    font-size: 2rem;
    font-weight: 600;
}

h2 {
    margin: 1.5rem 0 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* --- Alerts --- */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid;
}

.alert-success {
    background: hsla(142, 71%, 45%, 0.1);
    border-color: hsla(142, 71%, 45%, 0.3);
    color: hsl(142, 71%, 55%);
}

.alert-danger {
    background: hsla(0, 84%, 60%, 0.1);
    border-color: hsla(0, 84%, 60%, 0.3);
    color: hsl(0, 84%, 70%);
}

.alert-warning {
    background: hsla(38, 92%, 50%, 0.1);
    border-color: hsla(38, 92%, 50%, 0.3);
    color: hsl(38, 92%, 60%);
}

.alert-info {
    background: hsla(210, 80%, 55%, 0.1);
    border-color: hsla(210, 80%, 55%, 0.3);
    color: hsl(210, 80%, 65%);
}

.alert a { color: inherit; font-weight: 600; }

/* --- Forms --- */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--fg-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--fg);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder {
    color: var(--fg-muted);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px hsla(4, 90%, 58%, 0.2);
}

/* --- Buttons --- */

.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Oswald', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: opacity 0.2s, background 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, hsl(4, 90%, 58%) 0%, hsl(25, 95%, 53%) 100%);
    color: #fff;
    margin-top: 0.5rem;
    box-shadow: 0 0 20px -5px hsla(4, 90%, 58%, 0.3);
}

.btn-primary:hover {
    opacity: 0.9;
    color: #fff;
}

.btn-secondary {
    background: var(--bg-muted);
    color: var(--fg);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: #fff;
}

.btn-danger {
    background: hsla(0, 84%, 60%, 0.15);
    color: var(--danger);
    border: 1px solid hsla(0, 84%, 60%, 0.3);
}

.btn-danger:hover {
    background: hsla(0, 84%, 60%, 0.25);
}

.btn-disabled {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Oswald', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: var(--bg-muted);
    color: var(--fg-muted);
    cursor: default;
    border: 1px solid var(--border);
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

.text-muted {
    margin-top: 1.5rem;
    color: var(--fg-muted);
    font-size: 0.85rem;
}

.text-muted a { color: var(--primary); }

/* --- Zone Table (Profile) --- */

.zone-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.zone-table th,
.zone-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.zone-table th {
    background: var(--bg-muted);
    font-weight: 600;
    color: var(--fg-muted);
}

.zone-1 td:first-child { border-left: 4px solid #9e9e9e; }
.zone-2 td:first-child { border-left: 4px solid #42a5f5; }
.zone-3 td:first-child { border-left: 4px solid #66bb6a; }
.zone-4 td:first-child { border-left: 4px solid #ffa726; }
.zone-5 td:first-child { border-left: 4px solid #ef5350; }

/* --- View Toggle --- */

.view-toggle {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.view-toggle .toggle-active,
.view-toggle .toggle-link {
    padding: 0.4rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-family: 'Oswald', sans-serif;
}

.view-toggle .toggle-active {
    background: linear-gradient(135deg, hsl(4, 90%, 58%) 0%, hsl(25, 95%, 53%) 100%);
    color: #fff;
}

.view-toggle .toggle-link {
    background: var(--bg-card);
    color: var(--fg-muted);
}

.view-toggle .toggle-link:hover {
    background: var(--bg-muted);
    color: var(--fg);
}

/* --- Dashboard --- */

.date-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.date-display {
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
}

.nav-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--fg);
    text-decoration: none;
    border-radius: var(--radius);
    transition: background 0.2s, color 0.2s;
}

.nav-arrow:hover {
    background: var(--bg-muted);
    color: #fff;
    opacity: 1;
}

.nav-arrow-disabled {
    color: var(--fg-muted);
    opacity: 0.3;
    cursor: default;
}

.nav-arrow-disabled:hover {
    background: none;
    color: var(--fg-muted);
    opacity: 0.3;
}

.card-subtitle {
    text-align: center;
    color: var(--fg-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* --- Heart Rate Zones Header + Toggle --- */

.hz-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.hz-header h2 {
    text-align: left;
}

.hz-header .card-subtitle {
    text-align: left;
}

.hz-toggle {
    display: flex;
    background: var(--bg-muted);
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}

.hz-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.hz-toggle-btn:hover {
    color: var(--fg);
}

.hz-toggle-active {
    background: linear-gradient(135deg, hsl(4, 90%, 58%) 0%, hsl(25, 95%, 53%) 100%);
    color: #fff !important;
}

.zone-breakdown {
    margin-top: 0;
}

.hz-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.hz-row:last-child {
    margin-bottom: 0;
}

.hz-label {
    width: 40px;
    flex-shrink: 0;
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
}

.hz-bar-container {
    flex: 1;
    position: relative;
    background: var(--bg-muted);
    border-radius: 6px;
    height: 24px;
}

.hz-bar {
    height: 100%;
    border-radius: 6px;
    min-width: 4px;
    transition: width 0.3s ease;
}

.hz-pct {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}


.hz-range {
    width: 80px;
    flex-shrink: 0;
    text-align: right;
    color: var(--fg-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .hz-range {
        width: 70px;
        font-size: 0.75rem;
    }
}

/* --- Heart Rate Chart --- */

.hr-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.trends-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.trends-header .hr-chart-title {
    display: block;
    margin-bottom: 0.2rem;
}

.trends-header .hr-chart-sub {
    display: block;
}

.hr-chart-title {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-muted);
    margin: 0;
}

.hr-chart-sub {
    font-size: 0.8rem;
    color: hsl(4, 90%, 58%);
}

.hr-chart-wrap {
    width: 100%;
    overflow: hidden;
}

.hr-chart-svg {
    display: block;
    width: 100%;
    height: 240px;
}

.hr-chart-legend {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--fg-muted);
    margin-top: 0.5rem;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.35rem;
    vertical-align: middle;
}

/* --- Meals page --- */

.meal-capture-form {
    text-align: center;
    padding: 1rem 0;
}

.meal-photo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.nutrient-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.nutrient-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--fg);
}

.nutrient-chip strong {
    font-weight: 700;
}

.nutrient-chip span {
    color: var(--fg-muted);
    font-size: 0.72rem;
}

.chip-cal { border-color: hsla(4, 90%, 58%, 0.4); }
.chip-prot { border-color: hsla(210, 70%, 55%, 0.4); }
.chip-carb { border-color: hsla(45, 90%, 55%, 0.4); }
.chip-fat { border-color: hsla(280, 60%, 60%, 0.4); }
.chip-fib { border-color: hsla(142, 60%, 45%, 0.4); }
.chip-sug { border-color: hsla(330, 70%, 60%, 0.4); }
.chip-sod { border-color: hsla(200, 20%, 60%, 0.4); }

.meal-items {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.meal-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-muted);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.meal-item-main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 150px;
    flex: 1;
}

.meal-item-qty {
    font-size: 0.8rem;
    color: var(--fg-muted);
    margin-left: 0.4rem;
}

.meal-item-macros {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.meal-action-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.meal-history-day {
    margin-top: 1.5rem;
}

.meal-history-day:first-child {
    margin-top: 0;
}

.meal-history-date {
    font-family: 'Oswald', sans-serif;
    font-size: 0.95rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3rem;
}

.meal-history-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.meal-history-entry:last-child {
    border-bottom: none;
}

.meal-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.meal-history-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.meal-history-details {
    margin-top: 0.6rem;
}

.meal-history-details summary {
    color: var(--fg-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.3rem 0;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
}

/* --- Scores Explained (Vertical Bars) --- */

.vbar-chart {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.25rem;
    height: 270px;
    padding-top: 1.5rem;
}

@media (min-width: 601px) {
    .vbar-chart {
        gap: 0.1rem;
    }
}

.vbar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
}

.vbar-value {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--fg);
    line-height: 1;
    padding-bottom: 0.05rem;
    transform: translateY(-100%);
}

.vbar-track {
    flex: 1;
    width: 100%;
    max-width: 40px;
    position: relative;
    background: var(--bg-muted);
    border-radius: 6px;
    display: flex;
    align-items: flex-end;
}

.vbar-fill {
    width: 100%;
    border-radius: 6px;
    min-height: 4px;
    transition: height 0.3s ease;
}

.vbar-label {
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 0.4rem;
    text-transform: uppercase;
    color: var(--fg-muted);
}

.vbar-bpm {
    font-size: 0.7rem;
    color: var(--fg-muted);
    margin-top: 0.1rem;
}

/* --- Dashboard Cards --- */

.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.card-title-centered {
    text-align: center;
    margin: 0 0 1rem 0;
    border: none;
    padding: 0;
}

/* --- Exercise Points Ring --- */

.delay-hint {
    text-align: center;
    color: var(--fg-muted);
    font-size: 0.75rem;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.sync-btn-form {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1;
}

.sync-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--bg-muted);
    color: var(--fg-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.sync-btn:hover {
    background: var(--border);
    color: #fff;
}

.ring-with-arrows {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.ring-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--fg-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.ring-arrow:hover {
    background: var(--bg-muted);
    color: #fff;
}

.ring-description {
    text-align: center;
    color: var(--fg-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
    margin-bottom: 0;
}

.points-ring-container {
    display: flex;
    justify-content: center;
}

.points-ring {
    position: relative;
    width: 176px;
    height: 176px;
}

.points-ring svg {
    display: block;
}

.points-ring-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    line-height: 1.3;
}

.points-ring-value {
    display: block;
    font-family: 'Oswald', sans-serif;
    font-size: 2rem;
    font-weight: 700;
}

/* --- Tracker Sections --- */

.tracker-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.tracker-section h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

/* --- Tracker Tiles --- */

.tracker-tiles {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.tracker-tile {
    position: relative;
    flex: 1;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: var(--bg-muted);
    border: 2px solid transparent;
    border-radius: var(--radius);
    color: var(--fg-muted);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.tracker-tile:hover {
    color: var(--fg);
}

.tracker-tile-active {
    border-color: hsl(4, 90%, 58%);
    color: var(--fg);
    background: hsla(4, 90%, 58%, 0.08);
}

.tracker-tile-label {
    font-family: 'Oswald', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.tracker-tile-status {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.85rem;
    color: hsl(142, 71%, 55%);
    font-weight: 700;
}

.tracker-panel {
    margin-top: 0.5rem;
}

.tracker-action {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tracker-action-slot {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* --- Setup Cards (Apple Health / Google Fit) --- */

.connect-card {
    margin: 1.5rem 0;
}

.setup-card {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.setup-card h2,
.setup-card h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.setup-field {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.75rem;
}

.setup-field label {
    width: 120px;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.setup-value {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--fg);
    word-break: break-all;
    cursor: pointer;
    transition: border-color 0.2s;
    user-select: all;
}

.setup-value:hover {
    border-color: var(--primary);
}

.setup-value.copied {
    border-color: var(--success);
    box-shadow: 0 0 0 2px hsla(142, 71%, 45%, 0.2);
}
