/* ============================================================
   BETTER - Sports Betting Advisor
   ============================================================ */

:root {
    --bg-dark:    #0d1117;
    --bg-card:    #161b22;
    --bg-card2:   #1c2128;
    --border:     #30363d;
    --accent:     #58a6ff;
    --accent2:    #1f6feb;
    --green:      #3fb950;
    --yellow:     #d29922;
    --red:        #f85149;
    --text:       #e6edf3;
    --text-muted: #8b949e;
    --radius:     12px;
    --shadow:     0 8px 32px rgba(0,0,0,.4);
}

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

body {
    background: var(--bg-dark);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    padding-bottom: 60px;
}

/* ── Header ── */
header {
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    border-bottom: 1px solid var(--border);
    padding: 24px 0 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent), #79c0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-muted);
    margin-top: 4px;
    font-size: 0.9rem;
}

/* ── Layout ── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ── Search Form ── */
.search-section {
    margin: 40px auto;
    max-width: 700px;
}

.search-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.search-card h2 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.8rem;
}

.teams-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: end;
}

.vs-badge {
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

/* ── Autocomplete wrapper ── */
.ac-wrap { position: relative; }

.ac-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card2);
    border: 1px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0,0,0,.6);
    z-index: 200;
    max-height: 320px;
    overflow-y: auto;
    display: none;
}

.ac-dropdown.open { display: block; }

.ac-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background .12s;
    border-bottom: 1px solid var(--border);
}

.ac-item:last-child { border-bottom: none; }

.ac-item:hover,
.ac-item.active { background: rgba(88,166,255,.12); }

.ac-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}

.ac-item .ac-no-crest {
    width: 28px;
    height: 28px;
    background: var(--border);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    color: var(--text-muted);
    font-weight: 700;
}

