/* =========================================
   1. VARIÁVEIS E TEMA (Design System)
   ========================================= */
:root {
    /* Paleta de Cores */
    --primary: #10B981;       /* Verde Esmeralda (Ação Principal) */
    --primary-dark: #059669;  /* Verde Escuro (Hover) */
    --secondary: #E5E7EB;     /* Cinza Claro (Botões Secundários) */
    --dark: #1F2937;          /* Preto Suave (Backgrounds Escuros) */
    --bg-page: #F3F4F6;       /* Fundo da Página */
    --white: #FFFFFF;
    
    /* Cores de Estado */
    --danger: #EF4444;        /* Vermelho (Erro/Sair) */
    --warning: #F59E0B;       /* Dourado (MVP) */
    --text-main: #111827;     /* Texto Principal */
    --text-muted: #6B7280;    /* Texto Secundário */

    /* Espaçamento e Formas */
    --radius: 12px;           /* Arredondamento padrão */
    --header-height: 60px;
    --nav-height: 75px;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-fab: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
}

/* =========================================
   2. RESET E BASE
   ========================================= */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove highlight azul no mobile */
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    padding-bottom: 100px; /* Espaço para não esconder conteúdo atrás da nav */
    line-height: 1.5;
}

/* =========================================
   3. CABEÇALHO (HEADER)
   ========================================= */
header {
    background-color: var(--dark);
    color: var(--white);
    padding: 0 20px;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-md);
}

header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

#live-indicator {
    background-color: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    animation: blink 2s infinite;
}

@keyframes blink { 50% { opacity: 0.5; } }

/* =========================================
   4. LAYOUT E ABAS
   ========================================= */
main {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
}

.tab-content {
    display: none;
    animation: fadeUp 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cartões (Cards) */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.highlight-card {
    border: 2px dashed #D1D5DB;
    background-color: #F9FAFB;
    text-align: center;
}

.danger-zone {
    border: 1px solid #FECACA;
    background-color: #FEF2F2;
}

.divider {
    height: 1px;
    background-color: #E5E7EB;
    margin: 25px 0;
}

/* =========================================
   5. BOTÕES (Flexbox & Centralização)
   ========================================= */
button {
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.1s, opacity 0.2s;
    
    /* Centralização perfeita Ícone + Texto */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px; 
}

button:active { transform: scale(0.97); }

/* Estilos de Botão */
.btn-primary {
    background-color: var(--primary);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    padding: 14px;
    border-radius: var(--radius);
    width: 100%;
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--dark);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
}

.btn-danger {
    background-color: var(--danger);
    color: var(--white);
    font-weight: bold;
    padding: 12px;
    border-radius: var(--radius);
    width: 100%;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px;
    border-radius: var(--radius);
    font-weight: 600;
    width: 100%;
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.full-width { width: 100%; }
.big-btn { font-size: 1.1rem; padding: 18px; }

/* =========================================
   6. INPUTS E FORMULÁRIOS
   ========================================= */
input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 14px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--white);
    appearance: none;
    margin-bottom: 15px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
}

