/* =======================================================
   1. ESTILOS GERAIS E TIPOGRAFIA
======================================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.container {
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 650px;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-top: 0;
}

hr {
    border: 0;
    height: 1px;
    background: #eee;
    margin: 20px 0;
}

/* =======================================================
   2. NAVEGAÇÃO (ABAS)
======================================================== */
.abas {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #eee;
    margin-bottom: 25px;
}

.aba {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 4px;
    font-size: 14px;
    font-weight: bold;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.aba-icone {
    font-size: 18px;
    line-height: 1;
}

.aba-texto {
    font-size: 13px;
}

.aba:hover {
    color: #2c3e50;
}

.aba.ativa {
    color: #27ae60;
    border-bottom: 3px solid #27ae60;
}

.oculta {
    display: none !important;
}

/* =======================================================
   3. CAIXAS DE BUSCA E AUTOCOMPLETE
======================================================== */
.search-box {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
}

input, select {
    flex: 1;
    min-width: 0; /* evita overflow em flex */
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
}

input:focus, select:focus {
    border-color: #27ae60;
}

button {
    padding: 12px 20px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

button:hover {
    background-color: #219150;
}

.sugestoes {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2);
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999;
}

/* =======================================================
   4. TELA 1: ESTATÍSTICAS DO JOGADOR
======================================================== */
.info-basica {
    margin: 8px 0;
}

.separador {
    margin: 0 8px;
    color: #bdc3c7;
}

.cor-vitoria {
    color: #28a745;
}

.cor-derrota {
    color: #dc3545;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    text-align: center;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.stat-label {
    margin: 0;
    font-size: 13px;
    color: #7f8c8d;
    text-transform: uppercase;
}

.stat-value {
    margin: 5px 0 0 0;
    font-size: 22px;
    font-weight: bold;
    color: #2c3e50;
}

.estante-trofeus {
    background: #fff9e6;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #ffeaa7;
}

.estante-trofeus h3 {
    margin-top: 0;
    color: #d35400;
    text-align: center;
}

.trofeus-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.trofeu-item {
    font-size: 15px;
    color: #34495e;
    position: relative;
}

/* Dica de hover */
.trofeus-dica {
    font-size: 12px;
    color: #95a5a6;
    margin: -8px 0 12px 0;
    text-align: center;
}

/* Item com títulos — interativo */
.trofeu-clicavel {
    cursor: default;
}

.trofeu-clicavel .trofeu-qtd {
    border-bottom: 2px dotted #d35400;
    padding-bottom: 1px;
    color: #d35400;
}

.trofeu-hint {
    font-size: 10px;
    color: #d35400;
    opacity: 0.7;
}

/* Zero — apagado */
.trofeu-zero {
    color: #bdc3c7;
}

/* Tooltip */
.trofeu-tooltip {
    display: none;
    position: fixed;
    background: #2c3e50;
    color: #fff;
    font-size: 13px;
    line-height: 1.8;
    padding: 10px 14px;
    border-radius: 8px;
    white-space: nowrap;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    pointer-events: auto;
    max-height: 260px;
    overflow-y: auto;
}

.trofeu-tooltip::-webkit-scrollbar { width: 4px; }
.trofeu-tooltip::-webkit-scrollbar-track { background: rgba(255,255,255,0.1); border-radius: 4px; }
.trofeu-tooltip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.35); border-radius: 4px; }

.trofeu-tooltip.visivel {
    display: block;
}

/* =======================================================
   5. TELA 2: TORNEIO
======================================================== */
.titulo-campeao {
    color: #d89f00;
    margin-top: 10px;
}

