/* Theme Variables */
:root {
    /* Option 1: Modern Sage (Default) */
    --bg-color: #F3F4F6;
    --surface-color: #FFFFFF;
    --primary-color: #10B981;
    --primary-hover: #059669;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sidebar-bg: #FFFFFF;
    --sidebar-width: 260px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-heading: 'Inter', -apple-system, sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
}

[data-theme="dark"] {
    /* Option 2: Deep Forest */
    --bg-color: #111827;
    --surface-color: #1F2937;
    --primary-color: #34D399;
    --primary-hover: #10B981;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --sidebar-bg: #1F2937;
}

[data-theme="neon"] {
    /* Option 3: Neon Tactical */
    --bg-color: #0F0F0F;
    --surface-color: #1A1A1A;
    --primary-color: #00FF00;
    --primary-hover: #32CD32;
    --text-main: #E5E5E5;
    --text-muted: #A3A3A3;
    --border-color: #333333;
    --shadow-sm: 0 0 5px rgba(0, 255, 0, 0.1);
    --shadow-md: 0 0 10px rgba(0, 255, 0, 0.15);
    --sidebar-bg: #1A1A1A;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.text-sm {
    font-size: 0.875rem;
}

.font-bold {
    font-weight: 700;
}

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

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

/* Layout Structure */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 50;
}

.sidebar-header {
    margin-bottom: 2.5rem;
}

.app-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.nav-links {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-size: 1rem;
}

.nav-btn:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.nav-btn.active {
    background-color: var(--primary-color);
    color: #fff;
    /* Always white text on primary */
    box-shadow: var(--shadow-md);
}

/* Theme Switcher in Sidebar */
.theme-select {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    margin-top: 0.5rem;
    cursor: pointer;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    max-width: 1400px;
}

/* Bottom Tab Bar (Mobile Navigation) */
.bottom-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom); /* Enhances layout on iPhones with home bars */
}

.bottom-tab-bar nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
}

.bottom-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    height: 100%;
    transition: color 0.15s ease;
}

.bottom-tab-btn .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3px;
}

.bottom-tab-btn .icon svg {
    width: 24px;
    height: 24px;
}

.bottom-tab-btn:hover {
    color: var(--text-main);
}

.bottom-tab-btn.active {
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none !important; /* Hide sidebar completely on mobile */
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: calc(75px + env(safe-area-inset-bottom)); /* Dynamic space for bottom bar */
    }

    .bottom-tab-bar {
        display: block; /* Show bottom bar on mobile */
    }
}

/* Cards & Components */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 3rem;
    height: 3rem;
    background: var(--bg-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Inputs & Forms */
input,
select,
textarea {
    width: 100%;
    padding: 0.875rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: scale(0.97);
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-color);
}

.btn-outline:active {
    transform: scale(0.97);
}

.btn-danger {
    background: #EF4444;
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

/* Lists */
.list-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item:last-child {
    border-bottom: none;
}

/* Authentication Screen */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    background: var(--bg-color);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-color);
    padding: 0.25rem;
    border-radius: var(--radius-md);
}

