/* ========================================================= */
/* === VARIÁVEIS E RESET === */
/* ========================================================= */
:root { 
    --primary: #1e272e; 
    --primary-light: #2f3640;
    --accent: #05c46b; 
    --bg: #f4f6f8; 
    --sidebar-width: 260px;
    --danger: #ff4757; 
    --info: #1e90ff; 
    --warning: #ffa502; 
    --purple: #5352ed;
    --border: #dfe4ea;
    --text-main: #2f3542;
    --text-muted: #747d8c;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.04); 
}

* { box-sizing: border-box; }
body { 
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; 
    background: var(--bg); 
    margin: 0; 
    display: grid; 
    grid-template-columns: var(--sidebar-width) 1fr; 
    min-height: 100vh; 
    color: var(--text-main); 
}

/* ========================================================= */
/* === COMPONENTES GLOBAIS E BOTÕES === */
/* ========================================================= */
.btn-accent { background: var(--accent); color: white; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; transition: 0.2s; }
.btn-accent:hover { background: #04b360; }
.btn-nav { background: #f1f2f6; color: var(--text-main); border: 1px solid var(--border); padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-logout { background: var(--danger); color: white; padding: 8px 15px; border-radius: 6px; text-decoration: none; font-weight: 600; }
.btn-small { padding: 6px 12px; font-size: 11px; border-radius: 4px; cursor: pointer; border: none; color: white; }
.btn-cancel { background: #7f8fa6; color: white; border: none; padding: 10px 18px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.full-width { width: 100%; }

/* ========================================================= */
/* === TELA DE LOGIN === */
/* ========================================================= */
.login-body { display: flex; justify-content: center; align-items: center; background: var(--primary); grid-template-columns: 1fr; }
.login-box { background: white; padding: 40px; border-radius: 12px; width: 100%; max-width: 400px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.login-box h1 { color: var(--accent); font-size: 32px; margin: 0 0 5px 0; }
.login-box p { color: var(--text-muted); margin-bottom: 30px; font-size: 13px; text-transform: uppercase; }
.login-box input { width: 100%; padding: 12px; margin-bottom: 15px; border-radius: 6px; border: 1px solid var(--border); font-size: 14px; outline: none; }
.login-box .credits { margin-top: 25px; font-size: 11px; color: #aaa; }

/* ========================================================= */
/* === SIDEBAR E TOPBAR === */
/* ========================================================= */
#sidebar { background: var(--primary); color: white; height: 100vh; overflow-y: auto; position: sticky; top: 0; display: flex; flex-direction: column; }
.logo-area { padding: 25px 20px; text-align: center; background: #151b20; border-bottom: 2px solid var(--accent); }
.logo-area h2 { margin: 0; font-size: 24px; color: #fff; }
.logo-area span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }

.modulo-header { background: var(--primary); padding: 12px 20px; cursor: pointer; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; border-bottom: 1px solid var(--primary-light); color: #ced6e0; transition: 0.2s; }
.modulo-header:hover { background: var(--primary-light); color: white; }
.modulo-content { display: none; background: #151b20; }
.modulo-content.active { display: block; }
.menu-item { padding: 10px 20px 10px 35px; font-size: 12px; color: #a4b0be; cursor: pointer; border-bottom: 1px solid #1e272e; transition: 0.2s; display: flex; justify-content: space-between; }
.menu-item:hover { color: white; background: rgba(255,255,255,0.05); }
.menu-item.active { background: var(--accent); color: white; font-weight: 600; border-left: 3px solid white; }
.menu-item.bloqueado { opacity: 0.4; cursor: not-allowed; }

main { padding: 30px 40px; max-width: 1800px; margin: 0 auto; width: 100%; }
.top-bar { background: white; padding: 15px 25px; display: flex; justify-content: space-between; align-items: center; border-radius: 8px; margin-bottom: 30px; box-shadow: var(--card-shadow); border: 1px solid var(--border); }
.top-bar-title { font-size: 16px; font-weight: 600; color: var(--primary); }
.top-bar-title span { color: var(--accent); font-size: 14px; margin-left: 8px; }
.user-info { display: flex; align-items: center; font-size: 13px; gap: 15px; }

/* ========================================================= */
/* === DASHBOARD E WIDGETS === */
/* ========================================================= */
.dash-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 30px; }
.dash-card { background: white; padding: 25px; border-radius: 8px; display: flex; align-items: center; gap: 15px; cursor: pointer; box-shadow: var(--card-shadow); border: 1px solid var(--border); border-left-width: 5px; transition: 0.2s; }
.dash-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.warning-border { border-left-color: var(--warning); }
.info-border { border-left-color: var(--info); }
.primary-border { border-left-color: var(--primary); }
.purple-border { border-left-color: var(--purple); }
.danger-border { border-left-color: var(--danger); }
.dash-card-icon { font-size: 28px; background: var(--bg); width: 55px; height: 55px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.dash-card-text h3 { margin: 0; font-size: 16px; font-weight: 600; }
.dash-card-text p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }

.widgets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.widget-box { background: white; padding: 25px; border-radius: 8px; box-shadow: var(--card-shadow); border: 1px solid var(--border); }
.widget-box h4 { margin: 0 0 15px 0; font-size: 15px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.widget-dark { background: var(--primary); color: white; border: none; }
.widget-dark h4 { color: var(--accent); border-color: rgba(255,255,255,0.1); }
.widget-content { font-size: 13px; line-height: 1.6; margin-top: 15px; color: #d2dae2; }

/* ========================================================= */
/* === PAINÉIS DE GESTÃO (CRUD) === */
/* ========================================================= */
.mgmt-container { display: none; background: white; padding: 30px; border-radius: 8px; box-shadow: var(--card-shadow); border: 1px solid var(--border); border-top: 4px solid var(--primary); animation: fadeIn 0.3s; }
.mgmt-container.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr auto; gap: 10px; background: var(--bg); padding: 15px; border-radius: 6px; border: 1px solid var(--border); align-items: center; }
.search-box { background: #fff; padding: 10px 14px; border-radius: 6px; margin: 15px 0; border: 1px solid var(--border); width: 100%; font-size: 13px; outline: none; }
textarea, input[type="text"], input[type="password"], input[type="date"], select { width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--border); font-size: 13px; outline: none; font-family: inherit; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); }

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
table th { background: var(--bg); padding: 12px 15px; text-align: left; font-size: 12px; color: var(--text-muted); border-bottom: 2px solid var(--border); }
table td { padding: 12px 15px; border-bottom: 1px solid var(--border); font-size: 13px; }

/* ========================================================= */
/* === EDITOR DE AULAS COM RICH TEXT (NOVO) === */
/* ========================================================= */
.editor-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 20px; }
.editor-card { background: white; padding: 20px; border-radius: 8px; border: 1px solid var(--border); box-shadow: var(--card-shadow); margin-bottom: 15px; }
.editor-card h4 { margin: 0 0 15px 0; color: var(--primary); font-size: 14px; border-bottom: 1px solid var(--bg); padding-bottom: 8px; }

.editor-toolbar { background: #f1f2f6; border: 1px solid var(--border); border-bottom: none; border-radius: 6px 6px 0 0; padding: 6px; display: flex; gap: 5px; }
.editor-toolbar button { background: white; border: 1px solid var(--border); border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 13px; color: var(--text-main); font-weight: bold; }
.editor-toolbar button:hover { background: #dfe4ea; }
.rich-editor { border: 1px solid var(--border); border-radius: 0 0 6px 6px; padding: 12px; min-height: 100px; background: white; outline: none; font-size: 14px; line-height: 1.6; max-height:400px; overflow-y:auto; }
.rich-editor:empty:before { content: attr(data-placeholder); color: #a4b0be; pointer-events: none; display: block; }
.rich-editor:focus { border-color: var(--accent); }

.footer-actions { position: sticky; bottom: 20px; background: white; padding: 15px 25px; border-radius: 8px; box-shadow: 0 -4px 15px rgba(0,0,0,0.1); border: 1px solid var(--border); display: flex; justify-content: flex-end; z-index: 50; }

/* ========================================================= */
/* === AVISOS, LIBERAÇÕES E MODAIS === */
/* ========================================================= */
.aviso-item-card { background: white; padding: 20px; border-radius: 8px; margin-bottom: 15px; border: 1px solid var(--border); border-left: 4px solid var(--warning); box-shadow: var(--card-shadow); }
.painel-liberacao { background: var(--bg); padding: 20px; border-radius: 8px; border: 1px solid var(--border); margin: 15px 0; }
.grid-lib-badge { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 15px 0; max-height: 300px; overflow-y: auto; }
.lib-badge { padding: 10px; background: white; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; text-align: center; cursor: pointer; font-weight: 500; }
.lib-badge.checked { background: var(--accent); color: white; border-color: var(--accent); }

.modal-bg { position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.modal-content { background: white; padding: 30px; width: 600px; border-radius: 12px; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 15px; }

/* Grid da Anamnese para Dependências (Múltipla Seleção) */
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--bg); padding: 15px; border-radius: 8px; border: 1px solid var(--border); max-height: 220px; overflow-y: auto; margin-bottom: 15px; }
.checkbox-grid label { display: flex; gap: 8px; font-size: 12px; align-items: center; cursor: pointer; }

/* ========================================================= */
/* === VISUALIZAÇÃO DE AULAS === */
/* ========================================================= */
.card-view { background: white; padding: 40px; border-radius: 8px; box-shadow: var(--card-shadow); border: 1px solid var(--border); border-top: 4px solid var(--accent); line-height: 1.6; font-size: 15px; }