/* =======================================================
   6. TELA 3: CAMPANHA
======================================================== */
.banner-campeao {
    display: none;
    background: #f1c40f;
    color: #fff;
    text-align: center;
    padding: 10px;
    font-weight: bold;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 18px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* =======================================================
   7. TELA 4: HEAD-TO-HEAD (H2H)
======================================================== */
.h2h-inputs {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.h2h-campo {
    position: relative;
    flex: 1;
}

.h2h-campo input {
    width: 100%;
    box-sizing: border-box;
}

.h2h-vs {
    font-weight: bold;
    font-size: 20px;
    padding-top: 12px;
    color: #7f8c8d;
    flex-shrink: 0;
}

.btn-h2h {
    width: 100%;
    margin-top: 4px;
}

.placar-h2h {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.lado-h2h {
    text-align: center;
    width: 40%;
}

.nome-h2h {
    margin: 0;
    font-size: 18px;
    color: white;
    word-break: break-word;
}

.pontuacao-h2h {
    font-size: 48px;
    font-weight: bold;
    color: #f1c40f;
}

.versus-h2h {
    font-size: 24px;
    font-weight: bold;
    color: #bdc3c7;
    flex-shrink: 0;
}

.titulo-historico {
    text-align: center;
    margin-top: 30px;
    color: #333;
}

/* Card de estatísticas comparativas */
.stats-comparativas {
    margin-top: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.stats-comp-header {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    text-align: center;
    background: #f0f4f8;
    padding: 10px 16px;
    font-weight: bold;
    font-size: 13px;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
}

.stats-comparativas-linha {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
    font-size: 15px;
}

.stats-comparativas-linha:last-child {
    border-bottom: none;
}

.stats-comparativas-linha:nth-child(even) {
    background: #fafafa;
}

.stat-comp-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-comp-valor {
    font-weight: bold;
    color: #2c3e50;
}

.stat-destaque {
    color: #27ae60;
    font-size: 17px;
}

.partida-h2h-item {
    background: #f9f9f9;
    border-left: 5px solid #3498db;
    padding: 12px 20px;
    margin-bottom: 12px;
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.partida-h2h-item > div:first-child {
    flex: 1;
    min-width: 200px;
}

.partida-h2h-item > div:last-child {
    font-size: 18px;
    font-weight: bold;
    text-align: right;
    letter-spacing: 1px;
    min-width: 120px;
}

.partida-h2h-meta {
    font-size: 12px;
    color: #7f8c8d;
}

#lista-partidas-h2h {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
    margin-top: 15px;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

#lista-partidas-h2h::-webkit-scrollbar { width: 8px; }
#lista-partidas-h2h::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
#lista-partidas-h2h::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 4px; }
#lista-partidas-h2h::-webkit-scrollbar-thumb:hover { background: #95a5a6; }

/* =======================================================
   8. CLASSES UTILITÁRIAS
======================================================== */

/* Mensagem de erro inline (substitui alert) */
.msg-erro {
    color: #dc3545;
    background: #fff0f0;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 0;
    font-size: 15px;
}

.negrito {
    font-weight: bold;
}

/* Separadores de seção na campanha */
.secao-label {
    font-size: 12px;
    color: #95a5a6;
    text-align: center;
    margin: 14px 0 8px 0;
    letter-spacing: 0.5px;
}

/* Badge de entrada especial (LL, WC, etc) */
.badge-entrada {
    display: inline-block;
    background: #e8f4fd;
    color: #2980b9;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid #aed6f1;
    vertical-align: middle;
}

/* Item de partida na aba Campanha */
.partida-campanha-item {
    padding: 10px;
    border-bottom: 1px solid #ccc;
    line-height: 1.6;
}

/* Item de sugestão do autocomplete (substitui inline styles do JS) */
.sugestao-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    background-color: white;
}

.sugestao-item:hover {
    background-color: #f1f1f1;
}

/* =======================================================
   9. ABA TORNEIO — HISTÓRICO DE EDIÇÕES
======================================================== */
.torneio-historico-titulo {
    margin: 0 0 4px 0;
    color: #2c3e50;
}

.torneio-historico-sub {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: #95a5a6;
}

.edicoes-lista {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 6px;
}

.edicoes-lista::-webkit-scrollbar { width: 6px; }
.edicoes-lista::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.edicoes-lista::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 4px; }
.edicoes-lista::-webkit-scrollbar-thumb:hover { background: #95a5a6; }

.edicao-item {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #eee;
    margin-bottom: 8px;
    background: #fff;
    transition: background 0.15s;
}

.edicao-item:hover {
    background: #f8f9fa;
}

.edicao-ano {
    font-size: 15px;
    font-weight: bold;
    color: #7f8c8d;
    text-align: center;
}

.edicao-jogadores {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.edicao-campeao {
    font-size: 14px;
    font-weight: bold;
    color: #2c3e50;
}

.edicao-vice {
    font-size: 13px;
    color: #7f8c8d;
}

.edicao-placar {
    font-size: 13px;
    font-weight: bold;
    color: #555;
    letter-spacing: 0.4px;
    text-align: right;
    white-space: nowrap;
}

/* =======================================================
   10. GRÁFICO DE SUPERFÍCIE
======================================================== */
.grafico-superficie {
    margin-top: 24px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.grafico-superficie h3 {
    margin: 0 0 16px 0;
    color: #2c3e50;
    font-size: 15px;
    text-align: center;
}

.grafico-wrapper {
    position: relative;
    max-height: 240px;
}

/* =======================================================
   10. SEÇÃO TEMPORADA
======================================================== */
.secao-temporada {
    margin-top: 24px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.temporada-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.temporada-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 15px;
    white-space: nowrap;
}

.temporada-controles {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}

.temporada-controles select {
    max-width: 160px;
}

.temporada-controles button {
    padding: 10px 20px;
    white-space: nowrap;
}

.temporada-carregando {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 12px 0;
}

/* Resumo de stats da temporada */
.temporada-resumo {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.temporada-resumo-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Lista de torneios */
.torneio-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #eee;
    margin-bottom: 8px;
    background: #fff;
    transition: background 0.2s;
}

.torneio-item:hover {
    background: #f8f9fa;
}

/* Torneio clicável */
.torneio-clicavel {
    cursor: pointer;
    user-select: none;
}

.torneio-clicavel.ativo {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

.torneio-clicavel.ativo:not(.campeao) {
    background: #f0f7ff;
    border-color: #3498db;
}

.torneio-clicavel.ativo.campeao {
    border-color: #f1c40f;
}

.torneio-seta {
    font-size: 11px;
    color: #bdc3c7;
    margin-left: 4px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

/* Painel de detalhe do acordeão */
.torneio-detalhe {
    display: none;
    background: #f8fbff;
    border: 1px solid #3498db;
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.torneio-detalhe.aberto {
    display: block;
}

.torneio-item.campeao + .torneio-detalhe {
    border-color: #f1c40f;
    background: #fffdf5;
}

/* Linhas de partida dentro do detalhe */
.detalhe-partida {
    display: grid;
    grid-template-columns: 80px 100px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid #eef2f7;
    font-size: 14px;
}

.detalhe-partida:last-child {
    border-bottom: none;
}

.detalhe-rodada {
    font-size: 11px;
    color: #7f8c8d;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detalhe-resultado {
    font-weight: bold;
    font-size: 13px;
}

.detalhe-oponente {
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detalhe-secao-label {
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #95a5a6;
    padding: 8px 16px 4px;
    background: #f0f4f8;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-entrada {
    background: #3498db;
    color: white;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    text-transform: none;
    font-weight: bold;
}

.detalhe-placar {
    font-size: 13px;
    color: #555;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-align: right;
    white-space: nowrap;
}

.torneio-item.campeao {
    border-color: #f1c40f;
    border-width: 2px;
    background: linear-gradient(135deg, #fffdf0 0%, #fff8d6 100%);
    box-shadow: 0 2px 8px rgba(241, 196, 15, 0.2);
}

.torneio-item.campeao .torneio-info strong {
    color: #b7860b;
}

.torneio-item.campeao .torneio-rodada {
    color: #b7860b;
}

.torneio-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.torneio-info strong {
    font-size: 14px;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.torneio-meta {
    font-size: 12px;
    color: #95a5a6;
}

.torneio-resultado {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    text-align: right;
}

.badge-qualifying {
    background: #eaf4fb;
    color: #2471a3;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid #aed6f1;
    white-space: nowrap;
}

.badge-campeao {
    background: #f1c40f;
    color: #7d6608;
    font-size: 11px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.torneio-placar {
    font-size: 13px;
    color: #7f8c8d;
    white-space: nowrap;
}

.torneio-rodada {
    font-size: 13px;
    font-weight: bold;
    color: #2c3e50;
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

/* =======================================================
   11. RESPONSIVIDADE
======================================================== */
@media (max-width: 500px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 16px;
    }

    /* Abas: só ícone em telas pequenas */
    .aba-texto {
        display: none;
    }

    .aba {
        font-size: 20px;
        padding: 10px 4px;
    }

    /* Stats do jogador: empilhar em 1 coluna */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Títulos: 1 coluna */
    .trofeus-grid {
        grid-template-columns: 1fr;
    }

    /* Busca: empilhar input e botão */
    .search-box {
        flex-direction: column;
    }

    input, select, button {
        width: 100%;
    }

    /* Temporada: resumo em 2 colunas no mobile */
    .temporada-resumo {
        grid-template-columns: repeat(2, 1fr);
    }

    .torneio-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .torneio-resultado {
        width: 100%;
        justify-content: flex-start;
    }

    .detalhe-partida {
        grid-template-columns: 80px 1fr;
        grid-template-rows: auto auto;
    }

    .detalhe-resultado {
        text-align: right;
    }

    .detalhe-placar {
        grid-column: 2;
        text-align: right;
    }

    /* H2H placar: reduzir fonte */
    .pontuacao-h2h {
        font-size: 36px;
    }

    .nome-h2h {
        font-size: 14px;
    }

    .partida-h2h-item > div:last-child {
        min-width: 80px;
        font-size: 15px;
    }
}