/* ══════════════════════════════════════════════════════════
   MODAL TÁTICA
   ══════════════════════════════════════════════════════════ */

.modal-tatica {
    align-items: flex-start;
    padding: 10px;
    overflow-x: auto;
    /* A modal exterior NÃO deve ter scroll vertical próprio — só o
       .tatica-content (o conteúdo interior) tem. Dois contentores com
       scroll vertical aninhados um dentro do outro são uma causa
       conhecida de "zonas mortas" ao toque, precisamente nos limites
       entre os dois — o que impedia o clique de funcionar sempre na
       parte inferior visível da modal. */
    overflow-y: hidden;
}

.tatica-content {
    width: max-content;
    min-width: 900px;
    max-width: 1520px;
    /* zoom em ecrãs pequenos (--tz definida por aplicarZoomTatica em tatica.js);
       o max-height compensa o zoom para a modal continuar a caber no ecrã */
    zoom: var(--tz, 1);
    max-height: calc((100vh - 20px) / var(--tz, 1));
    max-height: calc((100dvh - 20px) / var(--tz, 1));   /* dvh = área realmente visível no telemóvel (sem a barra do browser) */
    /* o scroll VERTICAL não passa para a página por trás; o horizontal tem de
       passar para a .modal-tatica (que é quem faz o scroll lateral) */
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overflow-x: visible;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ── Cabeçalho ──────────────────────────────────────────── */
.tatica-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #334155;
    background: #0f172a;
    flex-shrink: 0;
}

