/* public/modules/roleta/style.css */

:root {
    --glass-bg: rgba(13, 17, 23, 0.9);
    --glass-border: rgba(255, 255, 255, 0.08);
    --neon-accent: var(--neon-pink, #ff0055);
    --text-main: #e6edf3;
    --text-muted: #8b949e;
}

body {
    background-color: #050510;
    font-family: 'Rajdhani', sans-serif;
    overflow: hidden; /* Impede rolagem da página inteira */
    height: 100vh;
    display: flex; flex-direction: column;
    margin: 0;
}

/* Fundo Tecnológico */
.bg-grid {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(rgba(255, 0, 85, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 0, 85, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1; pointer-events: none;
}

/* --- HEADER --- */
.app-header {
    height: 60px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(5, 5, 16, 0.8);
    backdrop-filter: blur(10px);
    flex-shrink: 0; z-index: 100;
}
.btn-back { 
    color: white; text-decoration: none; opacity: 0.7; transition: 0.2s; 
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
}
.btn-back:hover { opacity: 1; background: rgba(255,255,255,0.1); color: var(--neon-accent); }
.app-logo { font-size: 1.5rem; font-weight: bold; letter-spacing: 2px; color: white; }

/* --- TELAS (SCREENS) --- */
.screen { 
    display: none; 
    flex: 1; 
    width: 100%; 
    height: calc(100vh - 60px); 
    overflow: hidden; 
    position: relative;
}
.screen.active { display: flex; flex-direction: column; }


/* =========================================
   DASHBOARD (MENU DE SELEÇÃO)
   ========================================= */
.dashboard-container {
    display: flex; width: 100%; max-width: 1200px; margin: 0 auto;
    padding: 20px; gap: 20px; height: 100%; overflow: hidden;
}

/* --- Painel Esquerdo: Biblioteca --- */
.library-panel {
    flex: 1; max-width: 350px; min-width: 280px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex; flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 15px 20px; border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center; gap: 10px;
    color: var(--neon-accent); font-size: 1.1rem; font-weight: bold; letter-spacing: 1px;
}

.library-content { flex: 1; overflow-y: auto; padding: 10px; }

.lib-item {
    padding: 12px 15px; margin-bottom: 6px;
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent; border-radius: 6px;
    cursor: pointer; transition: all 0.2s;
    display: flex; justify-content: space-between; align-items: center;
    color: var(--text-muted);
}
.lib-item:hover { background: rgba(255,255,255,0.05); color: var(--text-main); }
.lib-item.selected {
    background: linear-gradient(90deg, rgba(255, 0, 85, 0.15), transparent);
    border-left: 3px solid var(--neon-accent);
    color: white;
}
.item-badge { background: #1f1f2e; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; color: #aaa; }

/* --- Painel Direito: Preview --- */
.preview-panel {
    flex: 2;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    position: relative;
    display: flex; flex-direction: column;
    overflow: hidden;
}

.empty-state {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 10px;
}

.preview-content { display: flex; flex-direction: column; height: 100%; padding: 25px; }

.preview-header {
    display: flex; gap: 20px; align-items: center; margin-bottom: 20px;
    border-bottom: 1px solid var(--glass-border); padding-bottom: 20px;
}
.preview-icon { 
    font-size: 2.5rem; background: rgba(255,255,255,0.05); 
    width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; 
    border-radius: 12px; border: 1px solid var(--glass-border);
}
#prev-title { margin: 0; font-size: 2rem; color: white; line-height: 1.1; }
.meta-tag { color: var(--neon-accent); font-weight: bold; letter-spacing: 1.5px; margin-top: 5px; font-size: 0.9rem; }

.preview-body { 
    flex: 1; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column;
    min-height: 0; /* Essencial para o scroll funcionar dentro do Flexbox */
}

.scrolling-list {
    flex: 1; 
    overflow-y: auto;
    list-style: none; 
    padding: 0; 
    margin-top: 10px;
    
    /* Configuração do Grid Corrigida */
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); 
    grid-auto-rows: max-content; /* Garante que os itens tenham altura própria */
    gap: 10px; 
    align-content: start; /* Joga os itens para o topo */
}

.scrolling-list li {
    background: rgba(255,255,255,0.05); 
    padding: 10px 12px;
    border-radius: 6px; 
    font-size: 0.9rem; 
    color: #e6edf3; 
    border: 1px solid rgba(255,255,255,0.05);
    
    /* Tratamento de Texto Longo */
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    display: block;
    line-height: 1.4; /* Espaçamento interno do texto */
}

/* Scrollbar Bonita (Opcional) */
.scrolling-list::-webkit-scrollbar { width: 6px; }
.scrolling-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
.scrolling-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.preview-footer {
    margin-top: 15px; padding-top: 15px;
    border-top: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
}

/* Botões e Switches */
.switch-group { display: flex; align-items: center; gap: 10px; color: var(--text-muted); cursor: pointer; }
.cyber-switch { position: relative; width: 44px; height: 24px; }
.cyber-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #333; transition: .3s; border-radius: 34px; border: 1px solid #555;
}
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
    background-color: white; transition: .3s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--neon-accent); border-color: var(--neon-accent); }
