/* ============================================================
   SISTEMA DE GESTÃO DE SALAS — STYLESHEET
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-alt: #F1F0EC;
  --border: #E4E2DC;
  --border-strong: #C9C7BF;
  --text: #1A1916;
  --text-muted: #6B6860;
  --text-faint: #A09E97;
  --accent: #2563EB;
  --accent-bg: #EFF6FF;
  --success: #16A34A;
  --success-bg: #F0FDF4;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --pink: #DB2777;
  --pink-bg: #FDF2F8;
  --sidebar-w: 230px;
  --radius: 8px;
  --radius-lg: 12px;
  font-family: 'DM Sans', sans-serif;
}

body { background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; color: var(--text);
}
.logo-icon {
  width: 30px; height: 30px; background: var(--accent); color: #fff;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius); font-size: 13.5px; color: var(--text-muted);
  text-decoration: none; transition: all 0.12s;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.nav-section { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); padding: 12px 10px 4px; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 14px 14px;
  border-top: 1px solid var(--border);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.logout-btn { color: var(--text-muted); display: flex; align-items: center; }
.logout-btn:hover { color: var(--danger); }

/* ── MAIN ── */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-height: 100vh; }

/* ── PAGE HEADER ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 600; color: var(--text); }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: var(--radius); font-size: 13px; font-family: inherit; font-weight: 500;
  cursor: pointer; transition: all 0.12s; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-alt); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #1D4ED8; border-color: #1D4ED8; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }

/* ── CARDS ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── STAT CARDS ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--text); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--surface-alt); padding: 10px 12px; text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-alt); }

/* ── GRADE TABLE ── */
.grade-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 900px; }
.grade-table th { background: var(--surface-alt); padding: 8px 10px; font-size: 11px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border); text-align: center; }
.grade-table td { border: 1px solid var(--border); padding: 0; vertical-align: top; min-width: 80px; }
.grade-table .td-dia { font-weight: 600; font-size: 12px; padding: 8px 10px; white-space: nowrap; background: var(--surface-alt); text-align: center; }
.grade-table .td-periodo { font-size: 11px; color: var(--text-muted); padding: 6px 8px; white-space: nowrap; background: var(--bg); text-align: center; }
.cell-badge {
  display: block; padding: 5px 7px; margin: 3px; border-radius: 5px;
  font-size: 11px; font-weight: 500; cursor: pointer; text-align: center;
  transition: opacity 0.1s; white-space: nowrap;
}
.cell-badge:hover { opacity: .75; }
.badge-aula { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.badge-livre { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }
.badge-planejamento { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; font-style: italic; }
.badge-substituicao { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; font-weight: 700; }
.badge-bp { background: #F5F3FF; color: #6D28D9; border: 1px solid #DDD6FE; }
.cell-add { display: block; padding: 6px; text-align: center; color: var(--text-faint); font-size: 18px; cursor: pointer; }
.cell-add:hover { color: var(--accent); background: var(--accent-bg); border-radius: 5px; margin: 3px; }

/* ── CRONOGRAMA ── */
.crono-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.crono-nav h2 { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.crono-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.crono-day-header { background: var(--surface-alt); padding: 8px 4px; text-align: center; font-size: 11px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.crono-day-header:last-child { border-right: none; }
.crono-day-col { border-right: 1px solid var(--border); min-height: 140px; background: var(--surface); }
.crono-day-col:last-child { border-right: none; }
.crono-day-num { text-align: center; padding: 6px 4px; font-size: 12px; font-weight: 500; color: var(--text-muted); border-bottom: 1px solid var(--border); cursor: pointer; }
.crono-day-num:hover { background: var(--surface-alt); }
.crono-day-num.hoje { background: var(--accent); color: #fff; font-weight: 700; }
.crono-day-num.outro-mes { color: var(--text-faint); }
.crono-day-num.feriado { background: var(--surface-alt); }
.crono-evento {
  margin: 2px 3px; padding: 3px 5px; border-radius: 4px;
  font-size: 10px; font-weight: 500; cursor: pointer; line-height: 1.3;
  overflow: hidden; white-space: normal; text-overflow: ellipsis; max-height: 42px;
}
.crono-evento:hover { opacity: .8; }
.ev-aula { background: #DBEAFE; color: #1E40AF; }
.ev-livre { background: #DCFCE7; color: #15803D; }
.ev-plan { background: #E0E7FF; color: #4338CA; }
.ev-subst { background: #FEF3C7; color: #92400E; }
.ev-feriado { background: #FCE7F3; color: #9D174D; }
.ev-recesso { background: #F3F4F6; color: #6B7280; }
.ev-rosa { background: #FCE7F3; color: #BE185D; }
.ev-verde { background: #D1FAE5; color: #065F46; }
.crono-periodo { padding: 4px 6px; font-size: 10px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.crono-fds { background: var(--bg) !important; }
.crono-recesso-col { background: #FFF7ED !important; }
.crono-feriado-col { background: #FCE7F3 !important; }

/* ── FORMS ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.full { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color 0.12s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 70px; }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--surface-alt); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── BADGES & TAGS ── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-admin { background: #EFF6FF; color: #1D4ED8; }
.badge-coord { background: #F0FDF4; color: #15803D; }
.badge-prof-role { background: var(--surface-alt); color: var(--text-muted); }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot-ok { background: var(--success); }
.dot-warn { background: var(--warning); }
.dot-err { background: var(--danger); }

/* ── ALERTS ── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #86EFAC; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #FCA5A5; }
.alert-info { background: var(--accent-bg); color: var(--accent); border: 1px solid #93C5FD; }

/* ── FILTERS ── */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text); }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }
.search-input { width: 220px; }

/* ── COLOR PICKER ── */
.color-picker-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.color-dot { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .1s; }
.color-dot:hover, .color-dot.selected { border-color: var(--text); transform: scale(1.15); }

/* ── RESPONSIVO ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.three { grid-template-columns: 1fr 1fr; }
}

/* ── LOGIN ── */
.login-page { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px 36px; width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { width: 44px; height: 44px; font-size: 22px; margin: 0 auto 10px; border-radius: 12px; }
.login-logo h1 { font-size: 18px; font-weight: 600; }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.login-form .form-group { margin-bottom: 14px; }
.login-form .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; font-size: 14px; }

/* ── LEGEND ── */
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* ── PRINT ── */
@media print {
  .sidebar, .header-actions, .btn, .modal-overlay { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .grade-table { font-size: 10px; }
}

/* ── MELHORIAS V2: gestão educacional ── */
.kpi-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:12px; margin-bottom:20px; }
.metric-note { font-size:12px; line-height:1.5; color:var(--text-muted); }
.progress { height:8px; background:var(--surface-alt); border-radius:999px; overflow:hidden; }
.progress > span { display:block; height:100%; background:var(--accent); border-radius:999px; }
.empty-state { text-align:center; color:var(--text-faint); padding:24px; }
.card-grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width: 980px) { .card-grid-2, .main-content > div[style*="grid-template-columns:360px"] { grid-template-columns:1fr !important; } }

/* ── Cronograma: card compacto + tooltip leve ── */
.crono-evento {
  position: relative;
  max-height: 74px;
  white-space: normal;
}
.crono-evento .ev-prof-line {
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 2px;
}
.crono-evento .ev-info-line {
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.25;
  opacity: .92;
}
.crono-evento .ev-obs-line {
  opacity: .82;
  font-style: italic;
}



/* ── MELHORIAS DE EXCELÊNCIA ── */
.kpi-emphasis { font-size: 32px; font-weight: 700; letter-spacing: -.03em; }
.alert + .alert { margin-top: -8px; }
.data-table td.empty-state { text-align:center; color:var(--text-faint); padding:24px; }
@media (max-width: 980px) { .card-grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .header-actions { width:100%; justify-content:flex-start; flex-wrap:wrap; } .stats-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }

/* ── V4: Cronograma semanal e indicadores de carga ── */
.weekly-table { width:100%; border-collapse:collapse; min-width:1100px; font-size:12px; }
.weekly-table th { background:var(--surface-alt); border:1px solid var(--border); padding:10px 8px; text-align:center; color:var(--text-muted); font-weight:700; }
.weekly-table th span { font-size:11px; color:var(--text-faint); font-weight:500; }
.weekly-table td { border:1px solid var(--border); vertical-align:top; min-width:145px; min-height:110px; padding:5px; }
.weekly-periodo { width:110px; background:var(--surface-alt); font-weight:700; text-align:center; color:var(--text-muted); }
.weekly-cell { background:var(--surface); }
.weekly-empty { display:block; color:var(--text-faint); font-size:11px; text-align:center; padding:16px 0; }
.kpi-warning { color:var(--warning); font-weight:700; }
.kpi-danger { color:var(--danger); font-weight:700; }
.kpi-success { color:var(--success); font-weight:700; }
.form-hint { color:var(--text-faint); font-size:11px; line-height:1.35; }

/* ── Aulas do Dia ── */
.daily-table { min-width: 860px; }
.daily-event-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:8px; padding:4px; }
.daily-event-card { margin:0; padding:8px 10px; max-height:none; cursor:default; }
.daily-event-card .ev-info-line { font-size:11px; }
.daily-event-card .ev-obs-line { margin-top:4px; font-size:10.5px; }
@media print {
  .daily-event-list { display:block; }
  .daily-event-card { break-inside: avoid; margin-bottom: 6px; }
}
