:root {
    --primary: #1F4E79;
    --primary-hover: #2E75B6;
    --accent: #c0392b;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #e1e4e8;
    --success: #27ae60;
    --error: #c0392b;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    color: var(--primary);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Cards */
.card, .info-card, .chart-card, .stat-card {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.info-card h2, .chart-card h2 {
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    margin-top: 1rem;
}

.info-card h2:first-child {
    margin-top: 0;
}

.info-card ul {
    margin-left: 1.5rem;
    color: var(--text);
}

.info-card li {
    margin-bottom: 0.35rem;
}

.info-card p {
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* Upload form */
.upload-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.form-group {
    width: 100%;
    text-align: center;
}

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background-color: var(--bg);
    border: 2px dashed var(--primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--primary);
    font-weight: 500;
}

.file-label:hover {
    background-color: #e8f0f8;
    border-color: var(--primary-hover);
}

.file-icon {
    font-size: 1.3rem;
}

input[type="file"] {
    display: none;
}

.filename-display {
    display: block;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.filename-display.visible {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.alert-error {
    background-color: #fdecea;
    color: var(--error);
    border-left: 4px solid var(--error);
}

/* Actions bar */
.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

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

.stat-card {
    text-align: center;
    padding: 1.25rem;
    margin-bottom: 0;
}

.stat-card.highlight {
    background-color: var(--primary);
    color: white;
}

.stat-card.pause-card {
    background-color: #F5F0FF;
    border-left: 4px solid #8e44ad;
}

.stat-card.pause-card .stat-label {
    color: #6c3483;
    font-weight: 600;
}

.stat-card.pause-card .stat-value {
    color: #6c3483;
}

.stat-card.effort {
    background-color: #FFF8EC;
    border-left: 4px solid #E67E22;
}

.stat-card.effort .stat-label {
    color: #D35400;
    font-weight: 600;
}

.stat-card.effort .stat-value {
    color: #B9590F;
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-card.highlight .stat-label {
    color: rgba(255, 255, 255, 0.85);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card.highlight .stat-value {
    color: white;
}

/* Chart */
.chart-card {
    padding: 2rem;
}

.chart-container {
    position: relative;
    height: 480px;
    width: 100%;
}

.map-container {
    height: 420px;
    width: 100%;
    border-radius: 6px;
    z-index: 0;
}

/* Responsive */
@media (max-width: 640px) {
    header h1 {
        font-size: 1.5rem;
    }
    .chart-container {
        height: 340px;
    }
    .actions {
        flex-direction: column;
        align-items: stretch;
    }
    .btn {
        width: 100%;
        text-align: center;
    }
}

/* Badge sport */
.sport-badge {
    display: inline-block;
    background-color: var(--primary);
    color: white;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.5rem;
    letter-spacing: 0.02em;
}

/* Unités dans les cartes stats */
.stat-unit {
    font-size: 0.7em;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.15em;
}

.stat-card.highlight .stat-unit {
    color: rgba(255, 255, 255, 0.75);
}

/* Tableau des laps */
.table-wrapper {
    overflow-x: auto;
}

.laps-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.laps-table thead {
    background-color: var(--primary);
    color: white;
}

.laps-table th {
    padding: 0.7rem 0.8rem;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.laps-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.laps-table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.laps-table tbody tr:hover {
    background-color: #f0f4f8;
}

.laps-table td:first-child,
.laps-table th:first-child {
    font-weight: 600;
    text-align: center;
    width: 3rem;
}

/* ── Analyses récentes ── */
.recent-card h2 {
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.recent-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    background: var(--bg);
    transition: background 0.15s, border-color 0.15s;
    flex-wrap: wrap;
}

.recent-item:hover {
    background: #e8f0f8;
    border-color: var(--primary);
}

.recent-filename {
    font-weight: 500;
    font-size: 0.95rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-badges {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.sport-badge.small {
    font-size: 0.75rem;
    padding: 0.15rem 0.6rem;
}

.gps-badge {
    display: inline-block;
    background: #2ecc71;
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.recent-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.recent-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.recent-row .recent-item {
    flex: 1;
    min-width: 0;
}

.delete-form {
    flex-shrink: 0;
}

.btn-delete {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-delete:hover {
    background: #fdecea;
    color: var(--error);
    border-color: var(--error);
}

/* ── Profil utilisateur ── */
.profile-card {
    border-left: 4px solid var(--primary);
}

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

.profile-header h2 {
    color: var(--primary);
    font-size: 1.2rem;
    margin: 0;
}

.profile-hint {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0 0 1.25rem;
}

.profile-saved-badge {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
    background: #eafaf1;
    border: 1px solid #a9dfbf;
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    white-space: nowrap;
}

/* Sélecteur de mode : deux cartes côte à côte */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.mode-option {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.mode-option:hover {
    border-color: var(--primary-hover);
    background: #f4f8fd;
}

.mode-option.active {
    border-color: var(--primary);
    background: #eef4fb;
}

.mode-option-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.mode-option.active .mode-option-title {
    color: var(--primary);
}

.mode-option-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Panneau de champs */
.profile-panel {
    margin-bottom: 1.25rem;
}

.profile-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.field-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}

.unit {
    font-weight: 400;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.field-group input[type="number"] {
    padding: 0.5rem 0.7rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.field-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.1);
}

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

/* Boutons radio sexe */
.sex-toggle {
    display: flex;
    gap: 0.5rem;
}

.sex-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.sex-btn input[type="radio"] {
    accent-color: var(--primary);
}

.sex-btn:has(input:checked) {
    border-color: var(--primary);
    background: #eef4fb;
    color: var(--primary);
    font-weight: 500;
}

/* Encadré des estimations */
.estimates-box {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    padding: 0.85rem 1rem;
    background: #f8fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}

.estimate-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

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

.estimate-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
}

.estimates-note {
    flex: 1 1 100%;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
    font-style: italic;
}

.profile-footer {
    margin-top: 1.25rem;
}

.btn-save-profile {
    padding: 0.6rem 1.4rem;
    border-radius: 6px;
    border: 2px solid var(--primary);
    background: var(--primary);
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-save-profile:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* ── Zones FC ── */
.zones-card h2 {
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 0.4rem;
}

.zone-method-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.75rem;
}

.zone-default-notice {
    font-size: 0.85rem;
    color: #856404;
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-radius: 6px;
    padding: 0.5rem 0.85rem;
    margin-bottom: 1rem;
}

.zone-default-notice a {
    color: var(--primary);
    text-decoration: underline;
}

.zones-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.zones-table thead {
    background-color: var(--primary);
    color: white;
}

.zones-table th {
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.zones-table td {
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.zones-table tbody tr:nth-child(even) { background: #fafbfc; }
.zones-table tbody tr:hover { background: #f0f4f8; }

.zone-badge {
    display: inline-block;
    color: white;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
}

.zone-desc { color: var(--text); font-size: 0.85rem; }
.zone-range { white-space: nowrap; color: var(--text-muted); font-size: 0.85rem; }
.zone-time { white-space: nowrap; font-variant-numeric: tabular-nums; }

.col-pct { min-width: 140px; }

.zone-bar-outer {
    background: #e8ecef;
    border-radius: 4px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 0.2rem;
}

.zone-bar-inner {
    height: 100%;
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.4s ease;
}

.zone-pct {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.zone-comment {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    background: #f0f7ff;
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
}

.zone-comment-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    line-height: 1.5;
}

.zone-comment p {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text);
}

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

.zone-cta a {
    color: var(--primary);
    text-decoration: underline;
}

@media (max-width: 640px) {
    .mode-selector { grid-template-columns: 1fr; }
    .profile-fields { grid-template-columns: 1fr 1fr; }
    .zone-desc { display: none; }
    .col-pct { min-width: 90px; }
}
