/* =====================================================================
   Composants réutilisables
   ===================================================================== */

/* ---- Cartes et grilles ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4);
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-title h2, .card-title h3 { font-size: 1rem; }
.card-flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: var(--space-4); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 640px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .card { padding: var(--space-5); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}
.section-head { display: flex; align-items: end; justify-content: space-between; gap: var(--space-3); margin: var(--space-6) 0 var(--space-3); }
.section-head:first-child { margin-top: 0; }

/* ---- Indicateurs ---- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 550; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: .82rem; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: var(--space-2); }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.is-full > span { background: var(--amber); }

/* ---- Boutons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 44px; padding: 0 var(--space-4);
    border-radius: 12px; border: 1px solid transparent;
    font-weight: 600; font-size: .93rem; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: rgba(248, 113, 113, .3); }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: .86rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .55; cursor: not-allowed; }
.btn.is-loading::after {
    content: ""; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Formulaires ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--space-4); }
.label { font-size: .86rem; font-weight: 600; color: var(--text-2); }
.hint { font-size: .8rem; color: var(--muted); }
.input, .select, .textarea {
    width: 100%; min-height: 46px; padding: 10px 14px;
    background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px;
    font-size: 16px; /* évite le zoom automatique sur iOS */
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-invalid { border-color: var(--red); }
.error-text { color: var(--red); font-size: .82rem; }
.checkbox { display: flex; align-items: flex-start; gap: var(--space-2); font-size: .9rem; color: var(--text-2); cursor: pointer; }
.checkbox input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.form-row { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-row { grid-template-columns: 1fr 1fr; } }

/* Pastilles à cocher (marchés, compétitions) */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
    display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2);
    color: var(--text-2); font-size: .88rem; font-weight: 550; user-select: none;
}
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip input:disabled + span { opacity: .45; }
.chip .lock { font-size: .72rem; color: var(--muted); }

/* Sélecteur segmenté (profils de risque) */
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
@media (min-width: 640px) { .segmented { grid-template-columns: repeat(5, 1fr); } }
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segment span {
    display: flex; flex-direction: column; gap: 2px; height: 100%;
    padding: var(--space-3); border-radius: 12px; border: 1px solid var(--line-strong);
    background: var(--surface-2); font-weight: 600; font-size: .9rem;
}
.segment small { color: var(--muted); font-weight: 450; font-size: .76rem; line-height: 1.35; }
.segment input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.segment input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.segment input:disabled + span { opacity: .45; }

.range { width: 100%; accent-color: var(--accent); }