.tatica-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.tatica-header-acoes {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tatica-data       { font-size: 13px; color: var(--muted); }
.tatica-adversario { font-size: 15px; font-weight: bold; }

.tatica-badge-comp {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: #1e3a5f;
    color: #93c5fd;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tatica-comp-detalhe {
    font-weight: normal;
    color: #7dd3fc;
    font-size: 11px;
}

.btn-fechar-tatica {
    line-height: 1;
}



/* ── Alerta — área fixa que não move outros elementos ───── */
.tatica-alerta-toast {
    display: none;
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    max-width: 88vw;
    padding: 10px 20px;
    background: #7f1d1d;
    color: #fca5a5;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    border: 1px solid #ef4444;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ── Corpo ──────────────────────────────────────────────── */
.tatica-body {
    display: flex;
    gap: 16px;
    padding: 6px 12px 16px 12px;
    flex: 1;
    min-height: 0;
    align-items: flex-start;
}

.tatica-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: bold;
    text-align: center;
}

/* Botão de fechar e fundo escurecido do painel "Info Jogador" — só
   fazem sentido no formato "mini-modal" usado em ecrãs pequenos (ver
   media query mais abaixo); no PC o painel é uma coluna fixa sempre
   visível, sem necessidade de os fechar. */
.tatica-info-fechar,
.tatica-info-backdrop {
    display: none;
}
.tatica-info-topo-linha {
    display: block;
}
/* O botão "Remover" fundido no painel de info só existe para o
   formato mobile (ver media query) — no PC o popup próprio
   (.tatica-remove-popup) já funciona bem, sem sobreposição */
.tatica-info-btn-remover {
    display: none;
}

/* ── Plantel (esquerda) ─────────────────────────────────── */
.tatica-plantel {
    width: 320px;
    flex-shrink: 0;
}

.tatica-lista {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 620px;
    overflow-y: auto;
    overflow-x: visible;   /* permite tooltip sair para a direita */
    padding-right: 2px;
    padding-bottom: 32px;
}

.tatica-jogador {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 5px;
    padding: 5px 7px;
    cursor: grab;
    display: grid;
    grid-template-columns: 30px 1fr auto auto;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    position: relative;   /* âncora do tooltip */
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.tatica-jogador:hover  { background: #263348; border-color: var(--accent); }
.tatica-jogador.em-campo  { opacity: 0.4; }
.tatica-jogador.suplente  { opacity: 0.65; border-color: #1e40af; }
.tatica-jogador.dragging  { opacity: 0.2; }

.tj-pos {
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    padding: 2px 3px;
    border-radius: 3px;
    background: #334155;
    color: var(--text);
}
.tj-pos.GR  { background: #7c3aed; }
.tj-pos.DC, .tj-pos.DD, .tj-pos.DE { background: #0369a1; }
.tj-pos.MC, .tj-pos.MD, .tj-pos.ME { background: #065f46; }
.tj-pos.AV  { background: #b45309; }

.tj-nome { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tj-cond { font-size: 10px; color: var(--muted); white-space: nowrap; }
.tj-estrelas { display: flex; align-items: center; }
.tj-estrelas .estrela { font-size: 10px; }



/* ── Centro: campo ──────────────────────────────────────── */
.tatica-centro {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Campo + suplentes lado a lado */
.tatica-campo-row {
    display: flex;
    flex-direction: row;
    gap: 14px;
    align-items: flex-start;
}

.tatica-campo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding-bottom: 32px;
}

/* Campo de futebol */
.tatica-campo {
    position: relative;
    width: 493px;
    height: 580px;
    background: linear-gradient(180deg, #14532d 0%, #166534 50%, #14532d 100%);
    border: 3px solid rgba(255,255,255,0.7);
    border-radius: 3px;
    flex-shrink: 0;
    overflow: visible;
}

/* Linha de meio-campo */
.tatica-campo::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    height: 2px;
    background: rgba(255,255,255,0.5);
    pointer-events: none;
}

/* Círculo central */
.tatica-campo::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 90px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    pointer-events: none;
}

/* Linhas do campo via pseudo-elementos em divs filhos */
.campo-linha-grande-area-ataque {
    position: absolute;
    pointer-events: none;
    left: 15%;
    right: 15%;
    top: 5%;
    height: 16%;
    border: 2px solid rgba(255,255,255,0.4);
    border-top: none;
    pointer-events: none;
}

.campo-linha-grande-area-defesa {
    position: absolute;
    pointer-events: none;
    left: 15%;
    right: 15%;
    bottom: 5%;
    height: 16%;
    border: 2px solid rgba(255,255,255,0.4);
    border-bottom: none;
    pointer-events: none;
}

.campo-linha-pequena-area-ataque {
    position: absolute;
    pointer-events: none;
    left: 30%;
    right: 30%;
    top: 5%;
    height: 7%;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: none;
    pointer-events: none;
}

.campo-linha-pequena-area-defesa {
    position: absolute;
    pointer-events: none;
    left: 30%;
    right: 30%;
    bottom: 5%;
    height: 7%;
    border: 2px solid rgba(255,255,255,0.3);
    border-bottom: none;
    pointer-events: none;
}

/* Posição no campo — quadrado invisível */
.tatica-pos {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 58px;
    height: 58px;
    border: 2px dashed transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, background 0.15s;
    cursor: default;
}

/* Mostrar tracejado apenas quando está a arrastar */
.tatica-campo.arrastando .tatica-pos:not(.ocupado) {
    border-color: rgba(255,255,255,0.25);
}

.tatica-pos.drag-over {
    border-color: var(--accent);
    background: rgba(56,189,248,0.2);
}

.tatica-pos.ocupado {
    border-style: solid;
    border-color: rgba(255,255,255,0.4);
    background: rgba(0,0,0,0.25);
}

/* Texto da tática com tamanho fixo no iPhone/iPad: o Safari pode aumentar o texto pequeno (9px, 8px, 7px)
   e o nome do jogador deixa de caber nos quadrados */
.tatica-content,
.tatica-content * {
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

/* Ficha do jogador no campo */
.campo-jogador {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    gap: 1px;
}

.campo-jogador .cj-pos {
    font-size: 9px;
    font-weight: bold;
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 1px 4px;
    border-radius: 3px;
}

.campo-jogador .cj-nome {
    font-size: 9px;
    color: #fff;
    text-align: center;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}



/* ── Direita: Suplentes + Estratégia + Funções ─────────── */
.tatica-sub-suplentes {
    flex-shrink: 0;
}

/* Estratégia + Funções — coluna isolada à direita */
.tatica-extras {
    width: 146px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.select-estrategia {
    width: 100%;
    background: #0f172a;
    color: var(--text);
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 6px 6px;
    font-size: 11px;
    cursor: pointer;
}

.select-estrategia:focus { outline: none; border-color: var(--accent); }

/* Funções verticais — label em cima, drop em baixo */
.tatica-funcoes-vert {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.funcao-slot-vert {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.funcao-slot-vert .funcao-label {
    font-size: 10px;
    color: var(--muted);
    white-space: nowrap;
}

.funcao-slot-vert .funcao-drop {
    width: 100%;
    height: 40px;
    font-size: 10px;
}

.tatica-bench {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bench-pos {
    width: 90px;
    height: 49px;
    border: 2px dashed #334155;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #475569;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
    cursor: default;
}

.bench-pos.drag-over {
    border-color: var(--accent);
    background: rgba(56,189,248,0.1);
}

.bench-pos.ocupado {
    border-style: solid;
    border-color: #1e40af;
    background: rgba(30,64,175,0.15);
}

.bench-jogador {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #93c5fd;
    font-weight: bold;
    text-align: center;
    padding: 2px;
    cursor: grab;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Guardar ────────────────────────────────────────────── */




/* ── Funções drop zone ──────────────────────────────────── */
.funcao-drop {
    border: 2px dashed #334155;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--muted);
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
    padding: 2px 4px;
    cursor: default;
}

.funcao-drop.drag-over {
    border-color: var(--accent);
    background: rgba(56,189,248,0.1);
}

.funcao-drop.preenchido {
    border-style: solid;
    border-color: #f59e0b;
    color: #f59e0b;
    font-size: 9px;
    font-weight: bold;
}

/* ── Botão limpar formação ──────────────────────────────── */




/* ── Popup remover jogador ──────────────────────────────── */
.tatica-remove-popup {
    position: absolute;
    z-index: 10000;
    background: #1e293b;
    border: 1px solid #ef4444;
    border-radius: 6px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    white-space: nowrap;
}







/* ── Painel fixo de info do jogador ────────────────────── */
.tatica-info-painel {
    width: 235px;
    flex-shrink: 0;
    margin-left: 14px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
    align-self: flex-start;
}

.tatica-info-vazio {
    font-size: 12px;
    color: #475569;
    text-align: center;
    padding: 20px 0;
    font-style: italic;
}

/* Reutiliza tj-attr-row, tj-attr-label, etc do plantel */
.tatica-info-painel .tj-tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #334155;
    padding-bottom: 6px;
}

.tatica-info-painel .tj-tooltip-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
    border-bottom: 1px solid #1e293b;
}

.tatica-info-painel .tj-tooltip-row span:first-child { color: var(--muted); }

/* Cores da condição física dentro do painel info — forçar especificidade */
.tatica-info-painel .cond-alta  { color: #22c55e !important; font-weight: bold; }
.tatica-info-painel .cond-media { color: #f59e0b !important; font-weight: bold; }
.tatica-info-painel .cond-baixa { color: #ef4444 !important; font-weight: bold; }

.tatica-info-painel .tj-attr-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    padding: 2px 0;
}

.tatica-info-painel .tj-attr-label { width: 112px; color: var(--muted); flex-shrink: 0; }

.tatica-info-painel .tj-attr-barra {
    flex: 1;
    height: 5px;
    background: #334155;
    border-radius: 3px;
    overflow: hidden;
}

.tatica-info-painel .tj-attr-fill { height: 100%; border-radius: 3px; }
.tatica-info-painel .tj-attr-fill.alto  { background: #22c55e; }
.tatica-info-painel .tj-attr-fill.medio { background: #f59e0b; }
.tatica-info-painel .tj-attr-fill.baixo { background: #ef4444; }

.tatica-info-painel .tj-attr-val {
    width: 22px;
    text-align: right;
    font-weight: bold;
    font-size: 11px;
}

/* ── Toast de sucesso (fora da modal) ──────────────────── */
.tatica-sucesso-toast {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #065f46;
    color: #6ee7b7;
    border: 1px solid #22c55e;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: bold;
    z-index: 99999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    white-space: nowrap;
}

/* ── Botões header favoritos ────────────────────────────── */




/* ── Painel overlay (dentro da modal) ───────────────────── */
.tatica-painel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tatica-painel {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 20px;
    width: 360px;
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tatica-painel-larga { width: 520px; }

.tatica-painel-titulo {
    font-size: 15px;
    font-weight: bold;
    border-bottom: 1px solid #334155;
    padding-bottom: 8px;
}

/* Título com a cruz de fechar à direita; fica sempre visível ao fazer scroll na lista */
.tatica-painel-titulo-fechar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: -20px;
    z-index: 1;
    background: #0f172a;
    margin: -20px -20px 0;
    padding: 14px 20px 10px;
    border-radius: 10px 10px 0 0;
}

.tatica-painel-subtitulo {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 6px;
}

.tatica-painel-corpo {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tatica-painel-label {
    font-size: 12px;
    color: var(--muted);
}

.tatica-painel-input {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text);
    font-size: 14px;
    width: 100%;
}

.tatica-painel-input:focus {
    outline: none;
    border-color: var(--accent);
}

.tatica-painel-erro {
    color: #fca5a5;
    font-size: 12px;
    background: #7f1d1d;
    border-radius: 4px;
    padding: 6px 10px;
    border: 1px solid #ef4444;
}

.tatica-painel-vazio {
    font-size: 12px;
    color: #475569;
    font-style: italic;
    padding: 8px 0;
}

.tatica-painel-acoes {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Lista de táticas ───────────────────────────────────── */
.lista-taticas {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tatica-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 10px;
    gap: 8px;
}

.tatica-item-nome {
    font-size: 13px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tatica-item-acoes {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}









/* ── Item predefinida na lista ──────────────────────────── */
.tatica-item-predefinida {
    border-color: var(--accent);
    background: rgba(56,189,248,0.06);
}

/* ── Confirmação de remoção de tática favorita ──────────── */
.fav-confirmar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

/* ── Sub-pos: substituto por baixo da posição ──────────── */
.sub-pos {
    position: absolute;
    left: 50%;
    top: calc(100% + 3px);
    transform: translateX(-50%);
    width: 52px;
    height: 20px;
    border: 2px dashed rgba(245,158,11,0.55);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: rgba(245,158,11,0.6);
    cursor: default;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-pos-drag-over {
    border-color: #f59e0b;
    background: rgba(245,158,11,0.15);
}

.sub-pos-ocupado {
    border-style: solid;
    border-color: #f59e0b;
    background: rgba(245,158,11,0.12);
    color: #fcd34d;
    font-weight: bold;
    cursor: grab;
    padding: 0 3px;
}

/* Sub-pos sempre visível quando a posição está ocupada */
/* Posições não ocupadas: sub-pos oculta */
.tatica-pos:not(.ocupado) .sub-pos {
    display: none;
}

/* ── Legenda substituições ──────────────────────────────── */
.tatica-legenda-sub {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
    color: rgba(245,158,11,0.8);
    background: rgba(245,158,11,0.07);
    border: 1px dashed rgba(245,158,11,0.35);
    border-radius: 6px;
    padding: 7px 10px;
    margin-top: 8px;
    line-height: 1.4;
}

.tatica-legenda-sub-icone {
    flex-shrink: 0;
    font-size: 14px;
    margin-top: 1px;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVO — telemóvel/tablet
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    /* O painel lateral "Info Jogador" fixo deixa de fazer sentido
       (dependia de "hover", que não existe em toque, e ocupava uma
       3ª coluna que obrigava a arrastar o ecrã). Passa a aparecer como
       uma "mini-modal" centrada, por cima de tudo, com fundo escurecido
       — ao tocar num jogador para consultar a informação, o campo fica
       completamente coberto (nunca parcialmente, o que impedia por
       vezes tocar noutro jogador que ficasse por baixo do painel
       anterior); fecha-se explicitamente com o ✕, tocando fora, ou ao
       tocar noutro jogador. */
    .tatica-info-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.65);
        z-index: 1199;
    }
    .tatica-info-backdrop.tatica-info-backdrop-visivel {
        display: block;
    }

    .tatica-info-painel {
        display: none;
        width: auto;
        margin-left: 0;
        position: fixed;
        left: 12px;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        max-height: 80vh;
        overflow-y: auto;
        z-index: 1200;
        box-shadow: 0 6px 30px rgba(0,0,0,0.6);
    }
    .tatica-info-painel.tatica-info-painel-visivel {
        display: flex;
    }
    .tatica-info-topo-linha {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        padding-bottom: 10px;
        margin-bottom: 10px;
        border-bottom: 1px solid #334155;
    }
    /* O título "Info Jogador" deixa de ser necessário neste formato —
       o painel já é claramente identificável por si só */
    .tatica-info-painel > .tatica-section-title {
        display: none;
    }
    /* O popup próprio de "Remover" deixa de ser usado em ecrãs
       pequenos — o botão passa a estar junto da própria informação do
       jogador (ver .tatica-info-btn-remover), evitando que os dois
       fiquem sobrepostos */
    .tatica-remove-popup {
        display: none !important;
    }
    .tatica-info-btn-remover.tatica-info-btn-remover-ativo {
        display: inline-block;
        padding: 7px 14px;
        font-size: 13px;
    }

    /* Sempre encostado à direita da linha, quer o botão "Remover"
       esteja presente (jogador em campo/banco) quer não (Plantel) */
    .tatica-info-fechar {
        margin-left: auto;
        display: flex;
        background: #1e293b;
        border: 1px solid #334155;
        color: var(--text);
        border-radius: 6px;
        width: 28px;
        height: 28px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 14px;
        flex-shrink: 0;
    }
    .tatica-info-vazio {
        display: none !important;
    }

    /* Mensagem de sucesso — no fundo do ecrã (bottom:30px) muitas vezes
       fica tapada pela barra de endereços do telemóvel ou pelo banner
       de cookies; no topo é sempre visível */
    .tatica-sucesso-toast {
        bottom: auto;
        top: 16px;
        max-width: 88vw;
        white-space: normal;
        text-align: center;
    }
}

/* ── Jogadores arrastáveis não são texto seleccionável ────────────
   A lista do plantel já tinha user-select: none; o campo, as
   substituições e o banco não. Junto com a limpeza da selecção no
   mousedown (tatica.js), evita que o browser arraste um bocado de
   página em vez do jogador. Não afecta o texto fora destes elementos. */
.campo-jogador,
.bench-jogador,
.sub-pos {
    -webkit-user-select: none;
    user-select: none;
}

/* Cores das posições — iguais às da lista do Plantel (.tj-pos) */
.pos-chip,
.campo-jogador .cj-pos.pos-chip { background: #334155; color: #fff; }
.pos-chip.GR,
.campo-jogador .cj-pos.pos-chip.GR { background: #7c3aed; }
.pos-chip.DC, .pos-chip.DD, .pos-chip.DE,
.campo-jogador .cj-pos.pos-chip.DC, .campo-jogador .cj-pos.pos-chip.DD, .campo-jogador .cj-pos.pos-chip.DE { background: #0369a1; }
.pos-chip.MC, .pos-chip.MD, .pos-chip.ME,
.campo-jogador .cj-pos.pos-chip.MC, .campo-jogador .cj-pos.pos-chip.MD, .campo-jogador .cj-pos.pos-chip.ME { background: #065f46; }
.pos-chip.AV,
.campo-jogador .cj-pos.pos-chip.AV { background: #b45309; }

/* Estrelas da Cap. Atual nos quadrados do campo e do banco */
.cj-estrelas {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;
}
.cj-estrelas .estrelas { display: inline-flex; }
.cj-estrelas .estrela { font-size: 8px; letter-spacing: -0.5px; }

/* Linha de condição física / lesão / suspensão nos quadrados */
.cj-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 9px;
    line-height: 1.1;
    white-space: nowrap;
    text-shadow: 0 0 2px #000;
}
.cj-info .tag-lesao,
.cj-info .tag-suspensao { font-size: 9px; padding: 0 2px; }

/* Suplentes (banco): duas linhas — posição + nome, e condição */
.bench-jogador {
    flex-direction: column;
    gap: 2px;
}
.bench-jogador .bj-linha {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    max-width: 100%;
    overflow: hidden;
}
.bench-jogador .bj-pos {
    font-size: 8px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 3px;
}
.bench-jogador .bj-nome { overflow: hidden; text-overflow: ellipsis; }

/* Rectângulo do substituto (por baixo de cada posição) */
.sub-pos .sp-pos {
    font-size: 7px;
    font-weight: bold;
    padding: 0 2px;
    margin-right: 2px;
    border-radius: 2px;
    flex-shrink: 0;
}
.sub-pos .sp-nome { overflow: hidden; text-overflow: ellipsis; }
.sub-pos .sp-ico { font-size: 8px; margin-left: 2px; flex-shrink: 0; }

/* Indisponível (lesionado ou suspenso neste jogo): sombreado mais escuro em todo o quadrado.
   Não impede de guardar — as substituições ainda podem ser aplicadas antes do jogo. */
.tatica-pos.ocupado.indisponivel { background: rgba(0,0,0,0.7); }
.bench-pos.ocupado.indisponivel  { background: rgba(0,0,0,0.6); }
.sub-pos-ocupado.indisponivel    { background: rgba(0,0,0,0.65); }

/* Movimento suave quando a linha se reajusta */
.tatica-pos { transition: border-color 0.15s, background 0.15s, left 0.2s ease; }

/* Campo mais alto (580px → 640px): dá espaço ao fundo para o rectângulo do
   substituto do GR ficar dentro do campo. As posições em modals.html já estão
   calculadas para esta altura (as linhas mantêm a mesma distância em px). */
.tatica-campo { height: 640px; }

/* Baliza da nossa equipa: fora do campo, por baixo do GR, com a abertura virada para o campo */
.campo-baliza {
    position: absolute;
    left: 50%;
    top: calc(100% + 3px);          /* logo abaixo da linha de fundo (3px = espessura da borda do campo) */
    transform: translateX(-50%);
    width: 84px;
    height: 24px;
    box-sizing: border-box;
    border: 3px solid rgba(255,255,255,0.9);
    border-top: none;               /* lado aberto, virado para o campo */
    border-radius: 0 0 3px 3px;
    background-color: rgba(255,255,255,0.08);
    /* rede */
    background-image:
        repeating-linear-gradient(0deg,  rgba(255,255,255,0.35) 0 1px, transparent 1px 6px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.35) 0 1px, transparent 1px 6px);
    pointer-events: none;
}

/* ── Plantel: barra Filtrar / Ordenar ─────────────────────── */
.tatica-plantel-barra {
    display: flex;
    gap: 5px;
    align-items: stretch;
    margin-bottom: 6px;
}

.tatica-ordenar-wrap { position: relative; flex: 1; min-width: 0; }
.tatica-ordenar-wrap .btn-tatica-barra { width: 100%; }

.btn-tatica-barra {
    background: #1e293b;
    color: var(--text);
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s, border-color 0.15s;
}
.btn-tatica-barra:hover { background: #263348; border-color: var(--accent); }
.btn-tatica-barra.ativo { border-color: var(--accent); color: #93c5fd; }
.btn-tatica-ordem { width: 30px; padding: 5px 0; flex-shrink: 0; }

.tf-contagem {
    display: inline-block;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    text-align: center;
}

.tatica-menu-ordenar {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.5);
    z-index: 30;
    display: flex;
    flex-direction: column;
    padding: 3px;
}
.tatica-menu-ordenar[style*="display: none"] { display: none !important; }

.tf-opcao {
    background: transparent;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
}
.tf-opcao:hover { background: #1e293b; }
.tf-opcao.ativa { background: #1e3a5f; color: #93c5fd; font-weight: bold; }
.tf-padrao { color: var(--muted); font-weight: normal; font-size: 10px; }

/* ── Painel Filtrar Plantel ───────────────────────────────── */
.tf-linhas { display: flex; flex-direction: column; gap: 6px; }

.tf-linha {
    display: grid;
    grid-template-columns: 110px 1fr 24px;
    align-items: center;
    gap: 8px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 6px 8px;
}
.tf-nome { font-size: 12px; font-weight: bold; }
.tf-ctrl { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tf-lbl { font-size: 11px; color: var(--muted); }

.tf-in {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 5px;
    padding: 5px 7px;
    color: var(--text);
    font-size: 12px;
    min-width: 0;
}
.tf-in:focus { outline: none; border-color: var(--accent); }
.tf-in-int { width: 46px; }
.tf-in-din { width: 96px; }
.tf-in-texto { width: 100%; }
.tf-adicionar { width: 100%; padding: 7px 9px; font-size: 13px; }

.tf-remover {
    background: transparent;
    border: none;
    color: #fca5a5;
    cursor: pointer;
    font-size: 14px;
}
.tf-remover:hover { color: #ef4444; }

/* ── Zoom da modal da tática (telemóvel) ──────────────────── */
.tatica-zoom-ctrl { display: none; gap: 4px; }
/* Linha no topo da caixa da tática, com os botões ao centro. Os botões anulam o zoom do pai
   para manterem sempre o mesmo tamanho (senão encolhiam com o zoom que controlam). */
.tatica-zoom-linha { display: none; text-align: center; padding: 6px 0 0; }
.tatica-zoom-linha .tatica-zoom-ctrl { zoom: calc(1 / var(--tz, 1)); }
.btn-zoom-tatica {
    position: relative;
    background: #1e293b;
    color: var(--text);
    border: 1px solid #334155;
    border-radius: 6px;
    width: 30px;
    height: 28px;
    padding: 0;
    /* O texto (− e +) fica escondido e os símbolos desenham-se com linhas, para ficarem
       sempre no centro exato do botão, seja qual for o tipo de letra do telemóvel */
    font-size: 0;
    line-height: 0;
    cursor: pointer;
}
.btn-zoom-tatica::before,
.btn-zoom-tatica::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    background: currentColor;
    border-radius: 1px;
    transform: translate(-50%, -50%);
}
.btn-zoom-tatica::before { width: 12px; height: 2px; }           /* traço horizontal (− e +) */
#btn-zoom-mais::after { width: 2px; height: 12px; }              /* traço vertical (só no +) */
#btn-zoom-menos::after { display: none; }
.btn-zoom-tatica:disabled { opacity: 0.35; cursor: default; }

/* Elementos fixos (painéis e mini-modal de informação) não devem encolher
   com o zoom: anula-se o zoom do pai para ficarem com o tamanho normal. */
.tatica-content .tatica-painel-overlay,
.tatica-content .tatica-info-painel,
.tatica-content .tatica-info-backdrop {
    zoom: calc(1 / var(--tz, 1));
}

@media (max-width: 900px) {
    .tatica-zoom-linha { display: block; }
    .tatica-zoom-ctrl { display: inline-flex; }
}

/* Com a modal aberta, a página por trás não faz scroll */
body.tatica-aberta { overflow: hidden; }
.modal-tatica { overscroll-behavior: contain; }

/* ── Tática Predefinida em página própria (/tatica) ───────── */
.tatica-pagina-info {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #0c2a4a;
    border: 1px solid #1e40af;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.45;
    color: #bfdbfe;
}

.tatica-pagina { overflow-x: auto; }

/* O conteúdo da modal, dentro da página: sem fecho, sem limite de altura
   (quem faz scroll é a página) e alinhado à esquerda */
.tatica-pagina .tatica-content {
    max-height: none;
    overflow: visible;
    margin: 0;
    border: 1px solid #334155;
}

/* Linha do título da página: título à esquerda, botões à direita (como no Treino) */
.tatica-pagina-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}
.tatica-pagina-topo h2 { margin: 0; }
.tatica-pagina-topo .tatica-header-acoes { flex-wrap: wrap; flex-shrink: 1; }

/* Na página, o botão principal é o Guardar Predefinida/Favoritos: mesmo azul do
   "Guardar Treino". Na modal de um jogo o principal é o Guardar Tática. */



/* A linha de cabeçalho da modal (título e info do jogo) não é usada na página */
.tatica-pagina .tatica-header { display: none; }

/* Sem isto o conteúdo largo da tática alargava a coluna principal e
   esmagava/sobrepunha o menu lateral. */
body.pagina-tatica .main-content { min-width: 0; }

/* Página da Tática no computador: colunas mais estreitas e menos espaço entre
   elas, para o painel "Info Jogador" caber sem ficar cortado à direita. */
@media (min-width: 901px) {
    .tatica-pagina .tatica-body { gap: 10px; padding: 6px 8px 16px 8px; }
    .tatica-pagina .tatica-plantel { width: 280px; }
    .tatica-pagina .tatica-campo-row { gap: 8px; }
    .tatica-pagina .tatica-info-painel { width: 215px; margin-left: 4px; }
}