input:checked + .slider:before { transform: translateX(20px); }

.btn-launch {
    background: var(--neon-accent); color: white; border: none;
    padding: 12px 30px; border-radius: 30px;
    font-size: 1rem; font-weight: bold; letter-spacing: 1px;
    cursor: pointer; display: flex; align-items: center; gap: 8px;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.3); transition: 0.2s;
    font-family: 'Rajdhani', sans-serif;
}
.btn-launch:hover { transform: scale(1.05); box-shadow: 0 0 25px rgba(255, 0, 85, 0.5); }

/* Mobile Back Button */
.btn-mobile-back { display: none; }


/* =========================================
   GAME LAYOUT (ROLETA + HISTÓRICO)
   ========================================= */
.game-layout {
    display: flex; width: 100%; height: 100%;
    position: relative; overflow: hidden;
}

/* --- Área Esquerda: Roleta --- */
.wheel-section {
    flex: 1; 
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    position: relative;
    padding: 20px;
    min-width: 0; /* Impede overflow flex */
}

/* Container que mantém o aspect-ratio 1:1 */
.wheel-stage { 
    position: relative; 
    width: 100%; 
    max-width: 550px;
    aspect-ratio: 1 / 1;
    display: flex; align-items: center; justify-content: center;
}

.wheel-outer-ring {
    width: 100%; height: 100%;
    padding: 15px; border-radius: 50%;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
}

#wheel-canvas {
    width: 100% !important; height: 100% !important;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(255, 0, 85, 0.15);
    /* A rotação é aplicada via JS no style inline */
    transition: transform 5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.marker {
    position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
    font-size: 3rem; color: #fff; text-shadow: 0 0 15px var(--neon-accent);
    z-index: 20; pointer-events: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

/* Botão Central (Girar) */
.spin-trigger {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 80px; height: 80px; border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.8); 
    background: #fff;
    font-family: 'Rajdhani'; font-weight: 800; font-size: 1.2rem; color: #000;
    box-shadow: 0 0 30px rgba(255,255,255,0.4); 
    cursor: pointer; z-index: 10; transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.spin-trigger:hover { transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 0 40px rgba(255,255,255,0.6); }
.spin-trigger:active { transform: translate(-50%, -50%) scale(0.95); }
.spin-trigger:disabled { background: #333; border-color: #555; color: #777; box-shadow: none; cursor: not-allowed; }

/* Display do Vencedor (Abaixo da roleta) */
.last-winner-box {
    margin-top: 15px; text-align: center;
    background: rgba(0,0,0,0.6); padding: 10px 40px; border-radius: 30px;
    border: 1px solid var(--neon-accent);
    min-width: 250px;
}
.last-winner-box small { 
    color: var(--neon-accent); text-transform: uppercase; 
    letter-spacing: 2px; font-size: 0.75rem; 
}
#winner-text { 
    margin: 5px 0 0 0; font-size: 1.8rem; color: white; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 300px;
}

/* --- Área Direita: Histórico --- */
.history-panel {
    width: 320px;
    background: rgba(10, 10, 15, 0.8);
    border-left: 1px solid var(--glass-border);
    display: flex; flex-direction: column;
    backdrop-filter: blur(15px);
    z-index: 50;
}

.history-header {
    padding: 20px; background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--glass-border);
    font-weight: bold; color: var(--neon-accent); font-size: 1.1rem;
    display: flex; align-items: center; gap: 10px;
}

.history-body { 
    flex: 1; overflow-y: auto; padding: 0; 
    position: relative; /* Para o empty state centralizar */
}

/* Tabela Estilizada */
.cyber-table { width: 100%; border-collapse: collapse; color: var(--text-main); font-size: 0.9rem; }
.cyber-table th { 
    text-align: left; padding: 12px 15px; color: var(--text-muted); font-weight: 600; 
    border-bottom: 1px solid var(--glass-border); background: rgba(0,0,0,0.2);
    position: sticky; top: 0; z-index: 2; /* Header Fixo */
}
.cyber-table td { 
    padding: 12px 15px; border-bottom: 1px solid rgba(255,255,255,0.03); 
    vertical-align: middle;
}
.cyber-table tr:hover td { background: rgba(255,255,255,0.03); }

