/* ==========================================
   1. VARIÁVEIS E RESETS
   ========================================== */
:root {
    /* Cores Dinâmicas injetadas pelo motor PHP no Header do arquivo chamador ou via :root inline no PHP */
    --primary: #f4665c; /* Fallback */
    --primary-hover: #212529; /* Fallback */
    --icon-bg: rgba(244, 102, 92, 0.1); /* Fallback */
    
    --bg-light: #f8fafc;
    --bg-auth: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --white: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --accent: #ead300;
    
    /* Variáveis Adicionais para Torneios */
    --dark-grey: #1a1a1a;
    --medium-grey: #9a9693;
    --light-grey: #f3f4f6;
    
    /* Ranking Colors */
    --gold: #fef3c7; --gold-text: #92400e;
    --silver: #f1f5f9; --silver-text: #475569;
    --bronze: #ffedd5; --bronze-text: #9a3412;
}

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

a { text-decoration: none !important; }

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-light);
    line-height: 1.5;
}

body.auth-screen { background: var(--bg-auth); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
body.app-screen { background-color: var(--bg-light); padding-bottom: 80px; }

/* ==========================================
   2. NAVEGAÇÃO (nav.php)
   ========================================== */
.navbar, .top-nav {
    background: var(--white) !important;
    padding: 10px 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: 65px;
}

.logo-nav { height: 40px; width: auto; object-fit: contain; }
.nav-title { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.btn-back { color: var(--text-muted); font-size: 1.1rem; margin-right: 12px; display: inline-flex; align-items: center; }

/* ==========================================
   3. DASHBOARD (dashboard.php)
   ========================================== */
.plan-badge { 
    display: inline-block; padding: 4px 12px; border-radius: 20px; 
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase; 
    margin-bottom: 1rem; background: var(--icon-bg); 
    color: var(--primary); border: 1px solid var(--primary); 
}

.menu-grid { 
    display: grid; grid-template-columns: 1fr; gap: 1rem; 
    padding: 0 1.5rem; max-width: 500px; margin: 1.5rem auto; 
}

.menu-card { 
    background: var(--white); border-radius: 20px; padding: 1.25rem; 
    transition: 0.3s; border: 1px solid rgba(226, 232, 240, 0.8); 
    display: flex; align-items: center; gap: 1.25rem; 
    position: relative; color: var(--text-main);
}

.menu-card:hover { transform: scale(1.02); border-color: var(--primary); }

.icon-box { 
    width: 54px; height: 54px; border-radius: 14px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 1.5rem; flex-shrink: 0; 
    background: var(--icon-bg); color: var(--primary); 
}

#copyToast { 
    display: none; position: fixed; bottom: 30px; left: 50%; 
    transform: translateX(-50%); background: #1e293b; color: white; 
    padding: 12px 25px; border-radius: 50px; font-size: 0.85rem; 
    z-index: 2000; box-shadow: 0 10px 15px rgba(0,0,0,0.2); 
}

/* ==========================================
   4. MEMBROS (membros.php)
   ========================================== */
.member-card {
    background: var(--white); border-radius: 20px; padding: 15px;
    margin: 12px 1.25rem; border: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    transition: 0.2s;
}

.member-initial {
    width: 48px; height: 48px; background: var(--icon-bg);
    color: var(--primary); border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.3rem;
}

.fab-add {
    position: fixed; bottom: 25px; right: 25px;
    background: var(--primary); color: white;
    width: 60px; height: 60px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 1000; transition: 0.2s;
}
.fab-add:active { transform: scale(0.9); }

/* ==========================================
   5. RANKING (ranking.php)
   ========================================== */
.ranking-card {
    background: var(--white); border-radius: 24px; border: 1px solid var(--border-color);
    overflow: hidden; margin: 20px 1.25rem; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 0.65rem; text-transform: uppercase; color: var(--text-muted); background: #f9fafb; padding: 15px; font-weight: 800; text-align: left; }
.table td { vertical-align: middle; padding: 15px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: 0.2s; }
.table tr:hover td { background-color: #f8fafc; }

.pos-badge { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem; }
.pos-1 { background: var(--gold); color: var(--gold-text); border: 1px solid #fde68a; } 
.pos-2 { background: var(--silver); color: var(--silver-text); } 
.pos-3 { background: var(--bronze); color: var(--bronze-text); }

/* ==========================================
   6. JOGOS (jogos.php)
   ========================================== */
.game-card { background: white; border-radius: 20px; border: 1px solid #e2e8f0; margin-bottom: 15px; overflow: hidden; position: relative; }
.team-box { padding: 15px; }
.player-name { font-weight: 700; font-size: 0.9rem; color: #1e293b; }
.score-badge { width: 40px; height: 40px; background: #f1f5f9; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; }
.score-badge.winner { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.vs-tag { font-size: 0.65rem; font-weight: 900; color: #94a3b8; text-align: center; margin: -5px 0; }
.point-badge { font-size: 0.65rem; background: var(--icon-bg); color: var(--primary); padding: 4px 10px; border-radius: 8px; font-weight: 700; }
.text-primary { color: var(--primary) !important; }

/* ==========================================
   7. GESTÃO DE TORNEIO (gerenciar_torneio.php)
   ========================================== */
.tournament-header { padding: 30px 20px; text-align: center; }
.status-pill { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; padding: 5px 12px; border-radius: 20px; margin-bottom: 12px; display: inline-block; }
.badge-insc-abertas { background: var(--primary); color: white; }
.container .menu-grid { grid-template-columns: 1fr 1fr; gap: 15px; padding: 20px; max-width: 600px; margin: 0 auto; }
.menu-item { background: white; border-radius: 22px; padding: 22px 15px; text-align: center; text-decoration: none; color: inherit; border: 1px solid #e2e8f0; display: flex; flex-direction: column; align-items: center; gap: 12px; transition: all 0.3s ease; position: relative; }
.menu-item:hover:not(.disabled) { transform: translateY(-5px); border-color: var(--primary); }
.menu-item.disabled { opacity: 0.5; cursor: not-allowed; background: #f1f5f9; }
.menu-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; background: var(--icon-bg); color: var(--primary); }
.item-label { font-weight: 700; font-size: 0.85rem; }

#customToast { 
    display: none; position: fixed; bottom: 30px; left: 50%; 
    transform: translateX(-50%); background: #1e293b; color: white; 
    padding: 12px 25px; border-radius: 50px; font-size: 0.85rem; 
    z-index: 2000; box-shadow: 0 10px 15px rgba(0,0,0,0.2); 
}

/* ==========================================
   8. FORMULÁRIOS E MODAIS (GLOBAL)
   ========================================== */
.modal-content { border: none; border-radius: 28px; }
.form-select-sm, .form-control-sm { border-radius: 8px; font-size: 0.8rem; }
.btn-primary { background-color: var(--primary) !important; border: none !important; border-radius: 12px; font-weight: 700; transition: 0.2s; }
.btn-primary:hover { background-color: #212529 !important; }

/* ==========================================
   9. RESPONSIVIDADE
   ========================================== */
@media (min-width: 768px) {
    .menu-grid { grid-template-columns: 1fr 1fr; max-width: 800px; }
    .ranking-card { margin: 20px auto; max-width: 800px; }
}

/* ==========================================
   10. TORNEIOS GERAL (torneios.php)
   ========================================== */
.tournament-card { background: var(--white); border-radius: 24px; padding: 0; border: 1px solid #e2e8f0; margin-bottom: 25px; overflow: hidden; position: relative; display: block; text-decoration: none; color: inherit; transition: transform 0.3s ease; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }
.tournament-card:hover { transform: translateY(-5px); border-color: var(--primary); }
.tournament-img-container { width: 100%; height: 220px; overflow: hidden; background-color: var(--medium-grey); }
.tournament-img { width: 100%; height: 100%; object-fit: cover; }
.tournament-card .card-body { padding: 22px; }
.btn-delete { position: absolute; top: 15px; right: 15px; background: rgba(255, 255, 255, 0.9); color: var(--danger); width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; border: none; z-index: 10; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.badge-primary-pontus { background: var(--primary); color: var(--white); }
.status-badge { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; padding: 6px 12px; border-radius: 8px; margin-bottom: 12px; display: inline-block; }
.tournament-name { font-size: 1.2rem; font-weight: 800; color: var(--dark-grey); margin-bottom: 8px; }
.tournament-info { font-size: 0.8rem; color: var(--medium-grey); display: flex; gap: 18px; font-weight: 600; }
.tournament-info i { color: var(--primary); margin-right: 5px; }
body .fab-add { width: 65px; height: 65px; bottom: 30px; right: 30px; font-size: 1.8rem; box-shadow: 0 8px 25px rgba(0,0,0,0.1); }
.btn-create { background: var(--primary); color: var(--white); border: none; border-radius: 18px; padding: 16px; font-weight: 800; text-transform: uppercase; width: 100%; }

/* ==========================================
   11. CONFIGURAR LOCAL (torneio_local.php)
   ========================================== */
.card-local { background: var(--white); border-radius: 28px; padding: 25px; border: 1px solid var(--border-color); margin-top: 25px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }
.card-local .form-label { font-weight: 700; font-size: 0.85rem; color: var(--medium-grey); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.card-local .form-control, .card-local .form-select { border-radius: 14px; padding: 14px; border: 1px solid var(--border-color); background: #f9fafb; font-size: 0.95rem; }
.card-local .form-control:focus, .card-local .form-select:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 4px rgba(244, 102, 92, 0.1); }
.court-input-group { background: #f8fafc; padding: 15px; border-radius: 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; border: 1px solid #f1f5f9; }
.court-icon-box { width: 44px; height: 44px; background: var(--icon-bg); color: var(--primary); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; flex-shrink: 0; }
.btn-save { background: var(--primary); color: var(--white); border-radius: 18px; font-weight: 800; width: 100%; padding: 16px; border: none; margin-top: 20px; text-transform: uppercase; letter-spacing: 1px; box-shadow: 0 4px 12px rgba(244, 102, 92, 0.2); transition: all 0.2s; }
.btn-save:hover { background: var(--primary-hover); transform: translateY(-2px); }
.btn-save:active { background: var(--primary-hover); transform: translateY(-2px); }
.btn-save:focus { background: var(--primary-hover); transform: translateY(-2px); }
.card-local .input-group-text { border-radius: 14px 0 0 14px; background: #f9fafb; border: 1px solid var(--border-color); border-right: none; color: var(--medium-grey); }
.card-local .input-group .form-control { border-radius: 0 14px 14px 0; border-left: none; }

/* ==========================================
   12. INSCRIÇÕES (torneio_inscricao.php)
   ========================================== */
.nav-tabs { border: none; gap: 5px; margin-bottom: 20px; }
.nav-tabs .nav-link { border: 1px solid var(--border-color) !important; border-radius: 12px !important; color: var(--medium-grey); font-weight: 600; font-size: 0.85rem; padding: 10px 15px; transition: 0.2s; }
.nav-tabs .nav-link.active { background: var(--primary) !important; color: white !important; border-color: var(--primary) !important; }
.card-form { background: white; border-radius: 20px; border: 1px solid var(--border-color); padding: 20px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.member-item { display: flex; align-items: center; padding: 10px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.member-item:last-child { border-bottom: none; }
.member-item input { width: 18px; height: 18px; margin-right: 12px; accent-color: var(--primary); }
.inscrito-card { background: white; border-radius: 15px; padding: 12px 15px; margin-bottom: 10px; border: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
#membros_lote_container { max-height: 200px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: 12px; margin-bottom: 20px; background: #ffffff; }

/* ==========================================
   13. ESTRUTURA E REGRAS (torneio_regras.php)
   ========================================== */
.section-title { font-weight: 700; font-size: 0.85rem; color: var(--medium-grey); margin: 25px 0 15px; text-transform: uppercase; letter-spacing: 1px; }
.card-regras { background: white; border-radius: 24px; padding: 25px; border: 1px solid var(--border-color); }
.option-card { background: white; border: 2px solid var(--border-color); border-radius: 16px; padding: 15px; margin-bottom: 12px; cursor: pointer; transition: 0.2s; position: relative; }
.option-card.selected { border-color: var(--primary); background: var(--icon-bg); }
.option-card input { position: absolute; opacity: 0; }
.chave-item, .fase-item { background: #f8fafc; border-radius: 18px; padding: 15px; border: 1px solid var(--border-color); margin-bottom: 15px; position: relative; }
.btn-add { border: 2px dashed #cbd5e1; color: var(--medium-grey); background: white; border-radius: 15px; padding: 12px; width: 100%; font-weight: 600; transition: 0.2s; margin-bottom: 20px; }
.remove-btn { position: absolute; top: -10px; right: -10px; background: #fee2e2; color: var(--danger); border: none; width: 28px; height: 28px; border-radius: 50%; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); z-index: 10; }
.vaga-select { background: #fff; border-radius: 10px; border: 1px solid var(--border-color); padding: 8px; font-weight: 600; font-size: 0.9rem; width: 100%; }
.vaga-select.is-invalid { border-color: var(--danger); background-color: #fff1f2; }
.footer-save { position: fixed; bottom: 0; left: 0; right: 0; background: white; padding: 15px; box-shadow: 0 -5px 15px rgba(0,0,0,0.05); z-index: 1000; }
.total-badge { position: sticky; top: 80px; z-index: 900; background: var(--dark-grey); color: white; border-radius: 50px; padding: 8px 20px; font-weight: 700; font-size: 0.8rem; display: inline-block; margin-bottom: 10px; }
.total-badge.error { background: var(--danger); }


/* ==========================================
   14. CONFIGURAÇÃO DE PONTOS (torneio_pontuacao.php)
   ========================================== */
.card-config { background: var(--white); border-radius: 28px; padding: 25px; border: 1px solid var(--border-color); margin-top: 20px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }
.section-label { font-weight: 800; font-size: 0.75rem; color: var(--medium-grey); text-transform: uppercase; margin: 20px 0 12px; display: block; letter-spacing: 0.5px; }
.point-box { background: var(--white); border-radius: 20px; padding: 12px 18px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--border-color); transition: 0.2s; }
.point-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(244, 102, 92, 0.1); }
.point-info { display: flex; align-items: center; gap: 15px; }
.point-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--icon-bg); color: var(--primary); font-size: 1.2rem; }
.label-text { font-weight: 700; font-size: 0.9rem; color: var(--text-main); }
.point-input { border: none; background: #f1f5f9; text-align: center; font-weight: 800; font-size: 1.1rem; width: 70px; height: 45px; color: var(--primary); border-radius: 12px; outline: none; }
.info-alert { background: #fef2f2; border: 1px solid #fee2e2; color: var(--text-main); border-radius: 18px; padding: 15px; font-size: 0.8rem; margin-bottom: 25px; display: flex; gap: 12px; align-items: flex-start; }

/* ==========================================
   15. SORTEIO DAS CHAVES (torneio_sorteio.php)
   ========================================= */
.mode-card { background: white; border-radius: 24px; padding: 20px; border: 1px solid #e2e8f0; margin-bottom: 15px; cursor: pointer; transition: all 0.3s ease; }
.mode-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 10px 20px rgba(244, 102, 92, 0.1); }
.icon-circle { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--icon-bg); color: var(--primary); font-size: 1.1rem; }
.card-box { background: white; border-radius: 28px; overflow: hidden; border: 1px solid #e2e8f0; margin-top: 25px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.box-header { background: var(--dark-grey); color: white; padding: 12px 18px; font-weight: 800; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
.table-stats th { font-size: 0.6rem; text-transform: uppercase; color: var(--medium-grey); background: #f9fafb; text-align: center; border-bottom: 1px solid #f1f5f9; padding: 12px 5px; font-weight: 800; }
.table-stats td { text-align: center; font-size: 0.85rem; padding: 10px 5px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.dupla-nomes { line-height: 1.2; color: var(--text-main); font-size: 0.85rem; display: block; }
.match-row { border-top: 1px solid #f1f5f9; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: 0.2s; }
.match-row:active { background-color: #f9fafb; }
.score-pill { background: var(--icon-bg); color: var(--primary); font-weight: 800; padding: 6px 12px; border-radius: 10px; font-size: 0.9rem; border: 1px solid <?= $config_esporte['cor_primaria'] ?>33; }
.text-pos { color: #2563eb !important; }
.text-neg { color: #ef4444 !important; }
.match-info-bar { font-size: 0.65rem; color: var(--medium-grey); display: flex; gap: 10px; margin-top: 4px; font-weight: 700; text-transform: uppercase; }
.match-info-bar i { color: var(--primary); }
.btn-reset-nav { color: var(--primary); font-weight: 800; font-size: 0.75rem; text-transform: uppercase; border: 1px solid var(--primary); padding: 5px 12px; border-radius: 50px; background: transparent; transition: 0.2s; }
.btn-reset-nav:hover { background: var(--primary); color: white; }
.btn-confirm { background: var(--primary); color: white; border-radius: 18px; font-weight: 800; padding: 16px; border: none; box-shadow: 0 4px 12px rgba(244, 102, 92, 0.2); width: 100%; transition: 0.2s; }
.btn-confirm:hover { background: var(--primary-hover); }

/* ==========================================
   16. PERFIL DO UTILIZADOR (perfil.php)
   ========================================== */
.profile-card { 
    background: var(--white); border-radius: 24px; padding: 20px; 
    border: 1px solid var(--border-color); margin-bottom: 20px; 
}

.ranking-link-box { 
    background: #f1f5f9; padding: 15px; border-radius: 15px; 
    display: flex; align-items: center; justify-content: space-between; 
    border: 1px dashed #cbd5e1; margin-top: 5px; 
}

.ranking-url { 
    color: var(--primary); font-weight: 700; font-size: 0.85rem; 
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; 
    max-width: 80%; 
}

.plan-item { 
    border: 2px solid var(--border-color); border-radius: 16px; 
    padding: 15px; margin-bottom: 12px; display: flex; 
    align-items: center; justify-content: space-between; 
    cursor: pointer; transition: 0.2s; 
}

.plan-item.active { 
    border-color: var(--primary); background: var(--icon-bg); 
}

.icon-plan { 
    width: 40px; height: 40px; border-radius: 10px; 
    background: var(--icon-bg); color: var(--primary); 
    display: flex; align-items: center; justify-content: center; 
    margin-right: 15px; font-size: 1.1rem; 
}

.plan-name { font-weight: 700; display: block; color: var(--text-main); }
.plan-desc { font-size: 0.8rem; color: var(--text-muted); }

.btn-save-profile { 
    background: var(--primary); color: var(--white); border-radius: 12px; 
    font-weight: 700; width: 100%; padding: 14px; border: none; 
    margin-top: 10px; transition: 0.2s; 
    box-shadow: 0 4px 10px rgba(244, 102, 92, 0.2); 
}
.btn-save-profile:hover { background: var(--primary-hover); transform: translateY(-1px); }