/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #7C3AED;
  --primary-dark: #6D28D9;
  --primary-light: #EDE9FE;
  --sidebar-w: 260px;
  --header-h: 60px;
  --bg: #F5F3FF;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text: #1F2937;
  --muted: #6B7280;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
}

body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* 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; left: 0; top: 0; bottom: 0; z-index: 100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; background: var(--primary); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
}
.sidebar-logo .logo-text { font-weight: 700; font-size: 16px; color: var(--text); }
.sidebar-logo .tenant-name { font-size: 11px; color: var(--muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section { margin-bottom: 4px; }
.nav-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase;
             letter-spacing: .08em; padding: 8px 20px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 20px;
            color: var(--muted); font-size: 13.5px; font-weight: 500; cursor: pointer;
            transition: all .15s; border-radius: 0; }
.nav-item:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary);
                   border-right: 3px solid var(--primary); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
               display: flex; align-items: center; justify-content: center;
               color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--muted); }
.btn-logout { display: flex; align-items: center; gap: 6px; font-size: 12.5px;
              color: var(--muted); padding: 6px 0; }
.btn-logout:hover { color: var(--danger); text-decoration: none; }

/* Main content */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

.topbar { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border);
          display: flex; align-items: center; justify-content: space-between;
          padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.hamburger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }

.page-content { flex: 1; padding: 24px; }

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

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
             padding: 20px; box-shadow: var(--shadow); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-icon { font-size: 24px; margin-bottom: 8px; }
.stat-card.primary .stat-icon { color: var(--primary); }
.stat-card.success .stat-icon { color: var(--success); }
.stat-card.warning .stat-icon { color: var(--warning); }
.stat-card.danger  .stat-icon { color: var(--danger); }
.stat-card.info    .stat-icon { color: var(--info); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px;
       font-size: 13.5px; font-weight: 500; cursor: pointer; border: 1px solid transparent;
       transition: all .15s; line-height: 1.4; }
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600;
           text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
           border-bottom: 1px solid var(--border); background: #FAFAFA; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px;
           vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text);
              margin-bottom: 5px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border);
                border-radius: 6px; font-size: 13.5px; color: var(--text); background: var(--surface);
                transition: border-color .15s, box-shadow .15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.form-text { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.form-row { display: grid; gap: 16px; }
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 100px;
         font-size: 11px; font-weight: 600; }
.badge-success  { background: #D1FAE5; color: #065F46; }
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-danger   { background: #FEE2E2; color: #991B1B; }
.badge-info     { background: #DBEAFE; color: #1E40AF; }
.badge-muted    { background: #F3F4F6; color: #374151; }
.badge-primary  { background: var(--primary-light); color: var(--primary-dark); }

/* ── Alerts / Flash ───────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px;
         display: flex; align-items: flex-start; gap: 8px; margin-bottom: 16px; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger  { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
                  display: flex; align-items: center; justify-content: center; padding: 16px;
                  opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border-radius: 10px; width: 100%; max-width: 520px;
         box-shadow: var(--shadow-md); max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { padding: 16px 20px; 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: 18px; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border);
                display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

/* ── Attendance ───────────────────────────────────────────────────────────── */
.attendance-btn { border: 2px solid var(--border); background: var(--surface); border-radius: 6px;
                  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; }
.attendance-btn.presente  { border-color: var(--success); background: #D1FAE5; color: #065F46; }
.attendance-btn.falta     { border-color: var(--danger);  background: #FEE2E2; color: #991B1B; }
.attendance-btn.justificada { border-color: var(--warning); background: #FEF3C7; color: #92400E; }

/* ── Utils ────────────────────────────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.page-header { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text); }
.search-bar { display: flex; gap: 8px; align-items: center; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .form-row.col-2, .form-row.col-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Color input ──────────────────────────────────────────────────────────── */
input[type=color] { width: 40px; height: 36px; padding: 2px; border-radius: 6px;
                    border: 1px solid var(--border); cursor: pointer; }
