/* ============================================================
   PariSelect - CSS Principal
   Design premium dark, mobile-first PWA
   ============================================================ */

:root {
    --bg-primary: #0a0e1a;
    --bg-card: #12172a;
    --bg-card-hover: #181e35;
    --bg-input: #0d1220;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --text-primary: #f0f0f0;
    --text-secondary: #8892a4;
    --text-muted: #5a6477;
    --accent: #00d4aa;
    --accent-blue: #0099ff;
    --accent-gold: #ffd700;
    --accent-orange: #ff9f43;
    --danger: #ff4757;
    --success: #00d4aa;
    --gradient: linear-gradient(135deg, #00d4aa, #0099ff);
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --nav-height: 70px;
    --header-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }

/* Legal Bar */
.legal-bar {
    background: #080b14;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-align: center;
    padding: 4px 12px;
    border-bottom: 1px solid var(--border);
}
.legal-bar a { color: var(--accent); }

/* Header */
.top-header {
    background: rgba(10,14,26,0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-primary);
}
.logo-icon { font-size: 1.4rem; }
.logo-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-plan-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.plan-free { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
.plan-pro { background: rgba(0,212,170,0.15); color: var(--accent); }
.plan-premium { background: rgba(255,215,0,0.15); color: var(--accent-gold); }
.user-bankroll {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
}
.header-admin-link {
    font-size: 0.8rem;
    color: var(--accent-orange);
    font-weight: 600;
}
.btn-header-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255,71,87,0.1);
    color: var(--danger);
    transition: all 0.2s;
}
.btn-header-logout:hover {
    background: rgba(255,71,87,0.25);
}
.btn-header-login {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.btn-header-register {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 10px;
    background: var(--gradient);
    color: var(--bg-primary);
}

/* Main */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
    min-height: calc(100vh - 200px);
}
.main-content.has-nav { padding-bottom: calc(var(--nav-height) + 20px); }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(12,17,30,0.97);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    transition: color 0.2s;
    padding: 8px;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }
.nav-item:active { transform: scale(0.95); }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-hover); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}
.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Recommendation Cards */
.reco-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}
.reco-card.confidence-high { border-left: 3px solid var(--accent); }
.reco-card.confidence-medium { border-left: 3px solid var(--accent-orange); }
.reco-card.confidence-gold {
    border-left: 3px solid var(--accent-gold);
    background: linear-gradient(135deg, rgba(255,215,0,0.03), var(--bg-card));
}
.reco-card.no-bet {
    border-left: 3px solid var(--danger);
    opacity: 0.6;
}
.reco-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-gold { background: rgba(255,215,0,0.15); color: var(--accent-gold); }
.badge-value { background: rgba(0,212,170,0.15); color: var(--accent); }
.badge-best { background: rgba(0,153,255,0.15); color: var(--accent-blue); }
.badge-nobet { background: rgba(255,71,87,0.15); color: var(--danger); }
.badge-sport {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
}

.reco-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}
.reco-sport { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.reco-event { font-weight: 700; font-size: 1rem; margin: 4px 0; }
.reco-time { font-size: 0.8rem; color: var(--text-secondary); }
.reco-details {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0;
}
.reco-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.reco-detail strong { color: var(--text-primary); }
.reco-selections {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 10px 0;
}
.reco-selections .horse-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(0,212,170,0.15);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    margin-right: 6px;
}
.reco-selections .horse-num.pilier { background: rgba(0,153,255,0.2); color: var(--accent-blue); }
.reco-selections .horse-num.outsider { background: rgba(255,215,0,0.15); color: var(--accent-gold); }

