/* =========================================
   VARIÁVEIS GLOBAIS (CALIBRAGEM DE CONTRASTE)
   ========================================= */
:root {
    /* Cores de Fundo */
    --bg-body: #0f0f0f;       /* Preto Absoluto para profundidade */
    --bg-sidebar: #050505;    /* Sidebar quase preta */
    --bg-card: #252525;       /* Card mais claro para destacar texto */
    
    /* Cores de Texto (CORRIGIDO PARA ALTA VISIBILIDADE) */
    --text-primary: #ffffff;  /* Branco Puro (Antes era cinza claro) */
    --text-secondary: #d4d4d4; /* Prata Claro (Antes era cinza escuro ilegível) */
    
    /* Cores de Destaque */
    --accent-color: #00e676;  /* Verde Neon Mantido */
    --danger-color: #ff5252;  /* Vermelho Alerta */
    --primary-color: #26bc75; /* Verde mais vibrante */
    --hover-color: #333333;

    /* Dimensões */
    --sidebar-width: 250px;
    --header-height: 60px;
    
    /* Configuração de Fonte Global */
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* RESET E BASE */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400; /* Peso normal mais sólido */
    line-height: 1.6; /* Melhora leitura de parágrafos */
    height: 100vh;
    overflow: hidden;
}

/* FIX: Aumenta contraste de textos pequenos automaticamente */
small, .text-secondary, .modal-text, .history-date {
    color: var(--text-secondary) !important;
    font-weight: 500; /* Deixa letras miúdas mais 'gordinhas' */
}

/* LAYOUT GRID (SIDEBAR + CONTENT) */
.dashboard-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr; /* 250px + Resto */
    height: 100vh;
    width: 100vw;
}

