/* ============================================================
   Panel de Administración — Colegio El Encuentro
   Estilo institucional: verde profundo + acentos dorados.
   Sin frameworks. Responsive.
   ============================================================ */

:root {
  --verde-profundo: #123a2b;
  --verde: #1c5a41;
  --verde-claro: #2f7d5c;
  --verde-suave: #e8f1ec;

  --dorado: #c9a227;
  --dorado-claro: #e6c757;

  --gris-bg: #f4f6f5;
  --gris-panel: #ffffff;
  --gris-borde: #e2e6e4;
  --gris-texto: #2c3330;
  --gris-suave: #6b7570;

  --rojo: #c0392b;
  --rojo-suave: #fdecea;
  --amarillo-suave: #fff7e0;

  --radio: 10px;
  --radio-lg: 16px;
  --sombra: 0 2px 8px rgba(18, 58, 43, .06);
  --sombra-lg: 0 10px 30px rgba(18, 58, 43, .12);

  --fuente: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--fuente);
  color: var(--gris-texto);
  background: var(--gris-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 .75rem; }
a { color: var(--verde); }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  padding: .62rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radio);
  cursor: pointer;
  transition: all .16s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--verde); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--verde-profundo); }
.btn-ghost { background: transparent; color: var(--verde); border-color: var(--gris-borde); }
.btn-ghost:hover:not(:disabled) { background: var(--verde-suave); border-color: var(--verde-claro); }
.btn-danger { background: var(--rojo); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a5311f; }
.btn-gold { background: var(--dorado); color: #2a2205; }
.btn-gold:hover:not(:disabled) { background: var(--dorado-claro); }
.btn-sm { font-size: .82rem; padding: .42rem .8rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .4rem .55rem; font-size: .95rem; }

/* ---------------- Login ---------------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(47,125,92,.35), transparent 60%),
    linear-gradient(160deg, #0e2e22 0%, #123a2b 45%, #0c2419 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-lg);
  padding: 2.2rem 2rem 1.6rem;
}
.login-brand { text-align: center; margin-bottom: 1.6rem; }
.login-logo { height: 64px; margin-bottom: .8rem; }
.login-brand h1 { font-size: 1.28rem; color: var(--verde-profundo); }
.login-brand p { color: var(--gris-suave); font-size: .9rem; margin: 0; }
.login-hint { text-align: center; font-size: .78rem; color: var(--gris-suave); margin: 1rem 0 0; }
.login-error { color: var(--rojo); font-size: .85rem; min-height: 1.1rem; margin: .3rem 0 .6rem; }

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gris-suave);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field input[type="number"],
.field input[type="url"],
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: .95rem;
  color: var(--gris-texto);
  background: #fbfcfb;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: .62rem .8rem;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--verde-claro);
  box-shadow: 0 0 0 3px rgba(47,125,92,.14);
  background: #fff;
}
.field textarea { resize: vertical; min-height: 90px; }
.field .help { font-size: .78rem; color: var(--gris-suave); margin-top: .25rem; }
.field .req { color: var(--rojo); }
.field-check { display: flex; align-items: center; gap: .5rem; }
.field-check input { width: auto; }

/* ---------------- Layout app ---------------- */
.app-view { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 264px;
  background: linear-gradient(180deg, #123a2b 0%, #0e2e22 100%);
  color: #dbe7e1;
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .55rem;
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.sidebar-logo { height: 38px; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand-text strong { font-size: .98rem; color: #fff; }
.sidebar-brand-text span { font-size: .74rem; color: #93b3a5; }

.sidebar-nav { flex: 1; padding: .8rem .7rem; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: .93rem;
  font-weight: 500;
  color: #c7d8d0;
  background: transparent;
  border: 0;
  border-radius: var(--radio);
  padding: .66rem .8rem;
  margin-bottom: .18rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--dorado); color: #241d04; font-weight: 700; }
.ni-icon { font-size: 1rem; width: 1.1rem; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--rojo);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .1rem .45rem;
  min-width: 1.2rem;
  text-align: center;
  display: none;
}
.nav-badge.show { display: inline-block; }

.sidebar-foot {
  padding: .9rem 1rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,.09);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
  color: #9fbdb0;
  margin-bottom: .6rem;
  overflow: hidden;
}
.user-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; flex-shrink: 0; }
.sidebar-foot .btn-ghost { color: #c7d8d0; border-color: rgba(255,255,255,.16); }
.sidebar-foot .btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }

.main-wrap { margin-left: 264px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border-bottom: 1px solid var(--gris-borde);
  padding: .8rem 1.6rem;
}
.topbar h2 { font-size: 1.18rem; color: var(--verde-profundo); margin: 0; flex: 1; }
.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  font-size: 1.2rem;
  padding: .25rem .6rem;
  cursor: pointer;
  color: var(--verde);
}

.content { padding: 1.6rem; flex: 1; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,25,18,.5);
  z-index: 55;
}

/* ---------------- Tarjetas ---------------- */
.card {
  background: var(--gris-panel);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra);
  margin-bottom: 1.3rem;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.3rem;
  border-bottom: 1px solid var(--gris-borde);
  background: #fcfdfc;
}
.card-head h3 { font-size: 1.02rem; margin: 0; color: var(--verde-profundo); flex: 1; }
.card-body { padding: 1.3rem; }