.auth-tab {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: calc(var(--radius-md) - 4px);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--surface-color);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form.active.slide-right {
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.auth-form.active.slide-left {
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Tab Sections */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

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

/* Lift Card */
.lift-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
    animation: fadeIn 0.2s ease;
}

.lift-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.lift-card-header input {
    flex: 1;
    margin-bottom: 0;
    font-weight: 600;
    font-size: 1rem;
}

.lift-card-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.lift-card-remove:hover {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
}

.lift-card-remove:active {
    transform: scale(0.9);
}

.lift-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.lift-field {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lift-field label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 700;
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    width: 100%;
}

.stepper-btn {
    width: 36px;
    height: 38px;
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.stepper-btn:hover {
    background: var(--bg-color);
}

.stepper-btn:active {
    transform: scale(0.9);
}

.stepper input {
    flex: 1;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    padding: 0.4rem 0;
    margin: 0;
    min-width: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
}

.calendar-day {
    aspect-ratio: 1;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day:hover {
    background: var(--bg-color);
}

.calendar-day.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.calendar-day.today {
    border-color: var(--primary-color);
    background: rgba(16, 185, 129, 0.1);
}

.calendar-day.has-workout::after {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    margin-top: auto;
}

.calendar-day.has-cardio::after {
    content: '';
    width: 6px;
    height: 6px;
    background: #F59E0B;
    /* Amber for cardio */
    border-radius: 50%;
    margin-top: auto;
}

.calendar-day.has-both::after {
    content: '';
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, var(--primary-color) 50%, #F59E0B 50%);
    border-radius: 50%;
    margin-top: auto;
}

/* UI Utilities */
.clickable {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-lg {
    font-size: 1.125rem;
    padding: 1.25rem 2rem;
}

.btn-sm {
    width: auto;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.text-sm {
    font-size: 0.875rem;
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--surface-color);
    color: var(--text-main);
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    pointer-events: auto;
    animation: toastIn 0.4s ease, toastOut 0.4s ease 2.6s forwards;
    backdrop-filter: blur(10px);
    max-width: 380px;
}

.toast.toast-error {
    border-left-color: #EF4444;
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

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

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* Loading Spinner */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-color);
    flex-direction: column;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Delete Icon Button */
.delete-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-icon-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

.delete-icon-btn:active {
    transform: scale(0.9);
}

/* Custom Confirm Modal (Action Sheet) */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: overlayIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.confirm-sheet {
    background: var(--surface-color);
    width: 100%;
    max-width: 400px;
    border-radius: 16px 16px 0 0;
    padding: 1.5rem;
    animation: sheetUp 0.3s ease;
}

.confirm-sheet h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.confirm-sheet p {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.confirm-sheet .confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.confirm-sheet .btn {
    width: 100%;
}

@keyframes overlayIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes sheetUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.9s forwards;
    max-width: 340px;
}

.toast-error {
    background: #EF4444;
}

.toast-icon {
    font-size: 1.1rem;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

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

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* PR Badge */
.pr-badge {
    display: inline-block;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.25rem;
    vertical-align: middle;
}

/* Template Picker */
.template-picker-card {
    padding: 0.75rem 1rem !important;
    margin-bottom: 0.75rem !important;
}

/* Session Timer Bar */
.session-timer-bar {
    padding: 0.6rem 1rem !important;
    margin-bottom: 0.75rem !important;
}

.timer-section {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.timer-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.timer-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

/* Rest Timer */
.rest-timer-section {
    display: flex;
    align-items: center;
}

.rest-presets {
    display: flex;
    gap: 0.3rem;
}

.rest-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.rest-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.rest-btn:active {
    transform: scale(0.95);
}

.rest-btn-cancel {
    background: transparent;
    border-color: #EF4444;
    color: #EF4444;
    font-size: 0.85rem;
}

.rest-btn-cancel:hover {
    background: #EF4444;
    color: white;
}

/* Session Timer Control Buttons */
.timer-ctrl-play {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.timer-ctrl-play:hover {
    background: var(--primary-color);
    color: white;
}

.timer-ctrl-pause {
    color: #F59E0B;
    border-color: #F59E0B;
}

.timer-ctrl-pause:hover {
    background: #F59E0B;
    color: white;
}

.timer-ctrl-stop {
    color: #EF4444;
    border-color: #EF4444;
}

.timer-ctrl-stop:hover {
    background: #EF4444;
    color: white;
}

.timer-ctrl-edit {
    color: var(--text-muted);
    border-color: var(--border-color);
}

.timer-ctrl-edit:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.rest-countdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rest-countdown.hidden {
    display: none;
}

.rest-timer-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
    min-width: 3rem;
    text-align: center;
}

.rest-timer-value.rest-urgent {
    color: #EF4444;
    animation: restPulse 0.5s ease-in-out infinite;
}

@keyframes restPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.05);
    }
}

/* Exercise History Inline */
.exercise-history {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.2rem 0 0.4rem 0;
    font-style: italic;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.exercise-history.visible {
    opacity: 1;
}


/* Bottom Tab Bar (Mobile) */
.bottom-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--surface-color) 80%, transparent);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    padding: 0.5rem 0;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.bottom-tab-bar nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    transition: color 0.2s;
}

.bottom-tab-btn span:first-child {
    font-size: 1.4rem;
}

.bottom-tab-btn.active {
    color: var(--primary-color);
}

.bottom-tab-btn:active {
    transform: scale(0.9);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: 5rem;
    }

    .bottom-tab-bar {
        display: block;
    }

    .mobile-nav-toggle {
        display: none;
    }

    .calendar-grid {
        gap: 0.25rem;
    }

    .calendar-day {
        aspect-ratio: 1;
        padding: 0.25rem;
        font-size: 0.75rem;
        border-radius: 6px;
    }

    .calendar-day.has-workout::after,
    .calendar-day.has-cardio::after {
        width: 4px;
        height: 4px;
    }

    .calendar-day.has-both::after {
        width: 6px;
        height: 6px;
    }

    .calendar-header h3 {
        font-size: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stepper input {
        font-size: 1.1rem;
        padding: 0.5rem 0;
    }

    .lift-card {
        padding: 0.75rem;
    }

    .lift-fields {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .lift-field {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .lift-field label {
        margin-bottom: 0;
        font-size: 0.8rem;
    }

    .stepper {
        width: 160px;
        flex-shrink: 0;
    }

    .stepper-btn {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }

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

    .toast-container {
        top: auto;
        bottom: 5rem;
        left: 1rem;
        right: 1rem;
    }

    .toast {
        max-width: 100%;
    }

    .confirm-sheet {
        max-width: 100%;
    }
}


@media (min-width: 769px) {
    .confirm-sheet {
        border-radius: 16px;
        margin-bottom: 2rem;
    }
}

/* ============ Phase 1: PR & Overload Styles ============ */

/* Exercise history - last session info */
.exercise-history.visible {
    display: block;
}

.last-session-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 4px 0 2px;
}

/* Progressive overload suggestion chip */
.overload-suggestion {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: var(--primary-color);
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.2s;
}

.overload-suggestion:hover {
    background: rgba(52, 211, 153, 0.25);
    border-color: var(--primary-color);
}

.suggestion-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Personal Records in Progress tab */
.pr-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 0.5rem;
}

.pr-row:last-child {
    border-bottom: none;
}

.pr-exercise {
    font-weight: 600;
    flex: 1;
    color: var(--text-main);
}

.pr-weight {
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
}

.pr-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* PR Celebration Banner */
.pr-celebration-banner {
    position: fixed;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 16px 24px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.5);
    transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 260px;
    max-width: 420px;
    width: 90vw;
}

