/* Base Styles */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary-color: #94a3b8;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --danger-color: #f87171;
    --background: #0f172a;
    --surface: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* Navbar */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

.nav-brand a {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-normal);
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
}

.nav-link i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--background);
    color: var(--text);
    transform: translateY(-1px);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--background);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.theme-toggle:hover {
    background: var(--border);
    transform: scale(1.05);
}

.theme-toggle i {
    width: 20px;
    height: 20px;
    color: var(--text);
}

/* Show/hide theme icons based on current theme */
[data-theme="light"] .theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: none;
}

/* User Dropdown Menu */
.nav-user-dropdown {
    position: relative;
}

.nav-user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    transition: all var(--transition-normal);
}

.nav-user-btn:hover {
    background: var(--border);
}

.nav-user-btn i {
    width: 18px;
    height: 18px;
}

.nav-user-btn .chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform var(--transition-normal);
}

.nav-user-dropdown.open .nav-user-btn .chevron {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    z-index: 200;
}

.nav-user-dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.dropdown-item:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.dropdown-item:hover {
    background: var(--background);
}

.dropdown-item.active {
    background: var(--primary-color);
    color: white;
}

.dropdown-item i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* Mobile nav items in user dropdown - hidden on desktop */
.mobile-nav-item {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-nav-item {
        display: flex !important;
    }
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: calc(100vh - 120px);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

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

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--background);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

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

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    transition: all var(--transition-normal);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    animation: fadeSlideIn var(--transition-normal) ease;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-error {
    background: #fef2f2;
    color: var(--danger-color);
    border: 1px solid #fecaca;
}

[data-theme="dark"] .alert-error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