/* ---------------- Resumen (inicio) ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.3rem;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio-lg);
  padding: 1.2rem;
  box-shadow: var(--sombra);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--verde-claro);
}
.stat-card.gold::after { background: var(--dorado); }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--verde-profundo); line-height: 1; }
.stat-lbl { font-size: .84rem; color: var(--gris-suave); margin-top: .35rem; }

/* ---------------- Tablas ---------------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
table.data th {
  text-align: left;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gris-suave);
  background: #fafbfa;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--gris-borde);
  white-space: nowrap;
}
table.data td {
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--gris-borde);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fbfdfc; }
.cell-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.td-muted { color: var(--gris-suave); }
.td-truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Badges / pills ---------------- */
.pill {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .2rem .6rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.pill-on { background: #dff3e7; color: #1b6b45; }
.pill-off { background: #eee; color: #777; }
.pill-new { background: var(--rojo-suave); color: var(--rojo); }
.pill-cat { background: var(--verde-suave); color: var(--verde); }

/* ---------------- Paginación ---------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.3rem;
  border-top: 1px solid var(--gris-borde);
  background: #fcfdfc;
  flex-wrap: wrap;
}
.pager-info { font-size: .82rem; color: var(--gris-suave); }
.pager-btns { display: flex; gap: .35rem; align-items: center; }
.pager-btns button {
  min-width: 34px;
  font-family: inherit;
  font-size: .85rem;
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  padding: .35rem .55rem;
  cursor: pointer;
  color: var(--verde-profundo);
}
.pager-btns button:hover:not(:disabled) { background: var(--verde-suave); }
.pager-btns button.active { background: var(--verde); color: #fff; border-color: var(--verde); font-weight: 700; }
.pager-btns button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- Estados ---------------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gris-suave); }
.empty-icon { font-size: 2.4rem; opacity: .5; margin-bottom: .5rem; }
.loading-row { display: flex; align-items: center; gap: .6rem; padding: 2rem; color: var(--gris-suave); justify-content: center; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--gris-borde);
  border-top-color: var(--verde);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,25,18,.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  z-index: 100;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-lg);
  width: 100%;
  max-width: 580px;
  animation: modalIn .18s ease;
  margin: auto;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--gris-borde);
}
.modal-head h3 { flex: 1; margin: 0; font-size: 1.1rem; color: var(--verde-profundo); }
.modal-x {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--gris-suave);
  cursor: pointer;
  padding: 0 .3rem;
}
.modal-content { padding: 1.4rem; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--gris-borde);
  background: #fcfdfc;
}
.modal-foot:empty { display: none; }
.modal-text { color: var(--gris-texto); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .field.full { grid-column: 1 / -1; }

/* ---------------- Toasts ---------------- */
#toast-container {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  background: #fff;
  border-left: 4px solid var(--verde);
  border-radius: var(--radio);
  box-shadow: var(--sombra-lg);
  padding: .85rem 1rem;
  font-size: .9rem;
  animation: toastIn .22s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast-out { opacity: 0; transform: translateX(20px); transition: all .3s; }
.toast-error { border-left-color: var(--rojo); }
.toast-error .toast-icon { color: var(--rojo); }
.toast-success { border-left-color: #1b6b45; }
.toast-success .toast-icon { color: #1b6b45; }
.toast-info .toast-icon { color: var(--verde-claro); }
.toast-icon { font-weight: 700; }
.toast-msg { flex: 1; }
.toast-close { background: 0; border: 0; font-size: 1.2rem; cursor: pointer; color: var(--gris-suave); line-height: 1; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--sombra-lg); }
  .main-wrap { margin-left: 0; }
  .menu-toggle { display: inline-block; }
  .sidebar-backdrop.show { display: block; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .content { padding: 1rem .9rem; }
  .topbar { padding: .7rem 1rem; flex-wrap: wrap; }
  .topbar h2 { font-size: 1.02rem; order: 3; flex-basis: 100%; }
  .login-card { padding: 1.6rem 1.3rem; }
  #toast-container { left: .8rem; right: .8rem; max-width: none; }
  .card-head { flex-wrap: wrap; }
}
