/* ==============================================
   RUNAPACE.CSS — Design System Light
   ============================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700;9..40,800;9..40,900&display=swap');

/* =============================================
   VARIABLES — LIGHT MODE (défaut)
   ============================================= */
:root {
    /* Brand */
    --rp-blue:        #2A5BA8;
    --rp-blue-lt:     #4A8BD4;
    --rp-blue-dk:     #1A3A72;
    --rp-coral:       #E8445A;
    --rp-coral-lt:    #FF6B7A;
    --rp-coral-bg:    rgba(232,68,90,0.08);

    /* Backgrounds — light */
    --rp-bg:          #F4F6FA;
    --rp-bg-white:    #FFFFFF;
    --rp-card:        #FFFFFF;
    --rp-card-alt:    #F0F4F9;
    --rp-nav:         #FFFFFF;

    /* Text */
    --rp-text:        #1A2B4A;
    --rp-text-body:   #3D5472;
    --rp-muted:       #7A98B8;

    /* Borders */
    --rp-border:      rgba(26,43,74,0.10);
    --rp-border-h:    rgba(26,43,74,0.25);
    --rp-border-c:    rgba(232,68,90,0.30);

    /* Effects */
    --rp-shadow:      0 2px 12px rgba(26,43,74,0.08);
    --rp-shadow-md:   0 4px 24px rgba(26,43,74,0.10);
    --rp-shadow-lg:   0 8px 40px rgba(26,43,74,0.14);
    --rp-radius:      12px;
    --rp-radius-sm:   8px;
    --rp-radius-lg:   18px;

    /* Strava */
    --strava:         #FC4C02;

    /* Fonts */
    --font-body:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-title:     'DM Sans', 'Inter', sans-serif;

    /* Compat aliases */
    --text:           #1A2B4A;
    --text-body:      #3D5472;
    --text-muted:     #7A98B8;
    --bg-card:        #FFFFFF;
    --bg-alt:         #F0F4F9;
    --border:         rgba(26,43,74,0.10);
    --border-h:       rgba(26,43,74,0.25);
    --shadow:         0 2px 12px rgba(26,43,74,0.08);
    --green:          #1A9E5C;
    --orange:         #E07020;
    --cyan:           #0A8E9E;
    --violet:         #6040C8;
    --pink:           #E8445A;

    /* SD compat */
    --sd-bg:          #F4F6FA;
    --sd-card:        #FFFFFF;
    --sd-text:        #1A2B4A;
    --sd-muted:       #7A98B8;
    --sd-border:      rgba(26,43,74,0.10);
    --sd-border-h:    rgba(26,43,74,0.25);
    --sd-border-sub:  rgba(26,43,74,0.18);
    --sd-shadow:      0 2px 12px rgba(26,43,74,0.08);
    --sd-shadow-lg:   0 8px 40px rgba(26,43,74,0.14);
    --sd-radius:      12px;
    --sd-radius-sm:   8px;
    --sd-yellow:      #E8445A;
    --sd-green:       #2A5BA8;
}

/* =============================================
   VARIABLES — DARK MODE
   ============================================= */
html[data-theme="dark"] {
    /* Backgrounds */
    --rp-bg:          #0D1526;
    --rp-bg-white:    #1A2540;
    --rp-card:        #1A2540;
    --rp-card-alt:    #0F1A30;
    --rp-nav:         rgba(18,28,52,0.96);

    /* Text */
    --rp-text:        #E8EEF8;
    --rp-text-body:   #A8BDD4;
    --rp-muted:       #5A7A9A;

    /* Borders */
    --rp-border:      rgba(255,255,255,0.08);
    --rp-border-h:    rgba(255,255,255,0.18);
    --rp-border-c:    rgba(232,68,90,0.35);

    /* Effects */
    --rp-shadow:      0 2px 12px rgba(0,0,0,0.30);
    --rp-shadow-md:   0 4px 24px rgba(0,0,0,0.40);
    --rp-shadow-lg:   0 8px 40px rgba(0,0,0,0.50);

    /* Compat aliases */
    --text:           #E8EEF8;
    --text-body:      #A8BDD4;
    --text-muted:     #5A7A9A;
    --bg-card:        #1A2540;
    --bg-alt:         #0F1A30;
    --border:         rgba(255,255,255,0.08);
    --border-h:       rgba(255,255,255,0.18);
    --shadow:         0 2px 12px rgba(0,0,0,0.30);

    /* SD compat */
    --sd-bg:          #0D1526;
    --sd-card:        #1A2540;
    --sd-text:        #E8EEF8;
    --sd-muted:       #5A7A9A;
    --sd-border:      rgba(255,255,255,0.08);
    --sd-border-h:    rgba(255,255,255,0.18);
    --sd-border-sub:  rgba(255,255,255,0.12);
    --sd-shadow:      0 2px 12px rgba(0,0,0,0.30);
    --sd-shadow-lg:   0 8px 40px rgba(0,0,0,0.50);
}


