/* assets/css/pages/banco.css - V53.1 (Fixed Checkboxes + Sticky Button) */

/* --- 1. VARIÁVEIS --- */
:root {
    --header-height: 70px; 
    --filter-sidebar-width: 340px; 
    --gap-fix: 0px; 

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-soft: #e0e7ff;
    --accent-gold: #f59e0b;
    --bg-app: #f1f5f9;
    --bg-panel: #ffffff;
    --border-color: #e2e8f0;
    
    --txt-heading: #0f172a;
    --txt-body: #334155;
    --txt-muted: #64748b;
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-md: 12px;
}

/* --- 2. TRAVAMENTO DA PÁGINA --- */
body.page-template-page-banco-de-questoes {
    overflow: hidden !important; 
    background-color: var(--bg-app);
}

body.page-template-page-banco-de-questoes footer,
body.page-template-page-banco-de-questoes .site-footer,
body.page-template-page-banco-de-questoes #colophon {
    display: none !important;
}

/* --- 3. RESET DO CONTAINER PAI --- */
body.page-template-page-banco-de-questoes #primary.site-main,
body.page-template-page-banco-de-questoes .site-content,
body.page-template-page-banco-de-questoes .entry-content {
    margin: 0 !important; padding: 0 !important;
    max-width: 100% !important; width: 100% !important;
    display: block !important;
}

/* --- 4. APP SHELL --- */
.metria-shell {
    position: relative; width: 100%;
    margin-top: var(--gap-fix); 
    height: calc(100vh - var(--header-height));
    background: var(--bg-app);
    display: grid;
    grid-template-columns: var(--filter-sidebar-width) 1fr; 
    grid-template-rows: 1fr;
    overflow: hidden;
}

body.admin-bar .metria-shell {
    margin-top: -32px; 
    height: calc(100vh - var(--header-height) + 32px);
}

/* --- 5. SIDEBAR INTERNA (FILTROS) --- */
.app-sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 20;
    position: relative; 
    overflow: hidden;
}

.sidebar-top {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-title-row {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.sidebar-title { 
    font-size: 0.75rem; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--txt-muted); 
    display: flex; align-items: center; gap: 8px;
}
.btn-reset {
    background: transparent; border: none; color: var(--primary); font-size: 0.75rem; font-weight: 600; cursor: pointer;
}
.btn-reset:hover { text-decoration: underline; }

.input-group { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--txt-muted); font-size: 0.9rem; }
.input-field {
    width: 100%; padding: 10px 12px 10px 38px;
    border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--bg-app); font-size: 0.9rem; transition: 0.2s;
    font-family: var(--font-ui);
}
.input-field:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }

.sidebar-content {
    flex: 1; overflow-y: auto; padding: 20px 24px;
    scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent;
    min-height: 0;
}
.sidebar-content::-webkit-scrollbar { width: 5px; }
.sidebar-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.filter-section { margin-bottom: 24px; }
.filter-label { display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--txt-muted); margin-bottom: 8px; }

.custom-select-wrapper { position: relative; }
.custom-select {
    width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px;
    background: #fff; appearance: none; color: var(--txt-heading); font-size: 0.9rem; cursor: pointer;
}
.select-chevron { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--txt-muted); pointer-events: none; font-size: 0.8rem; }

/* Tree Styles */
.tree-root { display: flex; flex-direction: column; gap: 4px; }
details > summary { list-style: none; cursor: pointer; outline: none; }
details > summary::-webkit-details-marker { display: none; }

.tree-node {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px; border-radius: 6px;
    color: var(--txt-body); font-size: 0.9rem;
    transition: 0.1s; user-select: none;
}
.tree-node:hover { background: var(--bg-app); color: var(--txt-heading); }

.node-content { display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden; }
.node-icon { font-size: 0.7rem; color: var(--txt-muted); transition: transform 0.2s; width: 12px; text-align: center; }
details[open] > summary .node-icon { transform: rotate(90deg); color: var(--txt-heading); }
.node-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

.tree-children { padding-left: 20px; border-left: 1px solid var(--border-color); margin-left: 10px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }

/* --- CORREÇÃO CRÍTICA DOS CHECKBOXES (HÍBRIDO) --- */
/* Funciona tanto com .checkbox-item (novo) quanto .tree-item.leaf (antigo) */
.checkbox-item,
.tree-item.leaf { 
    display: flex; align-items: center; gap: 10px; 
    cursor: pointer; width: 100%; position: relative;
    padding: 6px 10px; border-radius: 6px;
}
.checkbox-item:hover,
.tree-item.leaf:hover { background: var(--bg-app); }

