/* =============================================================
   SISTEMA CADI — Hoja de estilos principal
   Paleta: Verde salvia / Teal cálido + Ámbar
   Fuentes: sistema local (sin dependencia de internet)
============================================================= */

:root {
  --teal-50:  #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;

  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  --rose-500: #f43f5e;
  --rose-600: #e11d48;

  --green-500: #22c55e;

  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --sidebar-w: 260px;
  --header-h:  64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);

  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: Georgia, 'Times New Roman', serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--gray-50);
  color: var(--gray-700);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-600); text-decoration: none; }
a:hover { color: var(--teal-700); }

/* ── LOGIN ─────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--teal-900);
}
@media (max-width: 768px) {
  .login-wrapper { grid-template-columns: 1fr; }
  .login-left { display: none; }
}

.login-left {
  background: linear-gradient(145deg, var(--teal-800) 0%, var(--teal-600) 60%, var(--amber-500) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -200px; left: -200px;
}
.login-left::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  bottom: -100px; right: -100px;
}
.login-brand {
  position: relative; z-index: 1;
  text-align: center; color: #fff;
}
.login-brand .brand-icon {
  width: 80px; height: 80px;
  background: rgba(255,255,255,.15);
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2.5rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
}
.login-brand h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: .5rem;
}
.login-brand p { opacity: .8; font-size: .95rem; }
.login-features { margin-top: 3rem; position: relative; z-index: 1; }
.login-features .feat {
  display: flex; align-items: center; gap: 1rem;
  color: rgba(255,255,255,.85);
  margin-bottom: 1.25rem;
  font-size: .9rem;
}
.login-features .feat .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber-400);
  flex-shrink: 0;
}

.login-right {
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 3rem;
}
.login-form-box { width: 100%; max-width: 400px; }
.login-form-box h2 {
  font-size: 1.6rem; font-weight: 700;
  color: var(--gray-800); margin-bottom: .5rem;
}
.login-form-box .subtitle {
  color: var(--gray-500); font-size: .9rem; margin-bottom: 2rem;
}

/* ── LAYOUT PRINCIPAL ──────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--teal-900);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100;
  transition: transform .3s ease;
}
.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-header .logo-icon {
  width: 38px; height: 38px;
  background: var(--teal-600);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.sidebar-header .logo-text { color: #fff; }
.sidebar-header .logo-text strong {
  display: block; font-size: .95rem; font-weight: 700; line-height: 1.2;
}
.sidebar-header .logo-text small {
  font-size: .72rem; opacity: .6; font-weight: 400;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }
.nav-section-label {
  padding: .5rem 1.5rem .3rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.35);
}
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.5rem;
  color: rgba(255,255,255,.65);
  font-size: .875rem; font-weight: 500;
  transition: all .2s;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: var(--teal-400);
}
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--amber-500);
  color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-card {
  display: flex; align-items: center; gap: .75rem;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--teal-600);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
  color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong {
  display: block; color: #fff; font-size: .83rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info small { color: rgba(255,255,255,.45); font-size: .72rem; }
.btn-logout {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.4); font-size: 1rem;
  padding: .25rem; transition: color .2s;
}
.btn-logout:hover { color: var(--rose-500); }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 1.75rem;
  position: sticky; top: 0; z-index: 50;
  gap: 1rem;
}
.topbar .page-title {
  flex: 1;
  font-size: 1rem; font-weight: 600;
  color: var(--gray-800);
}
.topbar .page-title span { color: var(--gray-400); font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

.page-body {
  padding: 1.75rem;
  flex: 1;
}

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 1rem;
}
.card-header h3 {
  font-size: 1rem; font-weight: 700;
  color: var(--gray-800); flex: 1;
}
.card-body { padding: 1.5rem; }
.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex; gap: 1rem;
  align-items: flex-start;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.teal   { background: var(--teal-50);   color: var(--teal-600); }
.stat-icon.amber  { background: var(--amber-50);  color: var(--amber-600); }
.stat-icon.rose   { background: #fff1f2;           color: var(--rose-600); }
.stat-icon.green  { background: #f0fdf4;           color: #16a34a; }

.stat-info { flex: 1; }
.stat-value {
  font-size: 1.7rem; font-weight: 800;
  color: var(--gray-900); line-height: 1;
  margin-bottom: .2rem;
}
.stat-label { font-size: .8rem; color: var(--gray-500); }
.stat-sub   { font-size: .75rem; color: var(--gray-400); margin-top: .25rem; }

/* ── FORMS ─────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: .82rem; font-weight: 600;
  color: var(--gray-700);
}
.form-label .req { color: var(--rose-500); margin-left: 2px; }
.form-control {
  padding: .6rem .875rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: .875rem;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  width: 100%;
  text-transform: uppercase;
}
/* Campos que NO deben ser mayúsculas */
input[type="email"].form-control,
input[type="password"].form-control,
input[type="date"].form-control,
input[type="time"].form-control,
input[type="number"].form-control,
input[type="color"].form-control,
select.form-control,
.no-upper { text-transform: none; }
.form-control:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(20,184,166,.12);
}
.form-control::placeholder { color: var(--gray-400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: .75rem; color: var(--gray-400); }
.form-error { font-size: .75rem; color: var(--rose-600); }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: .875rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all .18s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm { padding: .4rem .9rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.75rem; font-size: .95rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: var(--teal-600); color: #fff; }
.btn-primary:hover { background: var(--teal-700); color: #fff; box-shadow: var(--shadow); }

.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); color: var(--gray-800); }

.btn-danger { background: var(--rose-500); color: #fff; }
.btn-danger:hover { background: var(--rose-600); color: #fff; }

.btn-success { background: var(--green-500); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; }

.btn-amber { background: var(--amber-500); color: #fff; }
.btn-amber:hover { background: var(--amber-600); color: #fff; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--teal-500); color: var(--teal-600); background: var(--teal-50); }

/* ── TABLES ────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
.data-table thead tr {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}
.data-table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-500); white-space: nowrap;
}
.data-table td { padding: .875rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }

/* ── BADGES ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .7rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700;
}
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-warning  { background: #fef9c3; color: #a16207; }
.badge-danger   { background: #ffe4e6; color: #be123c; }
.badge-info     { background: var(--teal-100); color: var(--teal-700); }
.badge-gray     { background: var(--gray-100); color: var(--gray-600); }
.badge-amber    { background: var(--amber-100); color: var(--amber-600); }

/* ── ALERTS ────────────────────────────────────────────── */
.alert {
  padding: .875rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: flex; align-items: flex-start; gap: .75rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-error   { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.alert-warning { background: var(--amber-50); border-color: var(--amber-100); color: #92400e; }
.alert-info    { background: var(--teal-50);  border-color: var(--teal-100); color: var(--teal-700); }
.alert-icon    { font-size: 1.1rem; flex-shrink: 0; margin-top: .1rem; }

/* ── MODALS ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(.96) translateY(8px);
  transition: transform .2s;
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h4 { font-size: 1rem; font-weight: 700; color: var(--gray-800); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.3rem; color: var(--gray-400); padding: .25rem; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: .75rem;
}

/* ── MISC ──────────────────────────────────────────────── */
.section-title {
  font-size: 1.3rem; font-weight: 800; color: var(--gray-900);
  margin-bottom: .25rem;
}
.section-sub { color: var(--gray-500); font-size: .875rem; margin-bottom: 1.5rem; }

.empty-state {
  text-align: center; padding: 3rem 2rem; color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state p { font-size: .9rem; }

.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--gray-500); }
.text-small { font-size: .8rem; }
.text-right { text-align: right; }
.font-mono { font-family: 'Courier New', monospace; }

/* Breadcrumb */
.breadcrumb {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; color: var(--gray-500); margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--teal-600); }
.breadcrumb .sep { color: var(--gray-300); }

/* Search bar */
.search-bar {
  display: flex; align-items: center; gap: .5rem;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: .5rem .875rem;
  transition: all .2s;
}
.search-bar:focus-within {
  background: #fff;
  border-color: var(--teal-400);
  box-shadow: 0 0 0 3px rgba(20,184,166,.1);
}
.search-bar input {
  border: none; background: transparent; outline: none;
  font-family: var(--font-main); font-size: .875rem;
  color: var(--gray-700); width: 100%;
}
.search-bar .search-icon { color: var(--gray-400); font-size: .9rem; }

/* Pagination */
.pagination {
  display: flex; align-items: center; gap: .35rem;
  justify-content: center; padding: 1rem 0;
}
.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600;
  border: 1.5px solid var(--gray-200);
  background: #fff; color: var(--gray-600);
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.page-btn:hover, .page-btn.active {
  background: var(--teal-600); border-color: var(--teal-600);
  color: #fff;
}

/* Alumno avatar chip */
.alumno-chip {
  display: flex; align-items: center; gap: .6rem;
}
.alumno-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: #fff; font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.alumno-avatar.fem { background: linear-gradient(135deg, var(--amber-400), var(--rose-500)); }
.alumno-chip .chip-name { font-weight: 600; color: var(--gray-800); font-size: .875rem; }
.alumno-chip .chip-code { font-size: .72rem; color: var(--gray-400); font-family: monospace; }

/* Actions col */
.actions { display: flex; gap: .4rem; }

/* Service tags */
.service-tag {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .7rem; font-weight: 600;
  margin: .1rem;
}
.tag-programa { background: #ede9fe; color: #5b21b6; }
.tag-escuela  { background: #dbeafe; color: #1d4ed8; }
.tag-terapia  { background: #fce7f3; color: #9d174d; }

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}
@media (max-width: 600px) {
  .page-body { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Print */
@media print {
  .sidebar, .topbar, .actions, .btn { display: none !important; }
  .main-content { margin-left: 0; }
}