.confidence-bar {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}
.confidence-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--gradient);
    color: var(--bg-primary);
}
.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(0,212,170,0.25);
}
.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-gold {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: var(--bg-primary);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-lg { padding: 16px 32px; font-size: 1rem; }
.btn-pmu {
    background: #006b3f;
    color: #fff;
    font-weight: 700;
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent);
}
.form-input::placeholder { color: var(--text-muted); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
}
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }
.stat-value.gold { color: var(--accent-gold); }
.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title {
    font-size: 1.15rem;
    font-weight: 700;
}
.section-action {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    line-height: 1.5;
}
.alert-success { background: rgba(0,212,170,0.1); border: 1px solid rgba(0,212,170,0.2); color: var(--accent); }
.alert-warning { background: rgba(255,159,67,0.1); border: 1px solid rgba(255,159,67,0.2); color: var(--accent-orange); }
.alert-danger { background: rgba(255,71,87,0.1); border: 1px solid rgba(255,71,87,0.2); color: var(--danger); }
.alert-info { background: rgba(0,153,255,0.1); border: 1px solid rgba(0,153,255,0.2); color: var(--accent-blue); }
.alert-gold {
    background: linear-gradient(135deg, rgba(255,215,0,0.08), rgba(255,170,0,0.05));
    border: 1px solid rgba(255,215,0,0.2);
    color: var(--accent-gold);
}

/* Day Off Banner */
.day-off-banner {
    background: linear-gradient(135deg, rgba(255,71,87,0.1), rgba(255,71,87,0.05));
    border: 1px solid rgba(255,71,87,0.2);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}
.day-off-banner .emoji { font-size: 2rem; margin-bottom: 8px; }
.day-off-banner h3 { color: var(--danger); margin-bottom: 8px; }
.day-off-banner p { color: var(--text-secondary); font-size: 0.9rem; }

/* Best Bet Highlight */
.best-bet-card {
    background: linear-gradient(135deg, rgba(0,212,170,0.08), rgba(0,153,255,0.05));
    border: 2px solid rgba(0,212,170,0.3);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
}
.best-bet-card::before {
    content: "⭐ BEST BET";
    position: absolute;
    top: -10px;
    left: 16px;
    background: var(--gradient);
    color: var(--bg-primary);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: 6px;
    letter-spacing: 1px;
}

