/* --- LAYOUT GERAL DA PÁGINA DO COMANDANTE --- */
.cmd-container {
    max-width: 1600px;
    width: 95%;
    margin: 0 auto;
    padding-bottom: 60px;
}

/* --- HEADER DO COMANDANTE --- */
.cmd-header {
    display: flex;
    gap: 35px;
    align-items: center;
    padding: 40px;
    background: linear-gradient(135deg, #111 0%, #0a0a0a 100%);
    border-bottom: 2px solid #ff4d4d;
    border-radius: 0 0 16px 16px;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* .cmd-header > img {
    width: 240px;
    border-radius: 12px;
    box-shadow: 0 15px 25px rgba(0,0,0,0.6);
} */

.cmd-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cmd-title h1 {
    font-size: 3.5rem;
    margin: 5px 0 20px 0;
    line-height: 1.1;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.cmd-stats {
    display: flex;
    gap: 15px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 25px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-box span {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-box strong {
    font-size: 2rem;
    color: #ff4d4d;
}

/* --- GRÁFICO DO HEADER --- */
.cmd-chart-container {
    width: 450px;
    height: 220px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #222;
}

/* --- CORPO PRINCIPAL (ASSIMÉTRICO) --- */
.sections-grid {
    display: grid;
    /* 400px para a tabela, o resto todo para as cartas */
    grid-template-columns: 400px 1fr;
    gap: 40px;
}

.section-panel {
    background: #111;
    border: 1px solid #222;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.section-panel h3 {
    margin-bottom: 20px;
    font-size: 1.4rem;
    color: #fff;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .subtitle {
    color: #888;
    font-size: 0.95rem;
}

/* --- TABELA DE EVENTOS --- */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #222;
    font-size: 0.95rem;
}

th {
    color: #ff4d4d;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.first-place-row {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.08) 0%, transparent 100%);
}

.first-place-row td {
    border-bottom: 1px solid rgba(255, 215, 0, 0.2) !important;
}

.first-place-row td:first-child {
    border-left: 3px solid #ffd700;
}

.btn-decklist-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #2a2a2a;
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    text-decoration: none;
    transition: 0.2s;
}

.btn-decklist-icon:hover {
    background: #ff4d4d;
    transform: scale(1.1);
}

.btn-decklist-icon svg {
    width: 18px;
    height: 18px;
}

/* --- GRID DE CARTAS (OTIMIZADO) --- */
.signature-category {
    margin-bottom: 35px;
}

.signature-category h4 {
    color: #aaa;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 500;
}

.cards-grid {
    display: grid;
    /* Reduzimos um pouco o tamanho mínimo para caber mais cartas na mesma linha */
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 12px;
}

.card-wrapper {
    position: relative;
    text-align: center;
    transition: transform 0.2s;
}

.card-wrapper:hover {
    transform: translateY(-5px) scale(1.03);
    z-index: 2;
}

.card-wrapper img {
    width: 105%;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.card-badge {
    background: rgba(0, 0, 0, 0.85);
    color: #00e5ff;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 4px;
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    border: 1px solid rgba(0, 229, 255, 0.5);
    font-size: 0.85rem;
    backdrop-filter: blur(2px);
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 450px;
    margin-bottom: 25px; /* Empurra o título do comandante para baixo */
    z-index: 20; /* Garante que o dropdown passe por cima dos gráficos */
}

#cmdSearchInput {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

#cmdSearchInput:focus {
    outline: none;
    border-color: #ff4d4d;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 10px rgba(255, 77, 77, 0.3);
}

.search-results-dropdown {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none; /* Escondido por padrão */
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #222;
    transition: background 0.2s;
    text-decoration: none;
    color: #fff;
}

.search-result-item:hover {
    background: #2a2a2a;
}

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

.search-result-img {
    width: 45px;
    height: 45px;
    border-radius: 4px;
    object-fit: cover;
    object-position: top;
}

.search-result-info {
    display: flex;
    flex-direction: column;
}

.search-result-name {
    font-size: 0.95rem;
    font-weight: bold;
}

.search-result-arch {
    font-size: 0.75rem;
    color: #aaa;
    text-transform: uppercase;
}

.charts-wrapper {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 15px;
    width: 100%;
}

.cmd-chart-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #222;
}

.spider-chart-box {
    width: 320px;
    height: 260px;
}

.trend-chart-box {
    width: 420px;
    height: 260px;
}

/* --- HEADER DO COMANDANTE (COM BACKGROUND IMERSIVO) --- */
.cmd-header {
    position: relative; /* Necessário para o posicionamento absoluto do ::before */
    display: flex;
    gap: 35px;
    align-items: center;
    padding: 40px 50px; /* Aumentei um pouco o padding lateral */
    /* Removemos o background linear antigo */
    background: #111; 
    border-bottom: 2px solid #ff4d4d;
    border-radius: 0 0 16px 16px;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden; /* Garante que a imagem borrada não saia das bordas arredondadas */
    
    /* Variável CSS que receberá a URL da imagem via JavaScript */
    --cmd-bg-image: none;
}

/* O elemento fantasma que conterá a imagem de fundo */
.cmd-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0; /* Fica atrás do conteúdo */

    /* Camada 1: Um degradê escuro para garantir leitura do texto */
    /* Camada 2: A imagem do comandante passada via variável CSS */
    background-image: 
        linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, rgba(10,10,10,0.95) 100%),
        var(--cmd-bg-image);
    
    background-size: cover;
    background-position: center 25%; /* Foca na parte superior da arte (rosto/ação) */
    filter: blur(2px) saturate(1.2); /* Um leve desfoque e saturação para estilo */
    opacity: 0.9; /* Controla a intensidade da imagem de fundo */
    transition: all 0.5s ease;
}