.checkbox-item input,
.tree-item.leaf input { display: none; }

/* Caixa do Checkbox */
.checkbox-box,
.checkmark {
    width: 16px; height: 16px; 
    border: 1px solid #cbd5e1; border-radius: 4px; 
    background: #fff;
    position: relative; flex-shrink: 0; transition: 0.2s;
}

/* Estado Marcado */
.checkbox-item input:checked + .checkbox-box,
.tree-item.leaf input:checked + .checkmark { 
    background: var(--primary); 
    border-color: var(--primary); 
}

/* O Vzinho (Check) */
.checkbox-item input:checked + .checkbox-box::after,
.tree-item.leaf input:checked + .checkmark::after {
    content: ''; position: absolute; 
    left: 5px; top: 1px; width: 4px; height: 8px;
    border: solid white; border-width: 0 2px 2px 0; 
    transform: rotate(45deg); display: block;
}

/* Texto */
.checkbox-text,
.tree-item.leaf .text { font-size: 0.85rem; color: var(--txt-body); }
.checkbox-item input:checked ~ .checkbox-text,
.tree-item.leaf input:checked ~ .text { color: var(--primary); font-weight: 600; }

/* Premium Btn */
.premium-card-btn {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px; background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
    border: 1px solid var(--accent-gold-soft); border-radius: var(--radius-md);
    cursor: pointer; text-align: left; transition: all 0.2s; margin-bottom: 24px;
}
.premium-card-btn:hover { border-color: var(--accent-gold); box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); transform: translateY(-1px); }
.p-icon-box {
    width: 36px; height: 36px; background: #fef3c7; color: var(--accent-gold);
    border-radius: 8px; display: grid; place-items: center; font-size: 1rem;
}
.p-info { flex: 1; display: flex; flex-direction: column; }
.p-title { font-weight: 700; font-size: 0.8rem; color: var(--txt-heading); }
.p-sub { font-size: 0.7rem; color: #b45309; }

/* --- SIDEBAR FOOTER (CORREÇÃO DE FIXAÇÃO) --- */
.sidebar-footer {
    padding: 20px 24px; 
    background: rgba(255,255,255,0.95); /* Um pouco mais opaco para leitura */
    backdrop-filter: blur(5px); 
    border-top: 1px solid var(--border-color);
    
    /* Trava no fundo da sidebar */
    margin-top: auto; 
    position: sticky; 
    bottom: 0; 
    z-index: 50;
    flex-shrink: 0;
}

.btn-apply {
    width: 100%; padding: 12px;
    background: var(--primary); color: white;
    border: none; border-radius: 6px;
    font-weight: 600; font-size: 0.85rem; letter-spacing: 0.5px;
    display: flex; justify-content: center; align-items: center; gap: 8px;
    cursor: pointer; transition: background 0.2s; /* Removemos transform transition */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* Hover estático */
.btn-apply:hover { 
    background: var(--primary-hover); 
    transform: none; /* Garante que não se mova */
}

/* --- 6. CONTEÚDO PRINCIPAL --- */
.app-main {
    background: var(--bg-app);
    overflow-y: auto;
    padding: 0;
    scroll-behavior: smooth;
    position: relative;
}

.content-container {
    max-width: 1000px; 
    margin: 0 auto;
    padding: 40px 40px 100px 40px;
}

.main-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 40px;
}
.page-title { font-size: 2rem; font-weight: 800; color: var(--txt-heading); margin: 0; letter-spacing: -1px; }
.page-subtitle { color: var(--txt-muted); margin-top: 4px; font-size: 1rem; }
.results-count {
    background: #fff; padding: 6px 16px; border-radius: 20px;
    font-size: 0.85rem; font-weight: 600; color: var(--primary);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); border: 1px solid var(--border-color);
}

.questions-grid { display: flex; flex-direction: column; gap: 32px; }

.q-card {
    background: #fff; border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    overflow: hidden;
    transition: box-shadow 0.2s; /* Sem transform */
}
.q-card:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); 
    border-color: var(--primary); 
    transform: none; /* Card estático */
}