/* Pricing Cards */
.pricing-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
.pricing-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    position: relative;
}
.pricing-card.featured {
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(0,212,170,0.05), var(--bg-card));
}
.pricing-card.featured::before {
    content: "POPULAIRE";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gradient);
    color: var(--bg-primary);
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 14px;
    border-radius: 6px;
    letter-spacing: 1px;
}
.pricing-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.pricing-price {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent);
    margin: 12px 0;
}
.pricing-price span { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
.pricing-features { list-style: none; text-align: left; margin: 20px 0; }
.pricing-features li {
    padding: 8px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.pricing-features li::before { content: "✓"; color: var(--accent); font-weight: 700; }
.pricing-features li.disabled { opacity: 0.4; }
.pricing-features li.disabled::before { content: "✗"; color: var(--danger); }

/* Tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
}
table th, table td {
    padding: 10px 12px;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
table tbody tr:hover { background: var(--bg-card-hover); }

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 16px;
}
.mode-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
    font-family: var(--font);
}
.mode-btn.active {
    background: var(--gradient);
    color: var(--bg-primary);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* Footer */
.site-footer {
    background: #080b14;
    border-top: 1px solid var(--border);
    padding: 40px 16px 100px;
    margin-top: 40px;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}
.footer-brand {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 8px;
}
.footer-tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 20px;
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}
.footer-links a {
    color: var(--text-secondary);
    font-size: 0.8rem;
}
.footer-links a:hover { color: var(--accent); }
.footer-legal {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.8;
    max-width: 600px;
    margin: 0 auto 16px;
}
.footer-affiliate { margin-top: 16px; }
.footer-affiliate a {
    display: inline-flex;
    padding: 10px 20px;
    background: #006b3f;
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 350px;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }
.toast-success { background: rgba(0,212,170,0.95); color: var(--bg-primary); }
.toast-error { background: rgba(255,71,87,0.95); color: #fff; }

/* ============================================================
   RESPONSIVE & MODE APP MOBILE
   ============================================================ */

/* Mobile-first : tablette et au-delà */
@media (min-width: 768px) {
    .bottom-nav { display: none; }
    .main-content.has-nav { padding-bottom: 20px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .pricing-grid { grid-template-columns: repeat(3, 1fr); }
    .reco-details { gap: 20px; }
}

@media (min-width: 1024px) {
    .main-content { padding: 30px 24px; }
}

/* ============================================================
   MOBILE FIN (≤480px) - Optimisations PWA / mode App
   ============================================================ */
@media (max-width: 480px) {
    html { font-size: 15px; }

    /* Headers plus petits */
    .top-header { height: 52px; }
    .legal-bar { font-size: 0.65rem; padding: 3px 10px; }

    /* Cards moins de padding */
    .card { padding: 14px; margin-bottom: 12px; }
    .reco-card { padding: 12px; }

    /* Stats grid plus serré */
    .stats-grid { gap: 8px; }
    .admin-stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .admin-stat { padding: 12px !important; }
    .admin-stat .val { font-size: 1.2rem !important; }
    .admin-stat .lbl { font-size: 0.7rem !important; }

    /* Pricing pleine largeur */
    .pricing-card { padding: 20px 16px; }

    /* Tables : scroll horizontal forcé + indicateur visuel */
    .table-responsive {
        margin: 0 -14px;
        padding: 0 14px;
        position: relative;
    }
    .table-responsive table {
        min-width: 100%;
        font-size: 0.78rem;
    }
    .table-responsive th, .table-responsive td {
        padding: 8px 6px !important;
        white-space: nowrap;
    }

    /* Forms : inputs + gros (évite le zoom iOS sur focus) */
    .form-input, .form-select {
        font-size: 16px; /* CRITIQUE iOS : <16px = auto-zoom */
        padding: 13px 14px;
    }

    /* Boutons : touch target 44px minimum */
    .btn { min-height: 44px; padding: 12px 20px; }
    .btn-sm { min-height: 38px; padding: 10px 14px; font-size: 0.8rem; }
    .btn-lg { min-height: 52px; padding: 16px 28px; }
}

/* ============================================================
   BOTTOM NAV MOBILE - Touch targets ≥48px + Safe Area iPhone
   ============================================================ */
.bottom-nav {
    /* Safe area iPhone (notch + home indicator) */
    padding-bottom: max(env(safe-area-inset-bottom), 4px);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
}
.nav-item {
    min-height: 48px;
    min-width: 48px;
    flex: 1;
    padding: 6px 4px;
    -webkit-tap-highlight-color: transparent;
}
.nav-item:active {
    background: rgba(0,212,170,0.08);
    border-radius: 8px;
}

/* ============================================================
   MODE APP / PWA standalone
   Détecté quand l'app est installée et lancée hors navigateur
   ============================================================ */
@media all and (display-mode: standalone) {
    /* Cache la barre légale en haut (gain d'espace) en mode App */
    .legal-bar { display: none; }
    /* Plus de safe-area padding en haut */
    body { padding-top: env(safe-area-inset-top); }
    /* Désactive le pull-to-refresh natif qui est gênant */
    html, body { overscroll-behavior-y: contain; }
}

/* ============================================================
   ACCESSIBILITÉ TOUCH GLOBALE
   ============================================================ */
button, a, [role="button"] {
    -webkit-tap-highlight-color: rgba(0,212,170,0.15);
    touch-action: manipulation; /* élimine le délai de 300ms du double-tap zoom */
}

/* Inputs natifs iOS : virer le styling par défaut */
input, select, textarea, button {
    -webkit-appearance: none;
    appearance: none;
    -moz-appearance: none;
}

/* Empêche le scroll en arrière-plan quand un modal est ouvert */
body.modal-open { overflow: hidden; position: fixed; width: 100%; }

/* Animations plus rapides sur mobile (économie batterie) */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