/* Animação de entrada da linha */
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.cyber-table tr { animation: slideInRight 0.3s ease-out; }

/* =========================================
   RESPONSIVIDADE (MOBILE & TABLET)
   ========================================= */
@media (max-width: 900px) {
    /* Dashboard: Colapso de Painéis */
    .dashboard-container { padding: 0; gap: 0; }
    
    .library-panel, .preview-panel {
        border: none; border-radius: 0; max-width: 100%; background: transparent;
    }
    
    /* Lógica de Troca (controlada via JS classes) */
    .library-panel { display: flex; width: 100%; }
    .preview-panel { display: none; width: 100%; position: absolute; top:0; left:0; height:100%; background: #050510; z-index: 20; }
    
    .dashboard-container.mobile-preview-active .library-panel { display: none; }
    .dashboard-container.mobile-preview-active .preview-panel { display: flex; }

    .btn-mobile-back {
        display: flex; align-items: center; justify-content: center;
        background: rgba(255,255,255,0.1); border: none; color: white;
        width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
        margin-right: 10px;
    }

    /* Jogo: Layout Vertical */
    .game-layout { flex-direction: column; overflow-y: auto; }
    
    .wheel-section { 
        flex: none; /* Altura automática baseada no conteúdo */
        padding: 20px 10px; 
        min-height: auto;
    }
    
    .wheel-stage { 
        max-width: 85vw; /* Roleta um pouco menor no mobile */
    }

    /* Histórico vai para baixo */
    .history-panel { 
        width: 100%; flex: 1; 
        min-height: 250px;
        border-left: none; border-top: 1px solid var(--glass-border); 
    }
    
    .spin-trigger { width: 60px; height: 60px; font-size: 1rem; border-width: 3px; }
    .marker { font-size: 2.5rem; top: -10px; }
    
    .last-winner-box { margin-bottom: 20px; }
}

/* =========================================
   MODAL DE VITÓRIA
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 2000;
    backdrop-filter: blur(5px);
    display: none; align-items: center; justify-content: center;
}

.modal-card {
    background: #0d0d12; 
    border: 1px solid var(--neon-accent);
    padding: 40px; border-radius: 20px; 
    text-align: center;
    width: 90%; max-width: 450px;
    box-shadow: 0 0 100px rgba(255, 0, 85, 0.2);
    position: relative; overflow: hidden;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-glow {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 200px; height: 200px; background: var(--neon-accent);
    filter: blur(120px); opacity: 0.3; z-index: 0; pointer-events: none;
}

.modal-card h1 { 
    margin: 0; font-size: 1rem; letter-spacing: 4px; color: var(--text-muted); text-transform: uppercase; 
    position: relative; z-index: 1;
}

.result-text { 
    font-size: 2.5rem; font-weight: 800; color: white; margin: 20px 0; 
    line-height: 1.2; word-break: break-word; text-shadow: 0 5px 15px rgba(0,0,0,0.5);
    position: relative; z-index: 1;
}

.btn-confirm {
    background: transparent; border: 1px solid rgba(255,255,255,0.2);
    color: white; padding: 12px 40px; border-radius: 30px; cursor: pointer;
    font-size: 1rem; font-family: 'Rajdhani'; transition: 0.2s;
    position: relative; z-index: 1;
}
.btn-confirm:hover { border-color: white; background: rgba(255,255,255,0.1); }

@keyframes zoomIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* =======================================================
   CORREÇÃO DE ROLAGEM E ESPAÇO PARA O BOTÃO NO MOBILE
   ======================================================= */
   .screen.active {
    overflow-y: auto; /* Permite rolar a tela se o conteúdo for grande */
    overflow-x: hidden;
}

.setup-container, .menu-content {
    /* Dá um respiro na parte de baixo para o botão nunca colar no fim da tela */
    padding-bottom: 60px; 
}

@media (max-width: 768px) {
    .screen.active {
        /* No mobile, alinha pelo topo em vez de centralizar. 
           Isso evita que a parte de cima e de baixo sejam cortadas juntas. */
        justify-content: flex-start; 
        padding-top: 20px;
    }
    
    .card-panel {
        /* Garante que o painel não fique gigante no celular */
        margin-bottom: 40px;
    }
}