/* ========================================
   COLISIONADOR DE HORARIOS - Estilos
   ======================================== */

:root {
  --azul: #1a3a6c;
  --azul-medio: #2457a0;
  --azul-claro: #3b7dd8;
  --teal: #0d7b6e;
  --rojo: #c0392b;
  --rojo-claro: #f8d7da;
  --verde: #1e8449;
  --verde-claro: #d4edda;
  --amarillo: #f9ca24;
  --naranja: #e67e22;
  --gris: #6c757d;
  --gris-claro: #f4f6f8;
  --borde: #dee2e6;
  --sombra: 0 2px 8px rgba(0,0,0,.12);
}

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

body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  background: #eef1f5;
  color: #212529;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ── */
.navbar {
  background: var(--azul);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 54px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  position: sticky; top: 0; z-index: 1000;
  gap: 12px;
}
.navbar-brand {
  font-size: 15px; font-weight: 700; color: #fff; text-decoration: none;
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  line-height: 1.2;
}
.navbar-brand .brand-sub { font-size: 10px; font-weight: 400; opacity: .65; display:block; }
.navbar-brand .brand-ver { font-size: 9px; opacity:.5; margin-left:4px; }

/* Menú principal con dropdowns */
.navbar-menu { display: flex; gap: 2px; align-items: center; flex: 1; }

.navbar-menu > a,
.nav-dropdown > .nav-btn {
  color: rgba(255,255,255,.88); text-decoration: none;
  padding: 6px 11px; border-radius: 5px; font-size: 12.5px;
  transition: background .15s; white-space: nowrap;
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  height: 36px;
}
.navbar-menu > a:hover,
.navbar-menu > a.active,
.nav-dropdown:hover > .nav-btn,
.nav-dropdown.active > .nav-btn {
  background: rgba(255,255,255,.18); color: #fff;
}
.nav-btn-arrow { font-size: 8px; opacity: .7; margin-left: 1px; }

/* Dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: #fff; border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  min-width: 180px; overflow: hidden; z-index: 2000;
  /* Área invisible que tapa el gap entre botón y menú */
  padding-top: 6px;
  margin-top: 0;
}
/* Puente invisible para no perder el hover al cruzar el gap */
.nav-dropdown::after {
  content: ''; display: block;
  position: absolute; height: 8px;
  left: 0; right: 0; top: 100%;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
  display: block; padding: 9px 16px;
  color: #1a3a6c; text-decoration: none; font-size: 12.5px;
  transition: background .12s; white-space: nowrap;
}
.nav-dropdown-menu a:hover { background: #f0f4fb; }
.nav-dropdown-menu a.active { background: #e8f0fe; font-weight: 700; }
.nav-dropdown-menu .nav-sep {
  height: 1px; background: #e9ecef; margin: 4px 0;
}

/* Usuario + logout (lado derecho) */
.navbar-user {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; font-size: 12px;
}
.navbar-user .user-name {
  color: rgba(255,255,255,.85); white-space: nowrap;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.navbar-rol-badge {
  padding: 2px 8px; border-radius: 10px; font-size: 10px;
  font-weight: 700; color: #fff; white-space: nowrap;
}
.navbar-inst-chip {
  font-size: 10.5px; color: rgba(255,255,255,.65);
  background: rgba(255,255,255,.12); padding: 2px 8px;
  border-radius: 10px; white-space: nowrap;
}
.navbar-logout {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.9);
  padding: 5px 10px; border-radius: 6px; text-decoration: none;
  font-size: 12px; font-weight: 600; transition: background .15s;
  white-space: nowrap;
}
.navbar-logout:hover { background: rgba(255,255,255,.25); color: #fff; }

/* ── Layout ── */
.page-wrap { max-width: 1500px; margin: 0 auto; padding: 20px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--azul); }

/* ── Cards ── */
.card {
  background: #fff; border-radius: 8px;
  box-shadow: var(--sombra); margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  background: var(--azul); color: #fff;
  padding: 10px 18px; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-header.teal { background: var(--teal); }
.card-body { padding: 18px; }

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; border-radius: 5px; border: none; cursor: pointer;
  font-size: 12.5px; font-weight: 600; text-decoration: none;
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--azul-medio); color: #fff; }
.btn-success { background: var(--verde); color: #fff; }
.btn-danger  { background: var(--rojo); color: #fff; }
.btn-warning { background: var(--naranja); color: #fff; }
.btn-secondary{ background: var(--gris); color: #fff; }
.btn-outline {
  background: transparent; color: var(--azul-medio);
  border: 1.5px solid var(--azul-medio);
}
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-xs { padding: 2px 7px; font-size: 11px; }

/* ── Tablas generales ── */
.table-wrap { overflow-x: auto; }
/* Contenedor con scroll propio — thead queda en top:0 dentro del scroll */
.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 160px);
}
table.data-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
table.data-table th {
  background: var(--azul); color: #fff;
  padding: 8px 10px; text-align: left; white-space: nowrap;
  position: sticky; top: 0; z-index: 5;
}
table.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
table.data-table tr:hover td { background: #f0f4fb; }
table.data-table tr.tope td { background: #fde8e8; }

/* ── COLISIONADOR ── */
.col-scroll {
  overflow: auto;
  max-height: calc(100vh - 120px);
  border-radius: 6px;
}
.col-table { border-collapse: collapse; font-size: 11px; min-width: 900px; }
.col-table th, .col-table td {
  border: 1px solid #c4ccd8; padding: 4px 6px;
  text-align: center; white-space: nowrap;
}
.col-table thead th {
  background: var(--azul); color: #fff;
  position: sticky; top: 0; z-index: 4;
}
.col-table td.dia-cel {
  background: #0d2f5e; color: #fff; font-weight: 700;
  font-size: 10px; letter-spacing: .8px;
  writing-mode: vertical-rl; transform: rotate(180deg);
  padding: 6px 3px; min-width: 28px;
}
.col-table td.bloque-num {
  background: #dce4f0; font-weight: 700; color: #1a3a6c; font-size: 11px;
  min-width: 26px;
}
.col-table td.hora-cell {
  background: #edf0f5; font-size: 10px; color: #4a5568;
  min-width: 80px;
}
.col-table td.tope {
  background: #fde8e8 !important; color: var(--rojo);
  font-weight: 700; border: 2px solid var(--rojo) !important;
}
.col-table td.almuerzo { background: #d4edda; color: #155724; font-style: italic; }
.col-table td.no-lectiva { background: #fef9e7; color: #7d6608; }
.col-table td.vacio { background: #f2f4f7; color: #ccc; }
.col-table td.filled { background: #fff; }

/* ── Paleta de asignaturas (una clase = un color único) ── */
/* Asignaturas generales */
.asig-lenguaje    { background: #fde0e0 !important; }   /* rojo claro */
.asig-matematica  { background: #d6eaff !important; }   /* azul */
.asig-historia    { background: #fff2b0 !important; }   /* amarillo */
.asig-ingles      { background: #f7c8c8 !important; }   /* rosa-rojo */
.asig-orientacion { background: #e2e5ea !important; }   /* gris neutro */
.asig-ciencias    { background: #c8f0dc !important; }   /* verde */
.asig-biologia    { background: #b8f0e0 !important; }   /* verde-teal */
.asig-quimica     { background: #c8f8d0 !important; }   /* verde lima */
.asig-fisica      { background: #c8eef8 !important; }   /* celeste */
.asig-ef          { background: #ffdec0 !important; }   /* naranja */
.asig-artes       { background: #ead8ff !important; }   /* violeta */
.asig-musica      { background: #fcd8f0 !important; }   /* magenta */
.asig-danza       { background: #ffc8e0 !important; }   /* rosado */
.asig-religion    { background: #ececec !important; }   /* gris claro */
.asig-filosofia   { background: #d8d0f8 !important; }   /* índigo */
.asig-tecnologia  { background: #d0dff8 !important; }   /* azul acero */
.asig-pie         { background: #e0d0f8 !important; }   /* lavanda */
.asig-prebas      { background: #e8f8c8 !important; }   /* verde amarillo (NT/preescolar) */
/* TP Administración (tonos azul-gris, cada uno distinto) */
.asig-tp-proc-adm { background: #ccdaf5 !important; }   /* azul pizarra */
.asig-tp-gest     { background: #c8d0f8 !important; }   /* azul-violeta */
.asig-tp-cont     { background: #c0e0f8 !important; }   /* azul cielo */
.asig-tp-aten     { background: #d8ccf8 !important; }   /* lavanda azul */
.asig-tp-csp      { background: #d0e8f8 !important; }   /* celeste grisáceo */
/* TP Enfermería (tonos verde-agua, cada uno distinto) */
.asig-tp-hig      { background: #b8f0e8 !important; }   /* menta */
.asig-tp-ana      { background: #b8e8e0 !important; }   /* verde agua */
.asig-tp-far      { background: #c8f8ee !important; }   /* turquesa */
.asig-tp-enf-gen  { background: #d0ffe8 !important; }   /* verde claro */
.asig-otro        { background: #f5f5f5 !important; }

/* ── Horario curso (GBás/GMed) ── */
.horario-curso { border-collapse: collapse; font-size: 12px; width: 100%; }
.horario-curso th, .horario-curso td {
  border: 1px solid #bbb; padding: 6px 8px; text-align: center; vertical-align: middle;
}
.horario-curso thead th { background: var(--azul); color: #fff; }
.horario-curso .bloque-info { font-size: 10px; color: #555; background: #f0f3f7; }
.horario-curso .recreo-row td { background: #fff9c4; color: #7d6608; font-weight: 600; text-align: center; }
.horario-curso .almuerzo-row td { background: #d4edda; color: #155724; font-weight: 600; text-align: center; }
.horario-curso .docente-cell { font-weight: 600; color: var(--azul); font-size: 11px; }
.horario-curso .asig-cell   { color: #555; font-size: 11px; }

/* ── Horario docente FULL ── */
.full-table { border-collapse: collapse; font-size: 12px; width: 100%; }
.full-table th, .full-table td { border: 1px solid #bbb; padding: 6px 8px; text-align: center; }
.full-table thead th { background: var(--azul); color: #fff; }
.full-table .lectivo { background: #e3f0ff; }
.full-table .no-lect { background: #fef9e7; }
.full-table .almuerzo { background: #d4edda; }
.full-table .tope     { background: var(--rojo-claro); color: var(--rojo); font-weight: 700; }

/* ── Cobertura ── */
.disponible { background: var(--verde-claro); color: var(--verde); font-weight: 600; }
.no-disponible { background: var(--rojo-claro); color: var(--rojo); }

/* ── Resumen docente ── */
.resumen-table th { white-space: nowrap; font-size: 11px; }
.resumen-table td { font-size: 12px; }
.resumen-table .exceso { color: var(--rojo); font-weight: 700; }
.resumen-table .ok     { color: var(--verde); }

/* ── Formularios ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; color: #444; margin-bottom: 5px; font-size: 12.5px; }
.form-control {
  width: 100%; padding: 8px 11px; border: 1.5px solid #ccc; border-radius: 5px;
  font-size: 13px; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--azul-claro); }
.form-row { display: grid; gap: 14px; }
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.col-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ── Alertas ── */
.alert { padding: 10px 16px; border-radius: 5px; margin-bottom: 14px; font-size: 13px; }
.alert-success { background: var(--verde-claro); color: #155724; border-left: 4px solid var(--verde); }
.alert-danger  { background: var(--rojo-claro); color: #721c24; border-left: 4px solid var(--rojo); }
.alert-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--naranja); }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 2000; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
  width: 90%; max-width: 540px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  background: var(--azul); color: #fff; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 10px 10px 0 0;
}
.modal-header h3 { font-size: 15px; }
.modal-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--borde); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Dashboard stats ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border-radius: 8px; padding: 16px;
  box-shadow: var(--sombra); text-align: center;
  border-top: 4px solid var(--azul-medio);
}
.stat-card.rojo  { border-top-color: var(--rojo); }
.stat-card.verde { border-top-color: var(--verde); }
.stat-card.teal  { border-top-color: var(--teal); }
.stat-num { font-size: 32px; font-weight: 800; color: var(--azul); }
.stat-num.rojo  { color: var(--rojo); }
.stat-num.verde { color: var(--verde); }
.stat-label { font-size: 11.5px; color: #666; margin-top: 4px; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 10.5px; font-weight: 700;
}
.badge-rojo  { background: var(--rojo-claro); color: var(--rojo); }
.badge-verde { background: var(--verde-claro); color: var(--verde); }
.badge-azul  { background: #d0e4ff; color: var(--azul-medio); }
.badge-gris  { background: #e9ecef; color: #495057; }

/* ── Suple grid ── */
.suple-scroll {
  overflow: auto;
  max-height: calc(100vh - 120px);
  border-radius: 6px;
}
.suple-table { border-collapse: collapse; font-size: 11.5px; min-width: 1200px; }
.suple-table th, .suple-table td {
  border: 1px solid #c4ccd8; padding: 4px 6px; text-align: center; min-width: 80px;
}
.suple-table thead th {
  background: var(--azul); color: #fff;
  position: sticky; top: 0; z-index: 4;
}
.suple-table th.docente-col { background: #2457a0; }
.suple-table td.dia-label {
  background: #0d2f5e; color: #fff; font-weight: 700;
  writing-mode: vertical-rl; transform: rotate(180deg);
  min-width: 28px; padding: 6px 3px;
}
.suple-table td.bloque-info {
  background: #edf0f5; font-size: 10px; text-align: left;
  white-space: nowrap; color: #4a5568;
}
.suple-table td.bloque-num {
  background: #dce4f0; font-weight: 700; color: #1a3a6c;
  font-size: 11px; min-width: 28px;
}
.suple-table td.nl-cell { background: #fef9e7; cursor: pointer; }
.suple-table td.nl-cell:hover { background: #fdefc0; }
.suple-table td.almuerzo-cell { background: #d4edda; color: #155724; font-size: 10px; }
.suple-table td.vacio-cell { background: #f2f4f7; }

/* ── Drag & Drop editor ── */
tr.drag-over td { background: #e8f0fe !important; border-top: 2px solid var(--azul-claro) !important; }
.drag-handle:hover { color: var(--azul) !important; }
tr[draggable="true"]:active { cursor: grabbing; }

/* ── Print ── */
@media print {
  .navbar, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
  /* Horario x Curso: forzar una sola hoja apaisada */
  .horario-print-page {
    width: 100%;
    page-break-inside: avoid;
  }
  @page { size: A4 landscape; margin: 8mm 10mm; }
  .horario-curso {
    font-size: 8.5px !important;
    width: 100% !important;
  }
  .horario-curso th, .horario-curso td {
    padding: 3px 4px !important;
  }
  .card-body { padding: 4px !important; }
  /* Forzar impresión de colores de fondo */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar-menu { display: none; }
  .form-row.col-3, .form-row.col-4 { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
