/* 1. Variables / theme */
:root {
    --bs-body-bg: #f5f7fa;
    --bs-body-color: #182230;
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-secondary-color: #65758b;
    --bs-border-color: #e6e8ec;
    --bs-link-color: #1d4ed8;
    --bs-link-hover-color: #1e40af;
    --bs-border-radius: 0.5rem;
    --bs-border-radius-sm: 0.375rem;
    --bs-border-radius-lg: 0.75rem;
    --bs-focus-ring-color: rgba(37, 99, 235, 0.22);

    --bike-bg: #f5f7fa;
    --bike-surface: #ffffff;
    --bike-surface-muted: #f8fafc;
    --bike-text: #182230;
    --bike-muted: #65758b;
    --bike-border: #e6e8ec;
    --bike-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --bike-shadow-md: 0 12px 28px rgba(15, 23, 42, 0.10);
    --bike-primary: #2563eb;
    --bike-primary-soft: #dbeafe;
    --bike-secondary: #0f766e;
    --bike-secondary-soft: #ccfbf1;
    --bike-accent: #f59e0b;
    --bike-chart-primary: #2563eb;
    --bike-chart-secondary: #0f766e;
    --bike-chart-grid: #e6e8ec;
    --zone-1: #3b82f6;
    --zone-2: #22c55e;
    --zone-3: #eab308;
    --zone-4: #f97316;
    --zone-5: #dc2626;
    --bikestat-zone-1: var(--zone-1);
    --bikestat-zone-2: var(--zone-2);
    --bikestat-zone-3: var(--zone-3);
    --bikestat-zone-4: var(--zone-4);
    --bikestat-zone-5: var(--zone-5);
    --bikestat-zone-none: #94a3b8;
    --bikestat-speed-slow: #94a3b8;
    --bikestat-speed-1: #22c55e;
    --bikestat-speed-2: #a3e635;
    --bikestat-speed-3: #facc15;
    --bikestat-speed-4: #f97316;
    --bikestat-speed-5: #8b5cf6;
}

/* 2. Base */
body {
    background: var(--bike-bg);
    color: var(--bike-text);
    letter-spacing: 0;
}

a {
    font-weight: 500;
}

.btn {
    --bs-btn-border-radius: 0.5rem;
    font-weight: 600;
}

.btn-primary {
    --bs-btn-bg: var(--bike-primary);
    --bs-btn-border-color: var(--bike-primary);
    --bs-btn-hover-bg: #1d4ed8;
    --bs-btn-hover-border-color: #1d4ed8;
}

.btn-outline-secondary {
    --bs-btn-color: #475569;
    --bs-btn-border-color: #cbd5e1;
    --bs-btn-hover-bg: #f1f5f9;
    --bs-btn-hover-border-color: #94a3b8;
    --bs-btn-hover-color: #1f2937;
}

.strava-link {
    font-size: 1.15rem;
}

.activity-map {
    border: 1px solid var(--bike-border);
    border-radius: 0.75rem;
    height: 420px;
    overflow: hidden;
    width: 100%;
}

.heatmap-map {
    border: 1px solid var(--bike-border);
    border-radius: 0.75rem;
    height: min(72vh, 740px);
    min-height: 680px;
    overflow: hidden;
    width: 100%;
}

.route-event-icon {
    background: transparent;
    border: 0;
}

.route-event-marker {
    align-items: center;
    border: 2px solid #ffffff;
    border-radius: 999px;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.24);
    display: flex;
    font-size: 1.15rem;
    height: 32px;
    justify-content: center;
    line-height: 1;
    width: 32px;
}

.route-event-start {
    background: var(--bs-success);
    color: #ffffff;
}

.route-event-pause {
    background: var(--bs-warning);
    color: var(--bike-text);
}

.route-event-stop {
    background: var(--bs-danger);
    color: #ffffff;
}

.activity-map-legend {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--bike-border);
    border-radius: 0.5rem;
    box-shadow: var(--bike-shadow-sm);
    color: var(--bike-text);
    font-size: 0.75rem;
    line-height: 1.3;
    padding: 0.6rem 0.7rem;
}