html[data-theme="dark"] .dark-invert {
    background: #1A2540;
    border-color: rgba(255,255,255,0.10);
    color: #A8BDD4;
}

html[data-theme="dark"] .flash {
    background: #1A2540;
    color: #E8EEF8;
}

/* =============================================
   RESET
   ============================================= */
*, *::before, *::after { box-sizing: border-box; }

/* =============================================
   BASE
   ============================================= */
html {
    background: var(--rp-bg);
    overflow-x: clip;
}

html[data-theme="dark"] { background: #0D1526; }

body {
    background: var(--rp-bg);
    color: var(--rp-text);
    font-family: var(--font-body);
    line-height: 1.6;
    margin: 0;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   LOGO — utilise le fichier image
   ============================================= */
.rp-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.rp-logo-img {
    height: 34px;
    width: auto;
    display: block;
}

/* Fallback texte si image absente */
.rp-logo-text {
    font-family: var(--font-title);
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1;
}
.rp-logo-run  { color: #E8445A; }
.rp-logo-pace { color: #2A5BA8; }

/* =============================================
   NAVIGATION
   ============================================= */
.rp-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: 64px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--rp-nav);
    box-shadow: 0 1px 0 var(--rp-border), 0 4px 16px rgba(26,43,74,0.06);
}

.rp-nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.rp-nav-link {
    color: var(--rp-text-body);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.rp-nav-link:hover  { background: var(--rp-card-alt); color: var(--rp-text); }
.rp-nav-link.active { background: var(--rp-coral-bg); color: var(--rp-coral); font-weight: 600; }

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

/* =============================================
   BOUTONS
   ============================================= */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    background: var(--rp-coral);
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    border: none;
    border-radius: var(--rp-radius-sm);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-primary:hover {
    background: var(--rp-coral-lt);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(232,68,90,0.35);
    color: #fff;
}
.btn-primary.btn-lg { padding: 0.85rem 2.2rem; font-size: 1rem; }

.btn-blue {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    background: var(--rp-blue);
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    border: none;
    border-radius: var(--rp-radius-sm);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-blue:hover {
    background: var(--rp-blue-lt);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(42,91,168,0.30);
    color: #fff;
}
.btn-blue.btn-lg { padding: 0.85rem 2.2rem; font-size: 1rem; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    background: transparent;
    color: var(--rp-blue);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    border: 1.5px solid var(--rp-blue);
    border-radius: var(--rp-radius-sm);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}
.btn-outline:hover {
    background: rgba(42,91,168,0.06);
    transform: translateY(-1px);
    color: var(--rp-blue);
}
.btn-outline.btn-lg { padding: 0.85rem 2.2rem; font-size: 1rem; }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    background: transparent;
    color: var(--rp-muted);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--rp-radius-sm);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.btn-ghost:hover { color: var(--rp-text); background: var(--rp-card-alt); }

.btn-strava {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    background: #FC4C02;
    color: white;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    border: none;
    border-radius: var(--rp-radius-sm);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-strava:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(252,76,2,0.35);
    color: white;
}

/* =============================================
   CARDS
   ============================================= */
.rp-card, .sd-card {
    background: var(--rp-card);
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    box-shadow: var(--rp-shadow);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.rp-card:hover, .sd-card:hover {
    box-shadow: var(--rp-shadow-md);
    border-color: var(--rp-border-h);
}
.rp-card-padded, .sd-card-padded { padding: 1.5rem; }

/* =============================================
   BADGES
   ============================================= */
.rp-badge, .sd-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 4px;
}

.badge-ef     { background: rgba(10,142,158,0.10); color:#0A8E9E;  border:1px solid rgba(10,142,158,0.22); }
.badge-seuil  { background: rgba(224,112,32,0.10); color:#E07020;  border:1px solid rgba(224,112,32,0.22); }
.badge-vma    { background: rgba(232,68,90,0.10);  color:#E8445A;  border:1px solid rgba(232,68,90,0.22); }
.badge-sl     { background: rgba(26,158,92,0.10);  color:#1A9E5C;  border:1px solid rgba(26,158,92,0.22); }
.badge-recup  { background: rgba(122,152,184,0.10);color:#7A98B8;  border:1px solid rgba(122,152,184,0.22); }
.badge-force  { background: rgba(42,91,168,0.10);  color:#2A5BA8;  border:1px solid rgba(42,91,168,0.22); }
.badge-repos  { background: rgba(26,43,74,0.06);   color:#7A98B8;  border:1px solid rgba(26,43,74,0.12); }

/* =============================================
   FLASH MESSAGES
   ============================================= */
.flash {
    position: fixed;
    top: 76px; right: 16px;
    z-index: 5000;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    background: #FFFFFF;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius-sm);
    color: var(--rp-text);
    box-shadow: var(--rp-shadow-md);
    animation: rp-slideIn 0.3s ease;
    max-width: 360px;
}
.flash-success { border-left: 3px solid #1A9E5C; }
.flash-error   { border-left: 3px solid #E8445A; }
.flash-warning { border-left: 3px solid #E07020; }
.flash-info    { border-left: 3px solid #2A5BA8; }

@keyframes rp-slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}


/* =============================================
   LAYOUT UTILITAIRES
   ============================================= */
.rp-section  { padding: 5rem 2rem; }
.rp-container, .sd-container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.rp-section-label {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--rp-coral);
    margin-bottom: 0.75rem;
}

.rp-section-title {
    font-family: var(--font-title);
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--rp-text);
    margin: 0 0 0.75rem;
    line-height: 1.15;
}

.rp-section-desc {
    font-size: 1rem;
    color: var(--rp-muted);
    line-height: 1.7;
    max-width: 580px;
}

/* Accent diagonal — élément dynamique */
.rp-slash {
    display: inline-block;
    width: 4px;
    height: 28px;
    background: var(--rp-coral);
    border-radius: 2px;
    transform: skewX(-12deg);
    margin-right: 6px;
    vertical-align: middle;
}

/* Pill tags */
.rp-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: var(--rp-card-alt);
    border: 1px solid var(--rp-border);
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--rp-text-body);
}

/* =============================================
   DARK MODE — base body override
   (couvre les color: #1A2B4A hardcodés dans les templates)
   ============================================= */
html[data-theme="dark"] body {
    background: #0D1526;
    color: #E8EEF8;
}

/* =============================================
   DARK MODE — overrides pour les éléments communs
   ============================================= */

/* Cards et containers blancs hardcodés dans les templates */
html[data-theme="dark"] .activity-header,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .coach-section,
html[data-theme="dark"] .analysis-card,
html[data-theme="dark"] .coach-advice-box,
html[data-theme="dark"] .user-feedback-display,
html[data-theme="dark"] .ai-response-display,
html[data-theme="dark"] .ai-response-advice {
    background: #1A2540;
    border-color: rgba(255,255,255,0.08);
}

html[data-theme="dark"] .analysis-card {
    background: #0F1A30;
}

html[data-theme="dark"] .coach-advice-box {
    background: rgba(42,91,168,0.12);
    border-color: rgba(42,91,168,0.30);
}

html[data-theme="dark"] .user-feedback-display {
    background: rgba(124,58,237,0.10);
    border-color: rgba(124,58,237,0.25);
}

html[data-theme="dark"] .ai-response-display {
    background: rgba(42,91,168,0.10);
    border-color: rgba(42,91,168,0.25);
}

html[data-theme="dark"] .ai-response-advice {
    background: #0F1A30;
}

html[data-theme="dark"] .back-btn {
    background: #1A2540;
    color: #A8BDD4;
    border-color: rgba(255,255,255,0.10);
}

html[data-theme="dark"] .back-btn:hover { color: #4A8BD4; border-color: #2A5BA8; }

/* Textes */
html[data-theme="dark"] .activity-header h1,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .fatigue-value,
html[data-theme="dark"] .feedback-title { color: #E8EEF8; }

html[data-theme="dark"] .activity-date,
html[data-theme="dark"] .metric-label,
html[data-theme="dark"] .analysis-card h3,
html[data-theme="dark"] .loading-text,
html[data-theme="dark"] .ai-response-advice-label { color: #5A7A9A; }

html[data-theme="dark"] .analysis-text,
html[data-theme="dark"] .coach-advice-text,
html[data-theme="dark"] .analysis-list li,
html[data-theme="dark"] .user-feedback-text,
html[data-theme="dark"] .ai-response-text { color: #A8BDD4; }

/* Fatigue bar track */
html[data-theme="dark"] .fatigue-bar { background: rgba(255,255,255,0.08); }

/* Analysis list separators */
html[data-theme="dark"] .analysis-list li { border-bottom-color: rgba(255,255,255,0.06); }

/* Feedback input */
html[data-theme="dark"] .feedback-input {
    background: #0F1A30;
    border-color: rgba(255,255,255,0.10);
    color: #E8EEF8;
}

html[data-theme="dark"] .feedback-input::placeholder { color: #5A7A9A; }
html[data-theme="dark"] .feedback-input:focus { border-color: #7C3AED; }

/* Feedback section separator */
html[data-theme="dark"] .feedback-section { border-top-color: rgba(255,255,255,0.08); }

/* Loading spinner */
html[data-theme="dark"] .loading-spinner {
    border-color: rgba(255,255,255,0.08);
    border-top-color: #4A8BD4;
}

/* Error state */
html[data-theme="dark"] .error-state { color: #FF6B7A; }

/* Auth cards (login/register) */
html[data-theme="dark"] .auth-card {
    background: #1A2540;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}

html[data-theme="dark"] .auth-title .pace { color: #A8BDD4; }
html[data-theme="dark"] .auth-subtitle    { color: #5A7A9A; }
html[data-theme="dark"] .auth-footer      { color: #5A7A9A; border-top-color: rgba(255,255,255,0.08); }
html[data-theme="dark"] .auth-footer a    { color: #4A8BD4; }
html[data-theme="dark"] .auth-hint        { color: #5A7A9A; background: rgba(42,91,168,0.08); border-color: rgba(42,91,168,0.18); }

html[data-theme="dark"] .form-label { color: #5A7A9A; }

html[data-theme="dark"] .form-input {
    background: #0F1A30;
    border-color: rgba(255,255,255,0.10);
    color: #E8EEF8;
}

html[data-theme="dark"] .form-input::placeholder { color: #5A7A9A; }
html[data-theme="dark"] .form-input:focus { border-color: #2A5BA8; box-shadow: 0 0 0 3px rgba(42,91,168,0.25); }

/* =============================================
   DARK MODE — Dashboard
   ============================================= */
html[data-theme="dark"] .hero-banner,
html[data-theme="dark"] .rp-card,
html[data-theme="dark"] .generate-card,
html[data-theme="dark"] .program-status-card,
html[data-theme="dark"] .next-session-card,
html[data-theme="dark"] .strava-card,
html[data-theme="dark"] .pro-card,
html[data-theme="dark"] .stats-card,
html[data-theme="dark"] .flash-message {
    background: #1A2540;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 2px 12px rgba(0,0,0,0.30);
}

html[data-theme="dark"] .activity-row {
    background: #1A2540;
    border-color: rgba(255,255,255,0.07);
}

html[data-theme="dark"] .activity-row:hover {
    background: #1F2D50;
    border-color: rgba(255,255,255,0.12);
}

html[data-theme="dark"] .hero-banner::before {
    opacity: 0.6;
}

/* Textes dashboard */
html[data-theme="dark"] .hero-greeting,
html[data-theme="dark"] .hero-name,
html[data-theme="dark"] .section-label-text,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .next-session-name,
html[data-theme="dark"] .stat-value { color: #E8EEF8; }

html[data-theme="dark"] .hero-subtitle,
html[data-theme="dark"] .hero-meta,
html[data-theme="dark"] .card-subtitle,
html[data-theme="dark"] .activity-name,
html[data-theme="dark"] .stat-label,
html[data-theme="dark"] .next-session-meta { color: #A8BDD4; }

/* Borders dans dashboard */
html[data-theme="dark"] .week-day-label,
html[data-theme="dark"] .section-divider { border-color: rgba(255,255,255,0.07); }

/* Input génération programme */
html[data-theme="dark"] select,
html[data-theme="dark"] .form-select {
    background: #0F1A30;
    border-color: rgba(255,255,255,0.10);
    color: #E8EEF8;
}

/* =============================================
   NAV USER WIDGET
   ============================================= */
.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-user-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--rp-muted);
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--rp-border);
    border-radius: 6px;
    color: var(--rp-muted);
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    background: transparent;
    flex-shrink: 0;
}

.nav-logout:hover {
    color: var(--rp-coral);
    border-color: rgba(232,68,90,0.35);
    background: rgba(232,68,90,0.05);
}

.nav-logout svg { width: 15px; height: 15px; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .rp-nav { padding: 0 1rem; }
    .rp-nav-links { display: none; }
    .rp-section { padding: 3rem 1.25rem; }
}