.pr-celebration-banner.visible {
    top: 24px;
}

.pr-celebration-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.pr-celebration-icon {
    font-size: 2rem;
    line-height: 1;
}

.pr-celebration-list {
    margin-top: 4px;
    font-size: 0.9rem;
    opacity: 0.95;
}

/* PR show more/less toggle */
.pr-toggle-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 6px 0 0;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.pr-toggle-btn:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ============ Phase 2: Badges, Volume Chart, Supersets ============ */

/* Badge Grid */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.badge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    cursor: default;
    position: relative;
}

.badge-unlocked {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.12), rgba(16, 185, 129, 0.06));
    border-color: var(--primary-color);
}

.badge-locked {
    background: var(--surface-color);
    opacity: 0.45;
    filter: grayscale(0.5);
}

.badge-icon {
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.badge-name {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 3px;
}

.badge-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-bottom: 4px;
}

.badge-status {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--primary-color);
}

.badge-locked .badge-status {
    color: var(--text-muted);
}

/* Achievement Unlock Toast (slides in from right) */
.achievement-toast {
    position: fixed;
    bottom: 80px;
    right: -340px;
    z-index: 9998;
    background: linear-gradient(135deg, var(--surface-color), rgba(52, 211, 153, 0.1));
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 260px;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: right 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.achievement-toast.visible {
    right: 20px;
}

.achievement-toast-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.achievement-toast-title {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.achievement-toast-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    margin: 2px 0;
}

.achievement-toast-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Superset Lift Card Styling */
.lift-card.superset-top {
    border-left: 3px solid var(--primary-color);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
    margin-bottom: 0;
    position: relative;
}

.lift-card.superset-top::after {
    content: 'SUPERSET';
    position: absolute;
    left: -3px;
    bottom: -10px;
    background: var(--primary-color);
    color: var(--surface-color);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 0 0 4px 0;
    z-index: 2;
}

.lift-card.superset-bottom {
    border-left: 3px solid var(--primary-color);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: 1px dashed var(--primary-color);
    margin-top: 0;
}

/* Lift Card Actions Row */
.lift-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    align-items: center;
}