/* ESTILOS DA SIDEBAR */
.sidebar {
    background-color: var(--bg-sidebar);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.brand h2 { color: var(--text-primary); font-weight: 300; }
.brand .highlight { color: var(--accent-color); font-weight: bold; }
.brand small { color: var(--text-secondary); font-size: 0.8rem; letter-spacing: 2px; }

.menu { margin-top: 40px; flex-grow: 1; }

.menu-item {
    display: block;
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 5px;
    background: none;
    border: none;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.menu-item:hover { background-color: var(--hover-color); color: var(--text-primary); }
.menu-item.active { background-color: var(--hover-color); color: var(--accent-color); border-left: 3px solid var(--accent-color); }

.footer-info { font-size: 0.8rem; color: var(--text-secondary); border-top: 1px solid #333; padding-top: 20px; }
.status-dot { display: inline-block; width: 8px; height: 8px; background-color: var(--accent-color); border-radius: 50%; margin-right: 5px; box-shadow: 0 0 5px var(--accent-color); }

/* ÁREA DE CONTEÚDO */
.content-area {
    background-color: var(--bg-body);
    display: flex;
    flex-direction: column;
    
    /* FIX: Permite rolar se o conteúdo for grande */
    overflow-y: auto; 
    height: 100vh;
    
    /* Transição suave de telas */
    transition: opacity 0.2s ease-in-out;
    opacity: 1;
}

.top-bar {
    height: var(--header-height);
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    background-color: var(--bg-body);
}

.widgets-container { padding: 30px; }

/* COMPONENTE: CARD GENÉRICO */
.card {
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* EFEITO DE TRANSIÇÃO DE TELA */
.content-area {
    transition: opacity 0.2s ease-in-out;
    opacity: 1;
}

/* HEADER DINÂMICO */
.top-bar h3 {
    color: var(--accent-color);
    font-weight: 500;
}

/* ESTILOS DO VOLANTE (GERADOR) */

.volante-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.lottery-grid {
    display: grid;
    /* Cria 5 colunas automaticamente */
    grid-template-columns: repeat(5, 1fr); 
    gap: 15px;
    margin: 20px 0;
}

.loto-ball {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--bg-body);
    border: 2px solid #444;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Efeito elástico */
    
    /* Centralizar o número */
    display: flex;
    justify-content: center;
    align-items: center;
}

.loto-ball:hover {
    border-color: var(--text-secondary);
    transform: scale(1.1);
}

/* Estado: Selecionado */
.loto-ball.selected {
    background-color: var(--accent-color);
    color: #000; /* Texto preto para contraste no verde neon */
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

/* --- INÍCIO DO CÓDIGO (CADEADO) --- */

/* Estado: Fixo (Cadeado) - Prioridade Visual */
.loto-ball.fixed {
    background: linear-gradient(145deg, #ffd700, #b29700) !important; /* Dourado Elite */
    color: #000 !important; /* Texto preto para leitura */
    border-color: #ffd700 !important;
    font-weight: 900;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    transform: scale(1.05); /* Leve destaque de tamanho */
    position: relative; /* Necessário para o ícone */
    z-index: 2;
}

/* Pequeno ícone de cadeado flutuante */
.loto-ball.fixed::after {
    content: '🔒';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.7rem;
    background: #000;
    border: 1px solid #ffd700;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    color: #ffd700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Efeito de hover no fixo */
.loto-ball.fixed:hover::after {
    transform: scale(1.2); /* Cadeado cresce ao passar mouse */
}

/* --- FIM DO CÓDIGO --- */

/* Painel de Estatísticas do Jogo Atual */
.selection-info {
    display: flex;
    gap: 20px;
    background: #111;
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid #333;
}

.stat-badge {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stat-badge span {
    color: var(--text-primary);
    font-weight: bold;
    margin-left: 5px;
}

/* COLE NO FINAL: CUSTOM SCROLLBAR (Visual Clean) */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body); 
}
::-webkit-scrollbar-thumb {
    background: #333; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color); 
}

/* Ajuste de segurança para o container do gerador não cortar */
.volante-container {
    padding-bottom: 50px; /* Garante espaço para os botões */
}

/* COLE NO FINAL: ESTILOS DO HISTÓRICO */

.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 40px;
}

.history-card {
    background-color: var(--bg-card);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.2s;
}

.history-card:hover {
    border-color: #555;
    transform: translateX(5px); /* Efeito sutil de movimento */
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 8px;
    margin-bottom: 5px;
}

.history-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.history-status {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

.status-ok { background: rgba(0, 230, 118, 0.1); color: var(--accent-color); }
.status-danger { background: rgba(255, 82, 82, 0.1); color: var(--danger-color); }

/* Mini bolinhas para o histórico (menores que as do gerador) */
.mini-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.mini-ball {
    width: 30px;
    height: 30px;
    background: #111;
    border: 1px solid #444;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: #e0e0e0;
}

.history-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-delete {
    background: transparent;
    border: 1px solid #333;
    color: #888;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
}
.btn-delete:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* COLE NO FINAL: MODAL CUSTOMIZADO (ELITE UI) */

/* Fundo Escuro (Overlay) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Bem escuro para foco */
    backdrop-filter: blur(4px); /* Efeito de vidro fosco */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Fica acima de tudo */
    opacity: 0;
    pointer-events: none; /* Não clica quando invisível */
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Caixa do Modal */
.modal-box {
    background: var(--bg-card);
    border: 1px solid #333;
    width: 400px;
    max-width: 90%;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Botões do Modal */
.btn-modal {
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    border: none;
    transition: all 0.2s;
}

.btn-cancel {
    background: transparent;
    border: 1px solid #444;
    color: #888;
}
.btn-cancel:hover {
    background: #333;
    color: #fff;
}

.btn-confirm {
    background: var(--danger-color); /* Vermelho para deletar */
    color: #fff;
    box-shadow: 0 4px 10px rgba(255, 82, 82, 0.3);
}
.btn-confirm:hover {
    background: #ff1744;
    transform: translateY(-2px);
}

/* =========================================
   📱 MODO MOBILE (WEB APP RESPONSIVO)
   ========================================= */

@media (max-width: 768px) {
    /* 1. LAYOUT PRINCIPAL */
    .dashboard-layout {
        display: flex;
        flex-direction: column;
        height: 100dvh;
    }

    /* 2. MENU LATERAL VIRA BARRA INFERIOR COM SCROLL HORIZONTAL */
    .sidebar {
        order: 2; 
        flex-direction: row;
        width: 100vw;
        height: 80px; /* Aumentado para acomodar o texto */
        padding: 0 10px;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 100;
        border-right: none;
        border-top: 1px solid #333;
        background-color: rgba(5, 5, 5, 0.98);
        backdrop-filter: blur(10px);
        align-items: center;
        display: flex;
        overflow-x: auto; /* ATENÇÃO: Isso permite deslizar os botões */
        overflow-y: hidden;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch; /* Scroll suave no iPhone */
    }

    /* Esconde a barra de scroll para ficar com visual de App */
    .sidebar::-webkit-scrollbar { display: none; }

    .brand, .footer-info {
        display: none;
    }

    .menu {
        margin-top: 0;
        display: flex;
        width: auto;
        justify-content: flex-start;
        align-items: center;
        gap: 15px;
        padding: 0 15px;
    }

    .menu-item {
        min-width: 75px; /* Não deixa o botão esmagar */
        padding: 8px 5px;
        font-size: 0.7rem;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        background: none;
        border: none;
        color: var(--text-secondary);
        border-radius: 8px;
    }

    /* Destaque para o Botão Sair no Mobile */
    #btn-logout {
        color: var(--danger-color) !important;
        font-weight: bold;
    }

    .menu-item.active {
        border-left: none;
        background-color: rgba(0, 230, 118, 0.1);
        color: var(--accent-color);
    }

    .menu-item::first-letter {
        font-size: 1.2rem;
    }

    /* 3. ÁREA DE CONTEÚDO */
    .content-area {
        order: 1;
        height: calc(100dvh - 80px);
        padding-bottom: 20px;
        overflow-y: auto;
    }

    .top-bar {
        padding: 0 15px;
        height: 50px;
    }

    .top-bar h3 { font-size: 1rem; }
    .widgets-container { padding: 15px; }

    /* 4. O VOLANTE */
    .lottery-grid {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
        gap: 8px;
        max-width: 100%;
    }

    .loto-ball {
        width: 42px;
        height: 42px;
        font-size: 0.9rem;
    }

    /* 5. ESTATÍSTICAS */
    .selection-info {
        flex-direction: column;
        gap: 8px;
        width: 90%;
    }

    .modal-box { width: 95%; padding: 15px; }
}