.activity-map-legend-title {
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.activity-map-legend-row {
    align-items: center;
    display: flex;
    gap: 0.45rem;
    white-space: nowrap;
}

.activity-map-legend-swatch {
    border-radius: 999px;
    display: inline-block;
    flex: 0 0 auto;
    height: 0.7rem;
    width: 0.7rem;
}

.activity-map-legend-muted {
    color: var(--bike-muted);
    max-width: 13rem;
}

.alert {
    border-color: transparent;
    border-radius: 0.75rem;
}

.progress {
    --bs-progress-height: 0.55rem;
    --bs-progress-bg: #eef2f7;
    border-radius: 999px;
}

.progress-bar {
    background-color: var(--bike-primary);
}

code {
    color: #334155;
}

/* 3. Navbar */
.navbar {
    --bs-navbar-padding-y: 0.8rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--bike-shadow-sm);
}

.navbar-brand {
    align-items: center;
    display: inline-flex;
    gap: 0.55rem;
    letter-spacing: 0;
}

.brand-icon,
.app-page-icon,
.metric-icon,
.login-brand-icon {
    align-items: center;
    display: inline-flex;
    justify-content: center;
}

.brand-icon {
    background: var(--bike-primary-soft);
    border-radius: 0.6rem;
    color: var(--bike-primary);
    height: 2rem;
    width: 2rem;
}

.nav-link {
    align-items: center;
    border-radius: 0.5rem;
    display: inline-flex;
    font-weight: 600;
    gap: 0.4rem;
    padding-inline: 0.75rem;
}

.nav-link.active {
    background: var(--bike-primary-soft);
    color: var(--bike-primary) !important;
}

.user-menu-button {
    align-items: center;
    display: inline-flex;
    gap: 0.5rem;
    max-width: 100%;
}

.user-avatar {
    align-items: center;
    background: linear-gradient(135deg, var(--bike-secondary-soft), var(--bike-primary-soft));
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    color: #0f172a;
    display: inline-flex;
    flex: 0 0 auto;
    font-weight: 700;
    height: 1.8rem;
    justify-content: center;
    width: 1.8rem;
}