.q-header {
    padding: 16px 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.q-meta { display: flex; gap: 8px; }
.badge {
    padding: 4px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; border: 1px solid transparent;
}
.b-year { background: #fff; color: var(--txt-body); border-color: var(--border-color); }
.b-hard { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.b-medium { background: #fff7ed; color: #ea580c; border-color: #ffedd5; }
.b-easy { background: #f0fdf4; color: #16a34a; border-color: #dcfce7; }
.b-comp { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.q-id { font-family: var(--font-mono); color: var(--txt-muted); font-size: 0.85rem; font-weight: 600; }

.q-body { padding: 32px 32px 10px 32px; }
.q-enunciado { font-size: 1.05rem; line-height: 1.7; color: var(--txt-heading); margin-bottom: 24px; }
.q-image-container { margin: 20px 0; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; display: inline-block; background: #fafafa; }
.q-image-container img { max-width: 100%; height: auto; display: block; }

.q-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.opt-label {
    display: flex; align-items: flex-start; gap: 16px;
    padding: 16px; border: 1px solid var(--border-color); border-radius: 12px;
    cursor: pointer; transition: all 0.15s ease-in-out;
}
.opt-label:hover { background: #f8fafc; border-color: #94a3b8; }
.opt-label input { display: none; }
.opt-circle {
    width: 24px; height: 24px; border-radius: 50%;
    background: #e2e8f0; color: #64748b;
    font-weight: 700; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 2px; transition: 0.2s;
}
.opt-text { font-size: 0.95rem; color: var(--txt-body); line-height: 1.5; }
.opt-label input:checked + .opt-circle { background: var(--primary); color: white; }
.opt-label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.q-footer { padding: 0 32px 24px 32px; display: flex; gap: 12px; }
.btn-action {
    background: var(--txt-heading); color: white; border: none;
    padding: 10px 24px; border-radius: 30px; font-weight: 600; font-size: 0.9rem;
    cursor: pointer; transition: 0.2s;
}
.btn-action:hover { background: #000; transform: translateY(-1px); }
.btn-ghost {
    background: transparent; border: 1px solid var(--border-color);
    color: var(--txt-muted); padding: 10px 20px; border-radius: 30px;
    font-size: 0.85rem; font-weight: 600; cursor: pointer; display: flex; gap: 6px; align-items: center;
}
.btn-ghost:hover { border-color: var(--txt-heading); color: var(--txt-heading); }

.pagination-container { margin-top: 40px; display: flex; justify-content: center; gap: 8px; }
.page-numbers {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: #fff; border: 1px solid var(--border-color);
    color: var(--txt-muted); text-decoration: none; font-weight: 600; transition: 0.2s;
}
.page-numbers.current, .page-numbers:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* --- 7. MODAL --- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(4px);
    z-index: 1000; display: flex; justify-content: center; align-items: center;
}
.modal-box {
    width: 900px; max-width: 95%; background: #fff;
    border-radius: 16px; box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    display: flex; flex-direction: column; max-height: 85vh;
}
.m-header {
    padding: 20px 30px; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center; background: #f8fafc;
}
.m-title h2 { margin: 0; font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.pro-badge { background: var(--txt-heading); color: var(--accent-gold); font-size: 0.65rem; padding: 3px 8px; border-radius: 4px; letter-spacing: 1px; }
.btn-close { background: none; border: none; font-size: 1.5rem; color: var(--txt-muted); cursor: pointer; }

.m-body { padding: 30px; overflow-y: auto; }
.m-section-title { font-size: 0.9rem; text-transform: uppercase; color: var(--txt-muted); font-weight: 700; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; }
.patterns-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.pat-card {
    border: 1px solid var(--border-color); border-radius: 6px;
    padding: 12px; cursor: pointer; background: #fff; transition: 0.15s;
    display: flex; flex-direction: column; gap: 4px;
}
.pat-card:hover { border-color: var(--primary); }
.pat-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.pat-code { font-size: 0.75rem; font-weight: 800; color: var(--txt-muted); text-transform: uppercase; }
.pat-name { font-size: 0.85rem; font-weight: 600; color: var(--txt-heading); }
.m-footer { padding: 20px 30px; border-top: 1px solid var(--border-color); text-align: right; background: #f8fafc; }

/* --- RESPONSIVO --- */
@media (max-width: 950px) {
    .metria-shell {
        grid-template-columns: 1fr;
        display: block; 
        overflow: auto;
        height: auto;
        margin-top: 0; 
    }
    .app-sidebar { height: auto; border-right: none; border-bottom: 1px solid var(--border-color); }
    .sidebar-content { max-height: 300px; }
    .content-container { padding: 20px; }
    .sidebar-footer { position: sticky; bottom: 0; z-index: 50; }
    body.page-template-page-banco-de-questoes #primary.site-main { width: 100% !important; }
}