/* =====================================================================
   Sistema de Academias Escolares - Hoja de estilos compartida
   ===================================================================== */

:root {
  --brand-primary: #1e40af;
  --brand-primary-dark: #16307f;
  --brand-secondary: #f59e0b;
  --brand-accent: #0ea5e9;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-alt: #eef1f8;
  --text: #1b2437;
  --text-muted: #64748b;
  --border: #e2e7f0;
  --success: #16a34a;
  --success-bg: #ecfdf3;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning-bg: #fffbeb;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.18);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

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

img { max-width: 100%; }

a { color: inherit; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- Layout helpers ---------- */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Topbar (public) ---------- */
.topbar {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff;
  padding: 28px 0 60px;
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__logo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: rgba(255,255,255,0.16);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.topbar__title h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .2px;
}

.topbar__title p {
  margin: 2px 0 0;
  font-size: .88rem;
  opacity: .85;
}

.hero {
  text-align: center;
  padding: 46px 0 30px;
  color: #fff;
}

.hero h2 {
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  margin: 0 0 10px;
  font-weight: 800;
}

.hero p {
  margin: 0 auto;
  max-width: 640px;
  opacity: .9;
  font-size: 1rem;
}

/* ---------- Toolbar (filters + search) ---------- */
.toolbar {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 22px;
  margin-top: -46px;
  position: relative;
  z-index: 5;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.filter-chip:hover { border-color: var(--brand-accent); color: var(--text); }

.filter-chip.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  min-width: 240px;
  flex: 1 1 240px;
  max-width: 360px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  color: var(--text);
  font-size: .92rem;
}

/* ---------- Cards grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 32px 0 60px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .15s ease, box-shadow .15s ease;
}

.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.card__level {
  align-self: flex-start;
  background: var(--brand-accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 12px;
  border-radius: 999px;
}

.card__title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  color: var(--text);
}

.card__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .88rem;
  color: var(--text-muted);
}

.card__meta div { display: flex; gap: 8px; align-items: flex-start; }
.card__meta .ico { flex-shrink: 0; opacity: .7; }

.card__cta {
  margin-top: auto;
  padding-top: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-weight: 700;
  font-size: .94rem;
  cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .82rem; border-radius: 8px; }

.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary { background: var(--brand-secondary); color: #fff; }
.btn-secondary:hover { filter: brightness(1.06); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-alt); }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px;
  animation: modalIn .18s ease;
}

.modal.modal-lg { max-width: 900px; }
.modal.modal-md { max-width: 620px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.modal__title { font-size: 1.2rem; font-weight: 800; margin: 0; }
.modal__subtitle { color: var(--text-muted); font-size: .9rem; margin: 4px 0 0; }

.modal__close {
  border: none; background: var(--surface-alt);
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 1.1rem; cursor: pointer; color: var(--text-muted);
  flex-shrink: 0;
}
.modal__close:hover { background: var(--danger-bg); color: var(--danger); }

.modal__body { margin-top: 16px; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 22px; flex-wrap: wrap;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-weight: 700; font-size: .86rem;
  margin-bottom: 6px; color: var(--text);
}
.form-group .hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-control {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s ease;
}
.form-control:focus { border-color: var(--brand-primary); }
.form-control.invalid { border-color: var(--danger); background: var(--danger-bg); }

select.form-control { cursor: pointer; }

.field-error { color: var(--danger); font-size: .78rem; margin-top: 4px; display: none; }
.field-error.show { display: block; }

/* ---------- Alerts / toasts ---------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: #92400e; }

.toast-stack {
  position: fixed; top: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 340px;
}
.toast {
  background: var(--surface);
  border-left: 4px solid var(--success);
  box-shadow: var(--shadow-md);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: .88rem;
  font-weight: 600;
  animation: toastIn .18s ease;
}
.toast.error { border-left-color: var(--danger); color: var(--danger); }
@keyframes toastIn { from { opacity:0; transform: translateX(20px);} to {opacity:1; transform: translateX(0);} }

/* ---------- Success confirmation ---------- */
.confirm-box {
  text-align: center;
  padding: 6px 0 4px;
}
.confirm-box .check-circle {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--success-bg); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 14px;
}
.confirm-detail {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: left;
  font-size: .9rem;
  margin-top: 16px;
  display: grid;
  gap: 6px;
}
.confirm-detail b { color: var(--text); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .ico { font-size: 2.6rem; margin-bottom: 10px; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 26px 20px 40px;
  color: var(--text-muted);
  font-size: .82rem;
}

/* =====================================================================
   ADMIN
   ===================================================================== */

.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 250px;
  background: #101a33;
  color: #cbd5f0;
  flex-shrink: 0;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 800; font-size: 1.05rem;
  padding: 6px 10px 20px;
}

.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  color: #b7c3e4; text-decoration: none; font-weight: 600; font-size: .92rem;
}
.admin-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-nav a.active { background: var(--brand-primary); color: #fff; }

.admin-main { flex: 1; min-width: 0; }

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 26px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}

.admin-topbar h1 { font-size: 1.15rem; margin: 0; }
.admin-content { padding: 24px 26px 60px; }

.admin-userchip {
  display: flex; align-items: center; gap: 10px;
  font-size: .88rem; color: var(--text-muted);
}
.admin-userchip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}

.mobile-menu-btn {
  display: none;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; width: 38px; height: 38px; font-size: 1.1rem; cursor: pointer;
}

/* Stat tiles */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-tile .label { color: var(--text-muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.stat-tile .value { font-size: 1.9rem; font-weight: 800; margin-top: 6px; color: var(--text); }
.stat-tile.accent-primary .value { color: var(--brand-primary); }
.stat-tile.accent-secondary .value { color: var(--brand-secondary); }
.stat-tile.accent-success .value { color: var(--success); }

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data-table thead th {
  background: var(--surface-alt);
  text-align: left;
  padding: 12px 16px;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-alt); }
.table-scroll { overflow-x: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--surface-alt); color: var(--text-muted); }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

.toolbar-admin {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
}
.filters-admin { display: flex; gap: 10px; flex-wrap: wrap; }
.filters-admin select, .filters-admin input {
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
  font-size: .86rem; background: var(--surface);
}

.section-title {
  font-size: 1.05rem; font-weight: 800; margin: 30px 0 14px;
}

.academy-admin-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm);
}
.academy-admin-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.academy-admin-card h3 { margin: 0; font-size: 1.05rem; }
.academy-admin-card .meta { font-size: .84rem; color: var(--text-muted); display: grid; gap: 4px; }
.academy-admin-card .enrolled { font-weight: 800; color: var(--brand-primary); font-size: .92rem; }
.academy-admin-card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 34px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone.dragover { border-color: var(--brand-primary); background: var(--surface-alt); }
.dropzone input { display: none; }

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 36px 32px; width: 100%; max-width: 380px;
}
.login-card h1 { margin: 0 0 4px; font-size: 1.3rem; }
.login-card p.sub { color: var(--text-muted); margin: 0 0 22px; font-size: .88rem; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .admin-sidebar { position: fixed; left: -270px; top: 0; z-index: 60; transition: left .2s ease; box-shadow: var(--shadow-lg); }
  .admin-sidebar.open { left: 0; }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { flex: none; width: 100%; max-width: none; min-width: 0; }
  .grid { grid-template-columns: 1fr; }
  .hero { padding: 30px 0 20px; }
  .admin-content { padding: 18px 14px 50px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