/* Superset toggle button */
.btn-superset {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-superset:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-superset-active {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    background: rgba(52, 211, 153, 0.1) !important;
}

/* ============ Phase 3: Body Weight, 1RM, Autocomplete, Export ============ */

/* Body Weight log row */
.weight-log-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.weight-date-input {
    flex: 1.5;
    background: var(--input-bg, var(--surface-color));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 8px 10px;
    font-size: 0.9rem;
}

.weight-number-input {
    flex: 1;
    background: var(--input-bg, var(--surface-color));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 8px 10px;
    font-size: 0.9rem;
    min-width: 70px;
}

/* 1RM Badge */
.one-rm-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Exercise Autocomplete Dropdown */
.lift-card {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 56px;
    /* below the lift-card-header */
    z-index: 100;
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: none;
}

.autocomplete-item {
    padding: 9px 14px;
    font-size: 0.88rem;
    color: var(--text-main);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: rgba(52, 211, 153, 0.12);
    color: var(--primary-color);
}

.autocomplete-item strong {
    color: var(--primary-color);
}

/* ============ Phase 4: Training Summary Card ============ */

.summary-card {
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--surface-color) 100%);
    border: 1px solid var(--border-color);
}

.summary-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    background: var(--bg-color);
    border-radius: 10px;
    padding: 4px;
}

.summary-tab {
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.summary-tab-label {
    font-size: 0.68rem;
    font-weight: 400;
    opacity: 0.7;
}

.summary-tab-active {
    background: var(--surface-color);
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.summary-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.summary-period-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
}

.summary-stat-row:last-child {
    border-bottom: none;
}

.summary-stat-label {
    color: var(--text-muted);
}

.summary-stat-value {
    font-weight: 700;
    color: var(--text-main);
}

.summary-highlight {
    color: var(--primary-color) !important;
}

.summary-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px 0;
}

/* --- Progress Page Cleanups --- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.charts-grid .card {
    margin-bottom: 0;
}

/* Collapsible Card Sections */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    min-height: 24px;
    padding: 0.5rem;
    margin: -0.5rem;
    /* Offset padding to keep alignment */
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease;
}

.collapsible-header:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.collapsible-header h3 {
    margin-bottom: 0;
}

.collapsible-chevron {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
}

.collapsible-body {
    margin-top: 1rem;
    overflow: hidden;
    transition: max-height 0.3s ease, margin-top 0.3s ease, opacity 0.3s ease;
    max-height: 5000px;
    opacity: 1;
}

.collapsible-body.collapsed {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
}

.collapsible-header.collapsed .collapsible-chevron {
    transform: rotate(-90deg);
}

/* ========================================= */
/*         Mobile Bottom Sheet UI            */
/* ========================================= */

.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    background: var(--bg-color);
    width: 100%;
    height: 85vh;
    border-radius: 24px 24px 0 0;
    padding: 1rem 1.5rem;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.bottom-sheet-overlay.active .bottom-sheet {
    transform: translateY(0);
}

.bottom-sheet-drag-handle {
    width: 40px;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    margin: 0 auto 1.5rem auto;
}

.bottom-sheet h2 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 1rem;
    text-align: center;
}

.bottom-sheet-search {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-main);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.bottom-sheet-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.bottom-sheet-list {
    flex: 1;
    overflow-y: auto;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

.bottom-sheet-item {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-main);
    transition: background-color 0.1s ease;
}

.bottom-sheet-item:active {
    background-color: var(--bg-secondary);
}

.bottom-sheet-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-color);
    opacity: 0.2;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    color: var(--primary-color);
}

.bottom-sheet-item-title {
    flex: 1;
    font-weight: 500;
}