/* ---- Alertes et badges ---- */
.alert {
    display: flex; align-items: flex-start; gap: var(--space-3);
    padding: var(--space-3) var(--space-4); border-radius: 12px; margin-bottom: var(--space-4);
    border: 1px solid; font-size: .92rem;
}
.alert p { flex: 1; }
.alert-success { background: var(--green-soft); border-color: rgba(52, 211, 153, .3); color: #b5f3da; }
.alert-info { background: rgba(96, 165, 250, .1); border-color: rgba(96, 165, 250, .3); color: #cfe2fd; }
.alert-error { background: var(--red-soft); border-color: rgba(248, 113, 113, .3); color: #fecaca; }
.alert-warning { background: var(--amber-soft); border-color: rgba(251, 191, 36, .3); color: #fde9b0; }
.alert-close { background: none; border: 0; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; opacity: .7; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 650;
    background: var(--surface-3); color: var(--text-2);
}
.badge-accent, .badge-profile-balanced { background: var(--accent-soft); color: var(--accent); }
.badge-profile-prudent { background: var(--green-soft); color: var(--green); }
.badge-profile-bold { background: var(--red-soft); color: var(--red); }
.badge-profile-target, .badge-profile-custom { background: rgba(96, 165, 250, .14); color: var(--blue); }

.status { font-size: .78rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-pending { background: var(--surface-3); color: var(--text-2); }
.status-won { background: var(--green-soft); color: var(--green); }
.status-lost { background: var(--red-soft); color: var(--red); }
.status-void { background: var(--amber-soft); color: var(--amber); }

.conf { font-size: .74rem; font-weight: 600; }
.conf-high { color: var(--green); }
.conf-medium { color: var(--amber); }
.conf-low { color: var(--red); }

/* ---- Barre de probabilités 1X2 ---- */
.probbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.probbar span:nth-child(1) { background: var(--accent); }
.probbar span:nth-child(2) { background: var(--line-strong); }
.probbar span:nth-child(3) { background: var(--blue); }
.probvals { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.probvals strong { color: var(--text); font-weight: 650; }

/* ---- Tableaux ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table th, .table td { padding: 10px var(--space-3); text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }

/* ---- Listes de matchs ---- */
.match-row {
    display: grid; grid-template-columns: 52px 1fr; gap: var(--space-3); align-items: center;
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); color: var(--text);
}
.match-row:last-child { border-bottom: 0; }
.match-row:hover { background: var(--surface-2); text-decoration: none; }
.match-time { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; font-size: .9rem; }
.match-teams { display: flex; flex-direction: column; min-width: 0; }
.match-teams span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-probs { grid-column: 1 / -1; }
@media (min-width: 768px) {
    .match-row { grid-template-columns: 60px 1fr 260px; }
    .match-probs { grid-column: auto; }
}
.group-title { padding: var(--space-3) var(--space-4); font-size: .82rem; font-weight: 650; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--line); }

/* ---- Coupon ---- */
.coupon-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }
.coupon-head { display: flex; justify-content: space-between; gap: var(--space-3); align-items: flex-start; }
.coupon-head h3 { margin-top: 6px; }
.coupon-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); padding: var(--space-3); background: var(--surface-2); border-radius: 12px; }
.coupon-kpis > div:last-child { grid-column: 1 / -1; }
@media (min-width: 640px) { .coupon-kpis { grid-template-columns: repeat(3, 1fr); } .coupon-kpis > div:last-child { grid-column: auto; } }
.kpi-label { display: block; font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.35rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.kpi-value.kpi-text { font-size: 1rem; }
.kpi-sub { display: block; font-size: .74rem; color: var(--muted); }

.selection-list { list-style: none; display: flex; flex-direction: column; }
.selection { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.selection:first-child { border-top: 0; padding-top: 0; }
.selection-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.selection-match { font-weight: 600; }
.selection-meta { font-size: .78rem; color: var(--muted); }
.selection-pick { font-size: .88rem; color: var(--text-2); }
.selection-pick strong { color: var(--text); }
.selection-figures { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.odds-pill { font-variant-numeric: tabular-nums; font-weight: 700; background: var(--surface-3); padding: 2px 10px; border-radius: 8px; }
.odds-pill.is-reference { border: 1px dashed var(--amber); color: var(--amber); }
.prob { font-size: .82rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.result-won .selection-match::after { content: " ✓"; color: var(--green); }
.result-lost .selection-match::after { content: " ✕"; color: var(--red); }

.risks summary { cursor: pointer; display: flex; align-items: center; gap: var(--space-2); color: var(--amber); font-size: .88rem; font-weight: 600; list-style: none; }
.risks summary::-webkit-details-marker { display: none; }
.risks summary .icon { width: 16px; height: 16px; }
.risks ul { margin-top: var(--space-2); padding-left: var(--space-5); color: var(--text-2); font-size: .86rem; }
.risks li + li { margin-top: 4px; }
.coupon-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---- États vides, toasts, modale ---- */
.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--muted); }
.empty .icon { width: 36px; height: 36px; margin: 0 auto var(--space-3); color: var(--line-strong); }
.empty h3 { color: var(--text); margin-bottom: var(--space-2); }

.toast-region { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-nav-h) + var(--space-4) + var(--safe-bottom)); z-index: 60; display: flex; flex-direction: column; gap: var(--space-2); width: min(92vw, 420px); }
.toast { background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 12px; padding: var(--space-3) var(--space-4); font-size: .9rem; animation: toast-in .2s ease; }
.toast.is-error { border-color: rgba(248, 113, 113, .5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (min-width: 1024px) { .toast-region { bottom: var(--space-5); left: auto; right: var(--space-5); transform: none; } }

.modal { position: fixed; inset: 0; z-index: 70; display: none; align-items: flex-end; justify-content: center; background: rgba(3, 8, 20, .7); }
.modal.is-open { display: flex; }
.modal-panel {
    background: var(--surface); border: 1px solid var(--line); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
    border-radius: var(--radius) var(--radius) 0 0; padding: var(--space-5) var(--space-4) calc(var(--space-5) + var(--safe-bottom));
}
@media (min-width: 640px) { .modal { align-items: center; } .modal-panel { border-radius: var(--radius); padding: var(--space-5); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.export-text { white-space: pre-wrap; font-family: var(--font-num); font-size: .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: var(--space-3); max-height: 260px; overflow-y: auto; }

.tabs { display: flex; gap: var(--space-1); overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); scrollbar-width: none; }
.tabs a, .tabs button { padding: var(--space-3) var(--space-3); color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .is-active { color: var(--accent); border-bottom-color: var(--accent); }