.user-name {
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-menu {
    border-color: var(--bike-border);
    border-radius: 0.75rem;
    box-shadow: var(--bike-shadow-md);
    padding: 0.45rem;
}

.dropdown-item {
    align-items: center;
    border-radius: 0.5rem;
    display: flex;
    gap: 0.55rem;
}

/* 4. Cards / metrics */
.app-page-header {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
}

.app-page-icon {
    background: var(--bike-primary-soft);
    border-radius: 0.75rem;
    color: var(--bike-primary);
    flex: 0 0 auto;
    font-size: 1.2rem;
    height: 2.75rem;
    width: 2.75rem;
}

.section-title {
    align-items: center;
    display: flex;
    gap: 0.55rem;
}

.section-title .bi {
    color: var(--bike-primary);
}

.dashboard-panel,
.form-panel,
.summary-card,
.card {
    background: var(--bike-surface);
    border: 1px solid var(--bike-border);
    box-shadow: var(--bike-shadow-sm);
}

.dashboard-panel,
.form-panel {
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.summary-card {
    border-radius: 0.75rem;
    padding: 1rem;
}

.metric-card {
    display: flex;
    gap: 0.85rem;
}

.metric-icon {
    border-radius: 0.65rem;
    flex: 0 0 auto;
    height: 2.35rem;
    width: 2.35rem;
}

.metric-primary {
    background: var(--bike-primary-soft);
    color: var(--bike-primary);
}

.metric-secondary {
    background: var(--bike-secondary-soft);
    color: var(--bike-secondary);
}

.metric-accent {
    background: #fef3c7;
    color: #b45309;
}

.metric-muted {
    background: #f1f5f9;
    color: #475569;
}

a.summary-card {
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

a.summary-card:hover {
    border-color: #b8c4d1;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

/* 5. Tables */
.table-responsive {
    border: 1px solid var(--bike-border);
    border-radius: 0.75rem;
}

.table {
    --bs-table-striped-bg: #f8fafc;
    --bs-table-hover-bg: #f1f5f9;
}

.table thead th {
    background: #f8fafc;
    color: #526071;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody td,
.table tbody th {
    border-color: var(--bike-border);
}

.description-cell {
    max-width: 18rem;
    overflow-wrap: anywhere;
    white-space: normal;
}

.activity-link {
    align-items: center;
    display: inline-flex;
    gap: 0.35rem;
}

/* 6. Forms */
.form-label {
    color: #475569;
    font-size: 0.88rem;
    font-weight: 700;
}

.form-control,
.form-select {
    border-color: #d9e0ea;
    border-radius: 0.5rem;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible,
.page-link:focus {
    border-color: var(--bike-primary);
    box-shadow: 0 0 0 0.2rem var(--bs-focus-ring-color);
}

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

/* 7. Badges / categories */
.category-badge,
.length-chip,
.soft-badge {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.78rem;
    font-weight: 700;
    gap: 0.35rem;
    line-height: 1.2;
    padding: 0.34rem 0.58rem;
    white-space: nowrap;
}

.category-recovery {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.category-z2,
.category-z2-like {
    background: #dbeafe;
    border-color: #bfdbfe;
    color: #1e40af;
}

.category-z2-dominant {
    background: #ccfbf1;
    border-color: #99f6e4;
    color: #115e59;
}

.category-mixed {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.category-intensive {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.category-none,
.length-chip,
.soft-badge {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

.coverage-excellent {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.coverage-good {
    background: #dbeafe;
    border-color: #bfdbfe;
    color: #1e40af;
}

.coverage-uncertain {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.coverage-insufficient,
.coverage-none {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

.status-danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.soft-alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #78350f;
}

.soft-alert-warning .alert-icon {
    color: #b45309;
    font-size: 1.35rem;
}

/* 8. Dashboard */
.chart-box {
    height: 280px;
}

.trend-mini-card {
    background: var(--bike-surface-muted);
    border: 1px solid var(--bike-border);
    border-radius: 0.65rem;
    padding: 0.75rem;
}

.progress-list .progress-bar {
    background: var(--bike-secondary);
}

.matrix-count {
    border-radius: 999px;
    display: inline-flex;
    min-width: 1.75rem;
    padding: 0.15rem 0.5rem;
    justify-content: center;
}

.training-plan-today > * {
    background: rgba(var(--bs-primary-rgb), 0.06) !important;
    box-shadow: inset 3px 0 0 rgba(var(--bs-primary-rgb), 0.7);
}

.today-badge {
    background: var(--bike-primary-soft);
    border-color: #bfdbfe;
    color: var(--bike-primary);
}

.training-plan-info {
    background: transparent;
    border: 0;
    color: var(--bike-muted);
    cursor: help;
    font-size: 0.9rem;
    margin-left: 0.35rem;
    padding: 0;
    vertical-align: middle;
}

.training-plan-info:hover,
.training-plan-info:focus {
    color: var(--bike-primary);
}

.coach-activity-card {
    box-shadow: none;
}

.coach-report-preview {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.88rem;
    min-height: 24rem;
    white-space: pre;
}

/* 9. Activity detail */
.zone-progress {
    background: #eef2f7;
    border-radius: 999px;
    height: 0.65rem;
    min-width: 8rem;
    overflow: hidden;
}

.zone-progress-bar {
    border-radius: inherit;
    height: 100%;
}

.zone-1 {
    background: var(--zone-1);
}

.zone-2 {
    background: var(--zone-2);
}

.zone-3 {
    background: var(--zone-3);
}

.zone-4 {
    background: var(--zone-4);
}

.zone-5 {
    background: var(--zone-5);
}

.zone-dot {
    border-radius: 50%;
    display: inline-block;
    height: 0.65rem;
    width: 0.65rem;
}

/* 10. Login / utilities / responsive */
.login-page {
    background: radial-gradient(circle at top, #e0f2fe 0, var(--bike-bg) 34rem);
}

.login-card {
    border-radius: 0.9rem;
    max-width: 420px;
}

.login-brand-icon {
    background: var(--bike-primary-soft);
    border-radius: 0.85rem;
    color: var(--bike-primary);
    font-size: 1.35rem;
    height: 3rem;
    width: 3rem;
}

.empty-state {
    background: var(--bike-surface-muted);
    border: 1px dashed #cbd5e1;
    border-radius: 0.75rem;
    color: var(--bike-muted);
    padding: 1.25rem;
}

.page-link {
    border-color: var(--bike-border);
    color: var(--bike-primary);
}

.active > .page-link,
.page-link.active {
    background-color: var(--bike-primary);
    border-color: var(--bike-primary);
}

@media (max-width: 575.98px) {
    .dashboard-panel,
    .form-panel {
        padding: 1rem;
    }

    .summary-card {
        padding: 0.85rem;
    }

    .app-page-header {
        gap: 0.75rem;
    }

    .app-page-icon {
        height: 2.35rem;
        width: 2.35rem;
    }

    .activity-map {
        height: 300px;
    }

    .heatmap-map {
        height: 60vh;
        min-height: 520px;
    }

    .user-name {
        max-width: 8rem;
    }
}
