/* ══════════════════════════════════════════════════════════
   Base
   ══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  background: #f1f5f9;
  color: #1e293b;
}

/* ══════════════════════════════════════════════════════════
   Typography
   ══════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5 { letter-spacing: -.02em; color: #0f172a; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4, h5 { font-size: .95rem; font-weight: 600; }

/* ══════════════════════════════════════════════════════════
   Layout — sidebar + content
   ══════════════════════════════════════════════════════════ */
#wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: 230px;
  min-height: 100vh;
  background: #0f172a;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 200;
  transition: transform .25s ease;
}

/* ── Page content ────────────────────────────────────────── */
#page-content {
  flex: 1;
  margin-left: 230px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar brand ───────────────────────────────────────── */
.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #1e293b;
}

.sidebar-brand a {
  color: #f1f5f9;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: -.01em;
}

.sidebar-brand i { font-size: 1.15rem; color: #60a5fa; }

/* ── Nav list ────────────────────────────────────────────── */
.sidebar-nav {
  list-style: none;
  padding: .75rem 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav li { margin: 1px 0; }

.sidebar-section {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: .9rem 1.25rem .3rem;
}

/* ── Sidebar links ───────────────────────────────────────── */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .48rem 1.25rem;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0;
  font-size: .87rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}

.sidebar-link i { font-size: 1rem; width: 1.1rem; text-align: center; flex-shrink: 0; }

.sidebar-link:hover {
  background: #1e293b;
  color: #e2e8f0;
  text-decoration: none;
}

.sidebar-link.active {
  background: #1e3a5f;
  color: #ffffff;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #3b82f6;
  border-radius: 0 2px 2px 0;
}

/* Toggle chevron */
.sidebar-toggle { cursor: pointer; }
.sidebar-chevron {
  font-size: .7rem;
  transition: transform .2s;
  color: #475569;
}
.sidebar-toggle[aria-expanded="true"] .sidebar-chevron,
.sidebar-toggle:not(.collapsed) .sidebar-chevron {
  transform: rotate(180deg);
}

/* ── Submenu ─────────────────────────────────────────────── */
.sidebar-sub {
  list-style: none;
  padding: .2rem 0 .4rem 2.8rem;
  margin: 0;
  background: #080f1d;
}

.sidebar-sub li a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .32rem .5rem;
  color: #64748b;
  text-decoration: none;
  font-size: .83rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
}

.sidebar-sub li a i { font-size: .85rem; }

.sidebar-sub li a:hover {
  color: #cbd5e1;
  background: #0f172a;
}

.sidebar-sub li a.active {
  color: #93c5fd;
  font-weight: 600;
}

/* ── Sidebar footer ──────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid #1e293b;
  padding: .75rem 0 .5rem;
}

.sidebar-link-sm {
  font-size: .82rem;
  padding: .38rem 1.25rem;
  color: #64748b;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem .5rem;
}

.sidebar-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #1e3a5f;
  color: #93c5fd;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name  { font-size: .82rem; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: .72rem; color: #475569; }

.btn-sidebar-logout {
  background: none;
  border: none;
  color: #475569;
  font-size: 1.1rem;
  padding: .25rem;
  cursor: pointer;
  line-height: 1;
  transition: color .15s;
}
.btn-sidebar-logout:hover { color: #f87171; }

/* ══════════════════════════════════════════════════════════
   Top bar
   ══════════════════════════════════════════════════════════ */
.topbar {
  height: 54px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 99;
  gap: .75rem;
  flex-shrink: 0;
}

.topbar-toggle {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: .4rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: #475569;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.topbar-toggle:hover { background: #f1f5f9; color: #0f172a; }

.topbar-brand {
  font-weight: 700;
  font-size: .9rem;
  color: #0f172a;
  letter-spacing: -.02em;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .82rem;
  color: #64748b;
}
.topbar-user i { font-size: 1.1rem; color: #94a3b8; }

/* ══════════════════════════════════════════════════════════
   Mobile overlay
   ══════════════════════════════════════════════════════════ */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 190;
}
#sidebarOverlay.show { display: block; }

@media (max-width: 991.98px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  #page-content { margin-left: 0; }
}

/* ══════════════════════════════════════════════════════════
   Cards
   ══════════════════════════════════════════════════════════ */
.card {
  border-radius: .75rem !important;
  border: 1px solid #e8eef5 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 3px 10px rgba(0,0,0,.04) !important;
}

.card-header {
  border-radius: .75rem .75rem 0 0 !important;
  font-weight: 600;
  font-size: .85rem;
  padding: .8rem 1.25rem;
  background: #f8fafc !important;
  border-bottom: 1px solid #e8eef5 !important;
  color: #374151;
}

/* ══════════════════════════════════════════════════════════
   Stat cards (dashboard)
   ══════════════════════════════════════════════════════════ */
.stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.04em;
  color: #0f172a;
}

