/* ── Family Success Hub — Shared Design System ─────────────────────────────── */

/* ── Reset y base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #F6F8FB; font-family: 'Inter', system-ui, sans-serif; color: #1e293b; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.page-wrap         { max-width: 1400px; margin: 0 auto; padding: 28px 24px 80px; }
.page-wrap--narrow { max-width: 900px;  margin: 0 auto; padding: 28px 24px 80px; }
.page-wrap--wide   { max-width: 1520px; margin: 0 auto; padding: 28px 24px 80px; }

/* ── Page header ───────────────────────────────────────────────────────────── */
.ph { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.ph-left { display: flex; flex-direction: column; gap: 2px; }
.ph-breadcrumb { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #94a3b8; margin-bottom: 5px; flex-wrap: wrap; }
.ph-breadcrumb a { color: #6366f1; text-decoration: none; font-weight: 500; }
.ph-breadcrumb a:hover { text-decoration: underline; }
.ph-breadcrumb-sep { color: #cbd5e1; font-size: 11px; }
.ph-title { font-size: 24px; font-weight: 800; color: #0f172a; margin: 0; letter-spacing: -.01em; line-height: 1.2; }
.ph-subtitle { font-size: 13px; color: #64748b; margin: 4px 0 0; line-height: 1.5; }
.ph-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; padding-top: 4px; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert { padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; margin-bottom: 16px; line-height: 1.5; }
.alert-error   { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card { background: #fff; border: 1px solid #e0e6ef; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.card-header { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 14px; font-weight: 700; color: #0f172a; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-subtitle { font-size: 12px; color: #64748b; margin: 2px 0 0; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid #f1f5f9; display: flex; align-items: center; gap: 8px; }

/* ── Section label ─────────────────────────────────────────────────────────── */
.section-label { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .07em; margin: 0 0 10px; }

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-search { flex: 1; min-width: 200px; max-width: 320px; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Form inputs ───────────────────────────────────────────────────────────── */
.fi { font-size: 13px; border: 1px solid #dde3ec; border-radius: 9px; padding: 8px 11px; height: 38px; background: #fff; outline: none; color: #334155; transition: border-color 130ms, box-shadow 130ms; }
.fi:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,.15); }
.fi::placeholder { color: #94a3b8; }
.fi-sm { height: 32px; padding: 5px 9px; font-size: 12px; }
.fi-full { width: 100%; }
textarea.fi { height: auto; resize: vertical; }
.fi-label { font-size: 12px; font-weight: 600; color: #475569; display: block; margin-bottom: 4px; }
.fi-hint  { font-size: 11.5px; color: #94a3b8; margin-top: 4px; }
.fi-error { font-size: 11.5px; color: #dc2626; margin-top: 4px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; border: 1.5px solid transparent; border-radius: 9px; padding: 0 16px; height: 38px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 120ms, border-color 120ms, box-shadow 120ms; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 14px; border-radius: 10px; }
.btn-icon { width: 38px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 30px; }

.btn-primary   { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.btn-primary:hover:not(:disabled) { background: #4338ca; border-color: #4338ca; }

.btn-secondary { background: #fff; color: #4f46e5; border-color: #c7d2fe; }
.btn-secondary:hover:not(:disabled) { background: #eef2ff; }

.btn-ghost     { background: transparent; color: #475569; border-color: #e2e8f0; }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; color: #1e293b; }

.btn-danger    { background: #fff; color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: #fff1f2; }

.btn-danger-solid { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger-solid:hover:not(:disabled) { background: #b91c1c; }

.btn-success   { background: #fff; color: #16a34a; border-color: #86efac; }
.btn-success:hover:not(:disabled) { background: #f0fdf4; }

.btn-dark      { background: #0f172a; color: #fff; border-color: #0f172a; }
.btn-dark:hover:not(:disabled) { background: #1e293b; }

.btn-amber     { background: #fff; color: #d97706; border-color: #fde68a; }
.btn-amber:hover:not(:disabled) { background: #fffbeb; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 8px; }
.badge-active   { color: #16a34a; background: #f0fdf4; border: 1px solid #bbf7d0; }
.badge-inactive { color: #94a3b8; background: #f8fafc; border: 1px solid #e2e8f0; }
.badge-draft    { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; }
.badge-paused   { color: #b45309; background: #fff7ed; border: 1px solid #fed7aa; }
.badge-error    { color: #dc2626; background: #fff1f2; border: 1px solid #fecdd3; }
.badge-pending  { color: #0369a1; background: #eff6ff; border: 1px solid #bfdbfe; }
.badge-synced   { color: #16a34a; background: #f0fdf4; border: 1px solid #bbf7d0; }
.badge-mapped   { color: #16a34a; background: #f0fdf4; border: 1px solid #bbf7d0; }
.badge-unmapped { color: #dc2626; background: #fff1f2; border: 1px solid #fecdd3; }
.badge-global   { color: #6366f1; background: #eef2ff; border: 1px solid #c7d2fe; }
.badge-code     { color: #6366f1; background: #eef2ff; border: 1px solid #c7d2fe; font-family: monospace; }
.badge-mock     { color: #92400e; background: #fef3c7; border: 1px solid #fde68a; }
.badge-google   { color: #065f46; background: #d1fae5; border: 1px solid #6ee7b7; }

/* Badge dot */
.badge-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-dot-active   { background: #16a34a; }
.badge-dot-inactive { background: #cbd5e1; }
.badge-dot-error    { background: #dc2626; }
.badge-dot-warn     { background: #f59e0b; }

/* Role badges */
.role-badge { display: inline-block; font-size: 10.5px; font-weight: 700; border-radius: 6px; padding: 2px 7px; margin: 1px; white-space: nowrap; }
.role-ADMIN      { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.role-BOARD      { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.role-SUPERVISOR { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.role-DIRECTOR   { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.role-AGENT      { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* School chips */
.school-chip { font-size: 11px; font-weight: 600; border-radius: 12px; padding: 2px 8px; background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; display: inline-block; }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; text-align: left; border-bottom: 1px solid #e2e8f0; background: #f8fafc; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: #4f46e5; }
th.sort-active { color: #4f46e5; }
td { font-size: 13px; color: #334155; padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
.td-right  { text-align: right; }
.td-center { text-align: center; }
.td-mono   { font-family: monospace; font-size: 12px; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: #94a3b8; }
.empty-state svg { opacity: .25; margin-bottom: 12px; }
.empty-state-title { font-size: 14px; font-weight: 600; color: #64748b; margin: 0 0 4px; }
.empty-state-body  { font-size: 13px; color: #94a3b8; margin: 0 0 16px; }

/* ── Audit action badges ───────────────────────────────────────────────────── */
.audit-badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 7px; white-space: nowrap; }
.audit-CREATE, .audit-ACTIVATE { color: #16a34a; background: #f0fdf4; border: 1px solid #bbf7d0; }
.audit-UPDATE { color: #0369a1; background: #f0f9ff; border: 1px solid #bae6fd; }
.audit-DELETE, .audit-DEACTIVATE, .audit-REVOKE_ROLE, .audit-BULK_REVOKE_ROLE { color: #dc2626; background: #fff1f2; border: 1px solid #fecdd3; }
.audit-TOGGLE, .audit-STATUS_CHANGE { color: #9333ea; background: #faf5ff; border: 1px solid #e9d5ff; }
.audit-ASSIGN_ROLE, .audit-BULK_ASSIGN_ROLE, .audit-SYNC_COLEGIOS, .audit-MAP_COLEGIO { color: #0891b2; background: #ecfeff; border: 1px solid #a5f3fc; }
.audit-DUPLICATE { color: #65a30d; background: #f7fee7; border: 1px solid #d9f99d; }
.audit-UPDATE_ROLE_PERMISSIONS { color: #7c3aed; background: #f5f3ff; border: 1px solid #ddd6fe; }
.audit-default { color: #475569; background: #f8fafc; border: 1px solid #e2e8f0; }

/* ── Chip selectors ────────────────────────────────────────────────────────── */
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 10px; background: #f1f5f9; border: 1.5px solid #e2e8f0; color: #475569; cursor: pointer; user-select: none; transition: all 120ms; }
.chip:hover { border-color: #a5b4fc; color: #4f46e5; }
.chip.selected, .chip[aria-pressed="true"] { background: #eef2ff; border-color: #818cf8; color: #4f46e5; }

/* ── Meta grid (for sync/config cards) ────────────────────────────────────── */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.meta-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; }
.meta-key { font-size: 11px; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.meta-val { font-size: 13px; color: #0f172a; font-weight: 600; }
.meta-val.dim { color: #94a3b8; font-weight: 400; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.hint     { font-size: 12px; color: #94a3b8; margin: 8px 0 0; line-height: 1.5; }
.code     { font-family: monospace; font-size: 12px; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; color: #334155; }
.text-muted   { color: #94a3b8; }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.ellipsis     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-mono    { font-family: monospace; }
.fw-medium    { font-weight: 500; }
.fw-semibold  { font-weight: 600; }
.fw-bold      { font-weight: 700; }
.mt-0  { margin-top: 0; }
.mb-0  { margin-bottom: 0; }
.gap-2 { gap: 8px; }

/* ── Pagination (.pgn-*) ───────────────────────────────────────────────────── */
.pgn { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 20px; border-top: 1px solid #f1f5f9; font-size: 13px; }
.pgn-info { color: #64748b; white-space: nowrap; }
.pgn-nav { display: flex; align-items: center; gap: 4px; }
.pgn-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 10px; border-radius: 7px; font-size: 13px; font-weight: 600; text-decoration: none; color: #475569; background: #fff; border: 1px solid #e2e8f0; transition: all 120ms; white-space: nowrap; cursor: pointer; }
.pgn-btn:hover:not(.pgn-btn--cur):not(.pgn-btn--dis) { background: #f1f5f9; border-color: #c7d2fe; color: #4f46e5; }
.pgn-btn--cur { background: #4f46e5; color: #fff !important; border-color: #4f46e5; cursor: default; }
.pgn-btn--dis { color: #cbd5e1; cursor: default; border-color: #f1f5f9; background: #f8fafc; }
.pgn-ellipsis { color: #94a3b8; padding: 0 4px; font-size: 13px; line-height: 32px; }
.pgn-size { display: flex; align-items: center; gap: 4px; }
.pgn-sz { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 28px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; text-decoration: none; color: #475569; border: 1px solid #e2e8f0; background: #fff; transition: all 100ms; cursor: pointer; }
.pgn-sz:hover:not(.pgn-sz--cur) { background: #f1f5f9; border-color: #c7d2fe; color: #4f46e5; }
.pgn-sz--cur { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; cursor: default; }
.pgn-sz-label { font-size: 12px; color: #94a3b8; white-space: nowrap; }

/* ── Drawer (.drawer-*) ────────────────────────────────────────────────────── */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 1000; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: 400px; max-width: 96vw; background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.12); z-index: 1001; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 250ms cubic-bezier(.4,0,.2,1); }
.drawer--open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid #e2e8f0; flex-shrink: 0; }
.drawer-title { font-size: 16px; font-weight: 700; color: #0f172a; margin: 0; }
.drawer-close { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid #e2e8f0; background: transparent; cursor: pointer; color: #64748b; transition: background 120ms; flex-shrink: 0; }
.drawer-close:hover { background: #f1f5f9; color: #1e293b; }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.drawer-section { display: flex; flex-direction: column; gap: 6px; }
.drawer-label { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .07em; }
.drawer-val { font-size: 13.5px; font-weight: 500; color: #334155; }
.drawer-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; flex-shrink: 0; display: flex; gap: 10px; align-items: center; }

/* KPI icon helper */
.kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-bottom: 10px; }
.kpi-icon--indigo  { background: #eef2ff; color: #4f46e5; }
.kpi-icon--blue    { background: #eff6ff; color: #2563eb; }
.kpi-icon--amber   { background: #fffbeb; color: #d97706; }
.kpi-icon--green   { background: #f0fdf4; color: #16a34a; }
.kpi-icon--red     { background: #fff1f2; color: #dc2626; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .page-wrap,
  .page-wrap--narrow,
  .page-wrap--wide { padding: 16px 14px 60px; }
  .ph { flex-direction: column; gap: 12px; }
  .ph-actions { width: 100%; }
  .toolbar { gap: 6px; }
  .toolbar-search { min-width: 0; max-width: none; width: 100%; }
  .hide-mobile { display: none !important; }
  th, td { padding: 8px 10px; }
}