.ac-item .ac-info { flex: 1; min-width: 0; }
.ac-item .ac-name { font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item .ac-league { font-size: .72rem; color: var(--text-muted); }

.ac-item .ac-tla {
    font-size: .7rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(88,166,255,.1);
    border: 1px solid rgba(88,166,255,.2);
    border-radius: 4px;
    padding: 1px 6px;
    flex-shrink: 0;
}

/* Badge équipe nationale dans l'autocomplete */
.ac-item.national .ac-league { color: #d29922; }

.ac-national-tag {
    font-size: .65rem;
    font-weight: 700;
    color: #d29922;
    background: rgba(210,153,34,.12);
    border: 1px solid rgba(210,153,34,.3);
    border-radius: 4px;
    padding: 1px 6px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Badge sur le chip de confirmation */
.team-chip.national {
    background: rgba(210,153,34,.08);
    border-color: rgba(210,153,34,.3);
    color: #d29922;
}

/* Bandeau de contexte dans les résultats */
.context-banner {
    background: rgba(210,153,34,.08);
    border: 1px solid rgba(210,153,34,.25);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: .82rem;
    color: #d29922;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Badge équipe nationale dans le header résultats */
.badge.national {
    background: rgba(210,153,34,.15);
    color: #d29922;
    border-color: rgba(210,153,34,.35);
}

.ac-spinner {
    text-align: center;
    padding: 14px;
    color: var(--text-muted);
    font-size: .85rem;
}

.ac-empty {
    padding: 14px;
    color: var(--text-muted);
    font-size: .85rem;
    text-align: center;
}

/* Chip de confirmation sous le champ */
.team-chip {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    background: rgba(63,185,80,.08);
    border: 1px solid rgba(63,185,80,.25);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: .8rem;
    color: var(--green);
}

.team-chip.visible { display: flex; }
.team-chip img { width: 20px; height: 20px; object-fit: contain; }
.team-chip .chip-clear {
    margin-left: auto;
    cursor: pointer;
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1;
}
.team-chip .chip-clear:hover { color: var(--red); }

.field-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-group input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.field-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}

.field-group input::placeholder { color: var(--text-muted); }

.btn-analyze {
    display: block;
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent2), var(--accent));
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity .2s, transform .1s;
    letter-spacing: 0.3px;
}

.btn-analyze:hover { opacity: .9; }
.btn-analyze:active { transform: scale(.99); }
.btn-analyze:disabled { opacity: .5; cursor: not-allowed; }

/* ── Loading ── */
.loading {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading p { color: var(--text-muted); }

/* ── Results ── */
#results { display: none; }

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.team-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-display img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}

.team-display .name {
    font-size: 1.3rem;
    font-weight: 700;
}

.team-display .badge {
    font-size: 0.7rem;
    background: rgba(88,166,255,.15);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid rgba(88,166,255,.3);
}

.vs-large {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Cards Grid ── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon { font-size: 1rem; }

/* ── Outcome Probs ── */
.outcome-bars { display: flex; flex-direction: column; gap: 14px; }

.outcome-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.outcome-label {
    font-size: 0.85rem;
    width: 130px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.bar-wrap {
    flex: 1;
    background: var(--bg-dark);
    border-radius: 4px;
    height: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(.4,0,.2,1);
}

.bar-home { background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.bar-draw { background: linear-gradient(90deg, #6e40c9, #a371f7); }
.bar-away { background: linear-gradient(90deg, #c9510c, #f0883e); }

.outcome-pct {
    width: 45px;
    text-align: right;
    font-weight: 700;
    font-size: 0.95rem;
}

.outcome-pct.best { color: var(--green); }

.outcome-odd {
    width: 52px;
    text-align: right;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--yellow);
    background: rgba(210,153,34,.08);
    border: 1px solid rgba(210,153,34,.2);
    border-radius: 5px;
    padding: 2px 7px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.outcome-odd.na {
    color: var(--text-muted);
    background: none;
    border-color: transparent;
    font-weight: 400;
}

.odds-legend {
    margin-top: 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: rgba(210,153,34,.5);
    border: 1px solid rgba(210,153,34,.6);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Score Prediction ── */
.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px 0;
}

.score-box {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 16px 28px;
    text-align: center;
}

.score-box.highlight { border-color: var(--accent); }

.score-number {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.score-dash { font-size: 2rem; color: var(--text-muted); font-weight: 300; }

.score-confidence {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 12px;
}

.score-confidence span { color: var(--yellow); font-weight: 600; }

/* Top scores */
.top-scores { margin-top: 16px; }
.top-scores h4 { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

.score-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.score-chip {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-chip .chip-score { font-weight: 700; }
.score-chip .chip-prob { color: var(--text-muted); font-size: 0.78rem; }

/* ── Form ── */
.form-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.form-badge {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.form-badge.W { background: rgba(63,185,80,.2); color: var(--green); border: 1px solid rgba(63,185,80,.4); }
.form-badge.D { background: rgba(210,153,34,.2); color: var(--yellow); border: 1px solid rgba(210,153,34,.4); }
.form-badge.L { background: rgba(248,81,73,.2); color: var(--red); border: 1px solid rgba(248,81,73,.4); }

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child { border-bottom: none; }

.stat-row .label { color: var(--text-muted); font-size: 0.88rem; }
.stat-row .value { font-weight: 600; font-size: 0.95rem; }

.team-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.team-stat-col h4 {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── H2H ── */
.h2h-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.h2h-stat {
    flex: 1;
    text-align: center;
    background: var(--bg-dark);
    border-radius: 8px;
    padding: 12px 8px;
}

.h2h-stat .big { font-size: 1.8rem; font-weight: 800; }
.h2h-stat .small { font-size: 0.75rem; color: var(--text-muted); }
.h2h-stat.home .big { color: var(--accent); }
.h2h-stat.draw .big { color: #a371f7; }
.h2h-stat.away .big { color: #f0883e; }

.h2h-match {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.h2h-match:last-child { border-bottom: none; }
.h2h-match .date { color: var(--text-muted); font-size: 0.78rem; }
.h2h-match .score-text { font-weight: 700; letter-spacing: 2px; }

/* ── Value Bets ── */
.value-bets-section { grid-column: 1 / -1; }

.no-bets {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 0.9rem;
}

.bet-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    transition: border-color .2s;
}

.bet-card:hover { border-color: var(--accent); }
.bet-card:last-child { margin-bottom: 0; }

.bet-type { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.bet-details { font-size: 0.83rem; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }
.bet-details span strong { color: var(--text); }

.bet-right { text-align: right; }

.bet-odd {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--green);
    line-height: 1;
}

.bet-odd-label { font-size: 0.72rem; color: var(--text-muted); }

.confidence-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 6px;
}

.confidence-badge.fort { background: rgba(63,185,80,.15); color: var(--green); border: 1px solid rgba(63,185,80,.3); }
.confidence-badge.tres-fort { background: rgba(63,185,80,.25); color: var(--green); border: 1px solid rgba(63,185,80,.5); }
.confidence-badge.moyen { background: rgba(210,153,34,.15); color: var(--yellow); border: 1px solid rgba(210,153,34,.3); }
.confidence-badge.faible { background: rgba(248,81,73,.1); color: var(--red); border: 1px solid rgba(248,81,73,.2); }

/* ── Odds Table ── */
.odds-row {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.odd-box {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.odd-box .type { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; }
.odd-box .val { font-size: 1.3rem; font-weight: 700; color: var(--accent); margin: 4px 0 2px; }
.odd-box .bookie { font-size: 0.7rem; color: var(--text-muted); }

/* ── Disclaimer ── */
.disclaimer {
    background: rgba(210,153,34,.08);
    border: 1px solid rgba(210,153,34,.2);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.82rem;
    color: var(--yellow);
    margin-top: 24px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

/* ── Error ── */
.error-msg {
    background: rgba(248,81,73,.1);
    border: 1px solid rgba(248,81,73,.3);
    border-radius: 8px;
    padding: 16px 20px;
    color: var(--red);
    font-size: 0.9rem;
    display: none;
}

/* ── Info banner ── */
.info-banner {
    background: rgba(88,166,255,.08);
    border: 1px solid rgba(88,166,255,.2);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.82rem;
    color: var(--accent);
    margin-bottom: 16px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .teams-row { grid-template-columns: 1fr; }
    .vs-badge { display: none; }
    .results-header { flex-direction: column; text-align: center; }
    .team-stats-grid { grid-template-columns: 1fr; }
    .odds-row { flex-direction: column; }
}