.stat-label {
  font-size: .78rem;
  color: #64748b;
  font-weight: 500;
  margin-top: .2rem;
}

/* ══════════════════════════════════════════════════════════
   Tables
   ══════════════════════════════════════════════════════════ */
.table th {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
  background: #f8fafc;
  padding: .65rem 1rem;
  border-bottom: 2px solid #e2e8f0 !important;
  border-top: none;
}

.table td {
  vertical-align: middle;
  padding: .65rem 1rem;
  border-color: #f1f5f9 !important;
  color: #374151;
}

.table-hover > tbody > tr:hover > * { background: #f8fafc !important; }
.table > tbody > tr:last-child > td { border-bottom: none !important; }

/* ══════════════════════════════════════════════════════════
   Badges
   ══════════════════════════════════════════════════════════ */
.badge {
  font-weight: 500;
  letter-spacing: .02em;
  padding: .3em .6em;
  border-radius: .35rem;
  font-size: .72rem;
}

/* ══════════════════════════════════════════════════════════
   Alerts (Django messages)
   ══════════════════════════════════════════════════════════ */
.alert { border-radius: .6rem; font-size: .875rem; border-left-width: 4px; }
.alert-warning { background: #fef9c3; color: #854d0e; border-color: #fbbf24; }
.alert-success  { background: #f0fdf4; color: #166534; border-color: #22c55e; }
.alert-error,
.alert-danger   { background: #fef2f2; color: #991b1b; border-color: #f87171; }
.alert-info     { background: #eff6ff; color: #1d4ed8; border-color: #60a5fa; }

/* ══════════════════════════════════════════════════════════
   Filter bar
   ══════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}

.filter-bar input[type="text"],
.filter-bar select {
  display: inline-block !important;
  width: auto !important;
  height: 2rem;
  border: 1px solid #dde3ec;
  border-radius: 2rem;
  font-size: .8rem;
  color: #374151;
  background-color: #f8fafc;
  transition: border-color .15s, background-color .15s;
  line-height: 1;
}

.filter-bar input[type="text"] {
  padding: 0 .85rem;
  min-width: 150px;
  flex: 1;
  max-width: 240px;
}

.filter-bar input[type="text"]:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  background-color: #fff;
  outline: none;
}

.filter-bar select {
  padding: 0 1.85rem 0 .7rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 16 16'%3E%3Cpath fill='%2394a3b8' d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  cursor: pointer;
}

.filter-bar select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  background-color: #fff;
  outline: none;
}

.filter-bar select.is-filtered,
.filter-bar input[type="text"].is-filtered {
  background-color: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 500;
}

.filter-bar .btn {
  height: 2rem;
  padding: 0 .9rem;
  font-size: .8rem;
  border-radius: 2rem !important;
  line-height: 2rem;
}

.filter-bar .btn-link {
  height: auto;
  border-radius: 0 !important;
  font-size: .78rem;
  line-height: 1.4;
  padding: 0;
}

/* Alert badges — data quality indicators */
.alert-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25em .65em;
  border-radius: 2rem;
  font-size: .75rem;
  font-weight: 500;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  text-decoration: none;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.alert-badge:hover {
  background: #fde68a;
  border-color: #f59e0b;
  color: #78350f;
  text-decoration: none;
}

.alert-badge.alert-badge-active {
  background: #f59e0b;
  border-color: #d97706;
  color: #fff;
}

/* ══════════════════════════════════════════════════════════
   Forms
   ══════════════════════════════════════════════════════════ */
.form-control, .form-select {
  font-size: .875rem;
  border-color: #d1d9e0;
  border-radius: .45rem;
  background: #fff;
  color: #1e293b;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  background: #fff;
}

.form-label  { font-weight: 500; font-size: .84rem; color: #374151; margin-bottom: .35rem; }
.form-text   { font-size: .78rem; }

/* ══════════════════════════════════════════════════════════
   Buttons
   ══════════════════════════════════════════════════════════ */
.btn     { font-weight: 500; font-size: .875rem; border-radius: .45rem; }
.btn-sm  { font-size: .8rem; border-radius: .4rem; }

.btn-primary                { background: #2563eb; border-color: #2563eb; }
.btn-primary:hover          { background: #1d4ed8; border-color: #1d4ed8; }
.btn-outline-primary        { color: #2563eb; border-color: #2563eb; }
.btn-outline-primary:hover  { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ══════════════════════════════════════════════════════════
   List group
   ══════════════════════════════════════════════════════════ */
.list-group-item { border-color: #f1f5f9; padding: .75rem 1.25rem; font-size: .875rem; color: #374151; }
.list-group-item-action:hover { background: #f8fafc !important; color: #0f172a; }

/* ══════════════════════════════════════════════════════════
   Saturday checkboxes in availability forms
   ══════════════════════════════════════════════════════════ */
.sabados-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .4rem;
}

.sabado-check {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: .4rem .6rem;
  cursor: pointer;
  transition: background .1s, border-color .1s;
}

.sabado-check input[type="checkbox"] {
  cursor: pointer;
}

.sabado-check:has(input:checked) {
  background: #eff6ff;
  border-color: #3b82f6;
}

/* ── Asterisco de campos obligatorios ─────────────────────── */
.asteriskField {
  color: #dc3545;
  font-weight: 700;
  margin-left: 3px;
}


/* ══════════════════════════════════════════════════════════
   Field overridden — used when a form field is superseded by another setting
   ══════════════════════════════════════════════════════════ */
.field-overridden {
  opacity: .4;
  transition: opacity .2s;
}
.field-overridden .form-control,
.field-overridden .form-select {
  background: #f1f5f9;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════
   WhatsApp bubble
   ══════════════════════════════════════════════════════════ */
.wa-bubble {
  background: #dcf8c6;
  border-radius: 0 10px 10px 10px;
  max-width: 75%;
  padding: .75rem 1rem;
  white-space: pre-wrap;
  font-size: .9rem;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════
   Teléfono con prefijo (DocenteForm)
   ══════════════════════════════════════════════════════════ */
.telefono-input-group { flex-wrap: nowrap; }

.prefijo-tel {
  width: auto !important;
  max-width: 195px;
  flex: 0 0 auto;
  border-right: 0 !important;
  border-radius: .45rem 0 0 .45rem !important;
  font-size: .875rem;
  background-color: #f8fafc;
  color: #374151;
}

.telefono-input-group .form-control {
  border-radius: 0 .45rem .45rem 0 !important;
}

/* ══════════════════════════════════════════════════════════
   Help / Ayuda page
   ══════════════════════════════════════════════════════════ */
.ayuda-section {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #e8eef5;
}
.ayuda-section:last-child { border-bottom: none; }
.ayuda-section h2 { margin-bottom: 1rem; }
.ayuda-section h5 { margin-top: 1.25rem; margin-bottom: .5rem; color: #374151; }

.ayuda-fase-badge {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: .4rem;
  font-size: .75rem;
  font-weight: 700;
  padding: .15em .55em;
  margin-right: .4rem;
  vertical-align: middle;
  letter-spacing: .02em;
}

.ayuda-steps {
  padding-left: 1.3rem;
}
.ayuda-steps > li {
  margin-bottom: .6rem;
  line-height: 1.6;
}

.ayuda-estados {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
}

/* Sticky TOC */
.ayuda-toc {
  position: sticky;
  top: calc(54px + 1.5rem);
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding: 1rem 1rem 1rem .5rem;
  border-left: 2px solid #e8eef5;
}
.ayuda-toc-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #94a3b8;
  margin-bottom: .5rem;
}
.ayuda-toc .nav-link {
  font-size: .8rem;
  color: #475569;
  padding: .2rem .5rem;
  border-radius: .3rem;
}
.ayuda-toc .nav-link:hover {
  color: #1d4ed8;
  background: #eff6ff;
}

/* ══════════════════════════════════════════════════════════
   Misc
   ══════════════════════════════════════════════════════════ */
dl dt { font-weight: 500; font-size: .82rem; color: #64748b; }
dl dd { font-size: .875rem; color: #1e293b; }
a.text-decoration-none:hover { text-decoration: underline !important; }