/* Input com legenda pequena (Goal Limit) */
.input-with-icon small {
    display: block;
    margin-top: -10px;
    margin-bottom: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Segment Control (Botões de Tempo) */
.segment-control {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.segment {
    flex: 1;
    background: var(--white);
    border: 1px solid #D1D5DB;
    padding: 10px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
}
.segment.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* =========================================
   7. PLACAR E JOGO
   ========================================= */
.scoreboard {
    background: linear-gradient(145deg, #1F2937, #111827);
    color: white;
    border-radius: 16px;
    padding: 25px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    box-shadow: var(--shadow-md);
}

.team-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.team-name {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #9CA3AF;
    margin: 0 0 10px 0;
    letter-spacing: 1px;
}

.score-display {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 10px;
}

.btn-goal {
    background: var(--white);
    color: var(--dark);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.timer-box {
    width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#timer-display {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: #E5E7EB;
    margin-bottom: 10px;
}

.btn-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 1.2rem;
}

/* Jogadores em Campo (NOVO) */
.players-on-field {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 10px;
}
.field-column {
    flex: 1;
    padding: 0 5px;
}
.field-column small {
    display: block;
    text-align: center;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
    font-size: 0.7rem;
    text-transform: uppercase;
}
.mini-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-main);
}
.mini-list li {
    padding: 4px 0;
    border-bottom: 1px solid #F3F4F6;
}
.mini-list li:last-child { border-bottom: none; }

/* Feed */
.feed-section {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
}
.feed-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
    max-height: 120px;
    overflow-y: auto;
}
.feed-list li {
    font-size: 0.9rem;
    padding: 5px 0;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================================
   8. FILA E DRAG & DROP
   ========================================= */
.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.badge {
    background: var(--dark);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

.list-group {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.list-group li {
    padding: 16px;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
}

.list-group li:last-child { border-bottom: none; }

.remove-btn {
    color: var(--danger);
    padding: 8px;
    cursor: pointer;
}

.empty-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-style: italic;
}

/* Drag Styling */
.drag-handle {
    color: #9CA3AF;
    cursor: grab;
    padding: 8px 12px 8px 0;
    font-size: 1.1rem;
}

.sortable-ghost {
    background-color: #ECFDF5 !important; /* Verde bem claro */
    border: 1px dashed var(--primary);
    opacity: 0.9;
}

/* =========================================
   9. ESTATÍSTICAS (MVP)
   ========================================= */
.mvp-highlight {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 20px -5px rgba(245, 158, 11, 0.4);
    margin-bottom: 25px;
}

.mvp-highlight .crown { font-size: 2.5rem; display: block; margin-bottom: 10px; }
.mvp-highlight h1 { font-size: 2.2rem; margin: 5px 0; font-weight: 800; }
.mvp-highlight p { font-size: 1.1rem; opacity: 0.9; margin: 0; }

.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th { text-align: left; color: var(--text-muted); font-size: 0.85rem; padding-bottom: 10px; }
.stats-table td { padding: 12px 0; border-bottom: 1px solid #F3F4F6; font-size: 0.95rem; }
.stats-table strong { color: var(--primary); }

/* =========================================
   10. FAB (BOTÃO FLUTUANTE) & NAV
   ========================================= */
.fab {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    box-shadow: var(--shadow-fab);
    z-index: 90;
    font-size: 1.5rem;
}
.fab:active { transform: scale(0.9); }

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--white);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #E5E7EB;
    z-index: 100;
}

.nav-item {
    background: none;
    flex-direction: column;
    color: #9CA3AF;
    width: 100%;
    height: 100%;
    gap: 4px;
    font-size: 0.8rem;
}

.nav-item i { font-size: 1.4rem; }
.nav-item.active { color: var(--primary); }

/* =========================================
   11. MODAIS
   ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden { display: none !important; }

.modal-content {
    background: var(--white);
    width: 90%;
    max-width: 400px;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Grid de Botões (Seleção) */
.grid-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

/* Botão de Rotação (Azul Informativo) */
.btn-info {
    background-color: #3B82F6; /* Azul */
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 16px;
    border-radius: var(--radius);
    width: 100%;
    margin-bottom: 10px;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.4);
}
.btn-info:active { transform: scale(0.98); }

/* =========================================
   11. MODAIS
   ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden { display: none !important; }

.modal-content {
    background: var(--white);
    width: 90%;
    max-width: 400px;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Grid de Botões (Seleção) */
.grid-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

/* Botão de Rotação (Azul Informativo) */
.btn-info {
    background-color: #3B82F6; /* Azul */
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 16px;
    border-radius: var(--radius);
    width: 100%;
    margin-bottom: 10px;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.4);
}
.btn-info:active { transform: scale(0.98); }

/* =========================================
   12. TOAST NOTIFICATIONS
   ========================================= */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
    pointer-events: none;
}

.toast {
    background: var(--white);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    border-left: 4px solid var(--primary);
    min-width: 280px;
}

.toast.success {
    border-left-color: var(--primary);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.info {
    border-left-color: #3B82F6;
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--primary);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast.info .toast-icon {
    color: #3B82F6;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: var(--text-main);
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: toastSlideOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Responsivo para Mobile */
@media (max-width: 480px) {
    #toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
    }
}