[data-theme="dark"] .alert-success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
}

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-card h2 {
    text-align: center;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.auth-form button {
    margin-top: 0.5rem;
}

.auth-links {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.auth-links a {
    color: var(--primary-color);
}

/* Calendar Header (used by dashboard) */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.week-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.week-navigation h2 {
    font-size: 1.25rem;
    min-width: 300px;
    text-align: center;
}

.workout-item,
.activity-item {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.workout-item.planned {
    background: #dbeafe;
    color: #1e40af;
}

/* Workout legend */
.workout-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Workout item structure */
.workout-item .workout-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.25rem;
}

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

.workout-item .workout-details {
    font-size: 0.7rem;
    opacity: 0.85;
    margin-top: 0.125rem;
}

.workout-item .workout-notes {
    font-size: 0.65rem;
    font-style: italic;
    opacity: 0.75;
    margin-top: 0.25rem;
    line-height: 1.3;
}

/* Intensity badges */
.intensity-badge {
    font-size: 0.6rem;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    font-weight: 500;
    text-transform: uppercase;
    white-space: nowrap;
}

.intensity-easy {
    background: #dcfce7;
    color: #166534;
}

.intensity-moderate {
    background: #fef3c7;
    color: #92400e;
}

.intensity-hard {
    background: #fee2e2;
    color: #991b1b;
}

/* Workout type color coding */
.workout-item.workout-easy_run,
.legend-color.workout-easy_run { background: #dcfce7; color: #166534; }

.workout-item.workout-recovery_run,
.legend-color.workout-recovery_run { background: #e0f2fe; color: #0369a1; }

.workout-item.workout-long_run,
.legend-color.workout-long_run { background: #fef3c7; color: #92400e; }

.workout-item.workout-tempo,
.legend-color.workout-tempo { background: #fee2e2; color: #991b1b; }

.workout-item.workout-intervals,
.legend-color.workout-intervals { background: #fce7f3; color: #9d174d; }

.workout-item.workout-threshold { background: #ffedd5; color: #9a3412; }
.workout-item.workout-fartlek { background: #fce7f3; color: #9d174d; }

.workout-item.workout-run_strength,
.legend-color.workout-run_strength { background: #e9d5ff; color: #7c3aed; }

.workout-item.workout-strength { background: #e9d5ff; color: #7c3aed; }
.workout-item.workout-rest { background: #f3f4f6; color: #6b7280; }

.activity-item {
    background: #dcfce7;
    color: #166534;
}

/* Clickable planned workout items */
.workout-item.planned {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.workout-item.planned:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* Wider modal variant */
.modal-wide {
    max-width: 550px;
}

/* Workout detail modal grid */
.workout-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.workout-detail-item {
    background: var(--background);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
}

.workout-detail-item .detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.workout-detail-item .detail-value {
    font-size: 1rem;
    font-weight: 600;
}

/* Workout detail sections */
.workout-detail-section {
    margin-bottom: 0.75rem;
}

.workout-detail-section .detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.workout-detail-section .detail-text {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Modal subtitle (date) */
.workout-detail-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Subheadings inside modal body */
.detail-subheading {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.025em;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.detail-subheading:first-child {
    margin-top: 0;
}

/* Workout structure card */
.workout-structure {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.workout-structure .detail-subheading {
    margin-top: 0;
}

.structure-step {
    display: flex;
    gap: 0.75rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border);
}

.structure-step:last-child {
    border-bottom: none;
}

.step-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    min-width: 70px;
    padding-top: 0.1rem;
}

.step-text {
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Reasoning/Notes text blocks */
.detail-text-block {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Context footer in workout detail */
.workout-detail-context {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
}

/* Plan info section below calendar */
.plan-info-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: cardFadeIn var(--transition-slow) ease;
}

.plan-info-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.plan-info-header i {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

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

.plan-info-content p {
    font-size: 0.8rem;
    font-style: italic;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.plan-info-content p:last-child {
    margin-bottom: 0;
}

/* Strength exercises list in workout detail */
.strength-list { margin: 0; padding-left: 1.25rem; }
.strength-list li { margin-bottom: 0.25rem; }
.strength-list li:last-child { margin-bottom: 0; }

/* Future weeks grid */
.future-weeks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
    padding: 0 1rem 1rem;
}

.future-week-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.future-week-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.375rem;
}
.future-week-id {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}
.future-week-phase {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--primary-color);
    font-weight: 500;
}
.future-week-focus {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.future-week-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.future-week-workouts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}
.future-week-tag {
    font-size: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.125rem 0.5rem;
    color: var(--text-muted);
}

.calendar-actions {
    display: flex;
    gap: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity var(--transition-normal);
    animation: modalFadeIn var(--transition-normal) ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn var(--transition-normal) ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.loading-indicator.hidden {
    display: none;
}

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

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

/* Chat Page */
.chat-page {
    height: calc(100vh - 180px);
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 1rem;
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    max-width: 80%;
}

.message.user {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
}

.message.assistant {
    background: var(--background);
}

.message.system {
    background: #fef3c7;
    color: #92400e;
    max-width: 100%;
    text-align: center;
    font-size: 0.875rem;
}

.message.loading {
    font-style: italic;
    color: var(--text-muted);
}

.chat-input-container {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: none;
    font-family: inherit;
}

/* Profile Page */
.profile-page,
.settings-page,
.health-page,
.admin-page {
    max-width: 800px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header h1 i {
    width: 28px;
    height: 28px;
    color: var(--primary-color);
}

/* Metric card icons */
.metric-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.metric-card h3 i {
    width: 18px;
    height: 18px;
    color: var(--primary-color);
}

/* Health history section */
.health-history h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.health-history h2 i {
    width: 22px;
    height: 22px;
    color: var(--primary-color);
}

.profile-section,
.settings-section,
.admin-section {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.profile-section h2,
.settings-section h2,
.admin-section .section-header h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.info-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.info-item span {
    font-weight: 500;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.connected,
.status-badge.active {
    background: #dcfce7;
    color: #166534;
}

.status-badge.disconnected,
.status-badge.inactive {
    background: #fef2f2;
    color: var(--danger-color);
}

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

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

.setting-info label {
    font-weight: 500;
}

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

.setting-item.danger {
    background: #fef2f2;
    margin: 0 -1.5rem;
    padding: 1rem 1.5rem;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 12px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Health Page */
.health-overview {
    margin-bottom: 2rem;
}

.readiness-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
}

.readiness-score {
    margin: 1.5rem 0;
}

.readiness-score .score {
    font-size: 4rem;
    font-weight: 700;
    display: block;
}

.readiness-score.excellent .score { color: var(--success-color); }
.readiness-score.good .score { color: #22c55e; }
.readiness-score.moderate .score { color: var(--warning-color); }
.readiness-score.low .score { color: #f97316; }
.readiness-score.very-low .score { color: var(--danger-color); }

.health-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1rem;
    transition: all var(--transition-normal);
}

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

.metric-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
}

.metric-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: -0.25rem;
}

.metric-trend {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Admin Page */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    display: block;
}

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.users-table,
.history-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.cache-actions,
.session-actions {
    display: flex;
    gap: 0.5rem;
}

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

.loading {
    color: var(--text-muted);
    font-style: italic;
}

.empty, .error {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Tag Input */
.tag-input-container {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    background: var(--surface);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tag-list:empty {
    margin-bottom: 0;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.8;
}

.tag-remove:hover {
    opacity: 1;
}

.tag-input-container input {
    border: none;
    outline: none;
    width: 100%;
    padding: 0.25rem;
    font-size: 0.875rem;
}

.section-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.field-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

/* Charts */
.chart-container {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1rem;
    margin-bottom: 1.5rem;
    transition: all var(--transition-normal);
}

.chart-container:hover {
    box-shadow: var(--shadow);
}

.chart-container h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container h3 i {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

.chart-wrapper {
    position: relative;
    height: 200px;
}

.chart-wrapper.tall {
    height: 300px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.charts-grid .chart-container {
    margin-bottom: 0;
    cursor: pointer;
}

.charts-grid .chart-container:hover {
    border-color: var(--primary-color);
}

/* Chart Detail Modal */
.modal-chart {
    max-width: 800px;
    width: 95%;
}

.chart-modal-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn:hover {
    background: var(--background);
    color: var(--text);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.chart-modal-body .chart-wrapper {
    height: 350px;
}

.chart-modal-body .loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 350px;
}

.chart-modal-body .error-message {
    text-align: center;
    color: var(--danger-color);
    padding: 2rem;
}

/* Card Entrance Animations */
.metric-card,
.readiness-card,
.chart-container {
    animation: cardFadeIn var(--transition-slow) ease;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation for grid items */
.health-metrics-grid .metric-card:nth-child(1) { animation-delay: 0ms; }
.health-metrics-grid .metric-card:nth-child(2) { animation-delay: 50ms; }
.health-metrics-grid .metric-card:nth-child(3) { animation-delay: 100ms; }
.health-metrics-grid .metric-card:nth-child(4) { animation-delay: 150ms; }

/* Dark mode adjustments for workout colors */
[data-theme="dark"] .workout-item.workout-easy_run,
[data-theme="dark"] .legend-color.workout-easy_run { background: rgba(220, 252, 231, 0.2); color: #86efac; }

[data-theme="dark"] .workout-item.workout-recovery_run,
[data-theme="dark"] .legend-color.workout-recovery_run { background: rgba(224, 242, 254, 0.2); color: #7dd3fc; }

[data-theme="dark"] .workout-item.workout-long_run,
[data-theme="dark"] .legend-color.workout-long_run { background: rgba(254, 243, 199, 0.2); color: #fcd34d; }

[data-theme="dark"] .workout-item.workout-tempo,
[data-theme="dark"] .legend-color.workout-tempo { background: rgba(254, 226, 226, 0.2); color: #fca5a5; }

[data-theme="dark"] .workout-item.workout-intervals,
[data-theme="dark"] .legend-color.workout-intervals { background: rgba(252, 231, 243, 0.2); color: #f9a8d4; }

[data-theme="dark"] .workout-item.workout-run_strength,
[data-theme="dark"] .legend-color.workout-run_strength { background: rgba(233, 213, 255, 0.2); color: #c4b5fd; }

[data-theme="dark"] .activity-item { background: rgba(220, 252, 231, 0.2); color: #86efac; }

/* Dark mode status badges */
[data-theme="dark"] .status-badge.connected,
[data-theme="dark"] .status-badge.active {
    background: rgba(220, 252, 231, 0.2);
    color: #86efac;
}

[data-theme="dark"] .status-badge.disconnected,
[data-theme="dark"] .status-badge.inactive {
    background: rgba(254, 242, 242, 0.2);
    color: #fca5a5;
}

/* Dashboard Page */
.main-content:has(.dashboard-page) {
    max-width: 1440px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    align-items: start;
}

.dashboard-main {
    min-width: 0;
}

/* Two-row week grid: headers, plan row, activity row */
.dashboard-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.dash-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* Remove right border on last column (every 7th child) */
.dashboard-week-grid > :nth-child(7n) {
    border-right: none;
}

.dash-day-header.today {
    background: var(--primary-color);
    color: white;
}

.dash-day-plan {
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0.375rem;
    min-height: 120px;
    vertical-align: top;
}

.dash-day-plan.today {
    border-bottom-color: var(--primary-color);
}

.dash-day-actual {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0.375rem;
    min-height: 48px;
    vertical-align: top;
}

/* Row labels via pseudo-elements */
.dash-day-plan:first-of-type::before,
.dash-day-actual:first-of-type::before {
    content: none;
}

/* Activity items in the actual row */
.activity-item-dash {
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
    background: #dcfce7;
    color: #166534;
}

[data-theme="dark"] .activity-item-dash {
    background: rgba(220, 252, 231, 0.2);
    color: #86efac;
}

.activity-dash-header {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.125rem;
}

.activity-item-dash .activity-type {
    font-weight: 600;
    font-size: 0.7rem;
}

.activity-dash-stats {
    font-size: 0.65rem;
    opacity: 0.9;
    line-height: 1.3;
}

.activity-dash-hr {
    font-size: 0.6rem;
    opacity: 0.8;
    margin-top: 0.125rem;
}

/* Interval badge in dashboard */
.interval-badge-dash {
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 500;
    text-transform: capitalize;
    white-space: nowrap;
}

.interval-badge-dash.intervals { background: #fee2e2; color: #991b1b; }
.interval-badge-dash.tempo { background: #fef3c7; color: #92400e; }
.interval-badge-dash.threshold { background: #ffedd5; color: #9a3412; }
.interval-badge-dash.easy { background: #d1fae5; color: #065f46; }
.interval-badge-dash.long_run { background: #dbeafe; color: #1e40af; }
.interval-badge-dash.fartlek { background: #ede9fe; color: #5b21b6; }

[data-theme="dark"] .interval-badge-dash.intervals { background: rgba(254, 226, 226, 0.3); color: #fca5a5; }
[data-theme="dark"] .interval-badge-dash.tempo { background: rgba(254, 243, 199, 0.3); color: #fcd34d; }
[data-theme="dark"] .interval-badge-dash.threshold { background: rgba(255, 237, 213, 0.3); color: #fdba74; }
[data-theme="dark"] .interval-badge-dash.easy { background: rgba(209, 250, 229, 0.3); color: #86efac; }
[data-theme="dark"] .interval-badge-dash.long_run { background: rgba(219, 234, 254, 0.3); color: #93c5fd; }
[data-theme="dark"] .interval-badge-dash.fartlek { background: rgba(237, 233, 254, 0.3); color: #c4b5fd; }

/* Row separator label */
.dashboard-week-grid .dash-day-actual {
    background: var(--background);
}

/* Daily Comments */
.day-comment-container {
    margin-top: auto;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--border);
    min-height: 1.25rem;
}

.day-comment-add {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.5;
    cursor: pointer;
    font-style: italic;
    transition: opacity var(--transition-fast);
}

.day-comment-add:hover {
    opacity: 1;
}

.day-comment-text {
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1.3;
    display: block;
    word-break: break-word;
}

.day-comment-text:hover {
    color: var(--text);
}

.day-comment-input {
    width: 100%;
    font-size: 0.65rem;
    padding: 0.25rem;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    resize: vertical;
    font-family: inherit;
    line-height: 1.3;
}

.day-comment-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.day-comment-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.2rem;
}

.btn-comment-save,
.btn-comment-cancel {
    font-size: 0.6rem;
    padding: 0.125rem 0.375rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: 1.4;
}

.btn-comment-save {
    background: var(--primary-color);
    color: white;
}

.btn-comment-save:hover {
    background: var(--primary-hover);
}

.btn-comment-cancel {
    background: var(--border);
    color: var(--text-muted);
}

.btn-comment-cancel:hover {
    background: var(--secondary-color);
    color: white;
}

/* Make actual cells flex to push comments to bottom */
.dash-day-actual {
    display: flex;
    flex-direction: column;
}

/* Charts below calendar */
.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.dashboard-charts .chart-container {
    margin-bottom: 0;
}

.dashboard-charts .chart-wrapper {
    height: 180px;
}

/* Right sidebar */
.dashboard-plan {
    position: sticky;
    top: 76px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-plan .plan-info-section {
    margin-bottom: 0;
}

.dashboard-main .future-weeks-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    padding: 0 0.5rem 0.5rem;
}

.dashboard-main .plan-info-section {
    margin-top: 1.5rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-plan {
        position: static;
    }

    .dashboard-main .future-weeks-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* Horizontal scroll wrapper for week calendar on mobile */
.dashboard-week-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
    padding: 0 0.25rem 0.5rem;
}

.dashboard-week-scroll .dashboard-week-grid {
    min-width: 560px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .health-metrics-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .nav-links {
        display: none;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .modal-chart {
        width: 100%;
        max-width: 100%;
        margin: 0.5rem;
    }

    .chart-modal-body .chart-wrapper {
        height: 250px;
    }

    .chart-modal-filters {
        flex-wrap: wrap;
    }

    .future-weeks-grid {
        grid-template-columns: 1fr;
    }

    .nav-actions {
        gap: 0.5rem;
    }

    .nav-user-btn span {
        display: none;
    }

    .nav-user-btn {
        padding: 0.5rem;
    }
}