/* Garante que o conteúdo (texto, gráficos) fique na frente do background */
.cmd-title, .charts-wrapper {
    position: relative;
    z-index: 1;
}

/* Esconde o anúncio por padrão (no Computador) */
.ad-mobile-only {
    display: none; 
    text-align: center;
    width: 100%;
    margin: 15px 0;
    /* Garante que, se for exibido em um grid, ele ocupe a linha inteira */
    grid-column: 1 / -1; 
}

/* Mostra o anúncio APENAS em telas de celular/tablets (abaixo de 768px) */
@media (max-width: 768px) {
    .ad-mobile-only {
        display: block; /* Revela o bloco */
    }
}

@media (max-width: 1100px) {
    .ad-mobile-only {
        display: block; /* Revela o bloco */
    }
    .sections-grid { grid-template-columns: 1fr; }
    .cmd-header { flex-wrap: wrap; justify-content: center; text-align: center; }
    .cmd-chart-container { width: 100%; max-width: 600px; margin-top: 20px; }
    .navbar {
    flex-direction: column;
    gap: 15px;
    }
    .search-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
    .cmd-header {
        padding: 25px 15px; 
    }
    .charts-wrapper {
        justify-content: center; 
        margin-top: 25px;
    }
    .cmd-title h1 {
        font-size: 2.2rem; 
        word-wrap: break-word;
        hyphens: auto;
    }
    .search-container {
        width: 100%;
        max-width: 100%;
        margin: 0 0 20px 0; 
    }
    .cmd-stats {
        display: flex;
        flex-wrap: wrap; 
        gap: 10px;
        justify-content: center;
    }
    .stat-box {
        flex: 1 1 45%; 
        padding: 10px;
        font-size: 0.85rem;
    }
    .stat-box strong {
        font-size: 1.1rem !important; 
    }   
    .spider-chart-box, 
    .trend-chart-box { 
        width: 100%; 
        max-width: 500px;
        height: 260px; 
    }
    .cmd-header::before {
        background-position: center center !important;
        filter: blur(2px) saturate(1.1) !important;
        opacity: 0.8 !important;
    }
}