/* Custom styles for Chronos School AI */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tab-btn.active,
aside .tab-btn.active {
  background-color: #4f46e5 !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.35);
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.cell-available {
  background-color: #d1fae5;
  color: #065f46;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}
.cell-available:hover {
  background-color: #a7f3d0;
}

.cell-blocked {
  background-color: #fee2e2;
  color: #991b1b;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}
.cell-blocked:hover {
  background-color: #fecaca;
}

.cell-slot {
  min-height: 48px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.cell-slot:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ================= PRINT STYLES (EXACT FIT 1 HOJA CARTA HORIZONTAL) ================= */
@page {
  size: letter landscape;
  margin: 3mm 5mm 2mm 5mm;
}

@media print {
  /* Ocultar elementos de navegación, modales y barras de herramientas */
  header, nav, #floating-scroll-controls, .modal, #tab-dashboard, #tab-teachers, #tab-subjects, #tab-rooms, #tab-curriculum, #tab-config,
  #viewer-top-toolbar, #editor-action-bar, #editor-legend-bar, #contingency-active-banner, #viewer-contingency-mini-card,
  .print-hidden, [class*="print:hidden"] {
    display: none !important;
  }

  /* Ocultar barra superior del visor de horarios */
  .bg-white.p-4.rounded-2xl.border.border-slate-200.shadow-sm.flex.flex-wrap {
    display: none !important;
  }

  html, body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #tab-viewer {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* Contenedor principal de la tabla */
  #tab-viewer .bg-white.rounded-2xl {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Encabezado del Horario Institucional - Compacto y elegante */
  #viewer-print-header {
    display: block !important;
    margin-bottom: 2px !important;
    padding-bottom: 2px !important;
    border-bottom: 1.5px solid #000 !important;
  }

  #viewer-print-header > div {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  #viewer-header-logo-container {
    display: flex !important;
    width: 50px !important;
    height: 38px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #viewer-header-logo {
    max-height: 36px !important;
    max-width: 50px !important;
    object-fit: contain !important;
    display: block !important;
  }

  #viewer-header-logo.hidden {
    display: none !important;
  }

  #viewer-header-logo-placeholder {
    display: none !important;
  }

  #viewer-inst-title {
    font-size: 13px !important;
    font-weight: 900 !important;
    font-family: Georgia, serif !important;
    color: #000000 !important;
    margin: 0 !important;
    line-height: 1.1 !important;
  }

  #viewer-target-title {
    font-size: 12.5px !important;
    font-weight: 900 !important;
    color: #000000 !important;
    margin: 0.5px 0 !important;
    line-height: 1.05 !important;
    letter-spacing: -0.2px !important;
  }

  #viewer-inst-address {
    font-size: 8.5px !important;
    font-weight: 600 !important;
    color: #111111 !important;
    margin: 0 !important;
    line-height: 1.05 !important;
  }

  #viewer-target-subtitle {
    font-size: 7.5px !important;
    font-weight: 500 !important;
    color: #444444 !important;
    margin-top: 0.5px !important;
    line-height: 1 !important;
  }

  #viewer-header-badge-container {
    display: flex !important;
    width: 50px !important;
    text-align: right !important;
  }

  /* Tabla de Horario */
  table.viewer-schedule-table {
    width: 100% !important;
    border-collapse: collapse !important;
    border: 1.5px solid #000000 !important;
    table-layout: fixed !important;
    margin: 0 !important;
  }

  table.viewer-schedule-table thead tr th {
    background-color: #f1f5f9 !important;
    color: #000000 !important;
    font-weight: 900 !important;
    font-size: 10px !important;
    padding: 2px 1px !important;
    border: 1px solid #000000 !important;
    text-align: center !important;
    line-height: 1.1 !important;
  }

  /* Filas de Lección con altura calibrada para caber exactamente en 1 sola hoja */
  table.viewer-schedule-table tbody tr.lesson-row {
    height: 31px !important;
    max-height: 33px !important;
  }

  table.viewer-schedule-table tbody td {
    padding: 1px 1.5px !important;
    border: 1px solid #64748b !important;
    vertical-align: top !important;
  }

  /* Columna de Periodo y Hora */
  td.col-period {
    width: 24px !important;
    background-color: #f8fafc !important;
    font-weight: 900 !important;
    font-size: 10px !important;
    text-align: center !important;
    border-right: 1.5px solid #000 !important;
    padding: 0 !important;
    line-height: 31px !important;
  }

  td.col-time {
    width: 52px !important;
    background-color: #f8fafc !important;
    font-size: 8px !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
    text-align: center !important;
    border-right: 1.5px solid #000 !important;
    padding: 1px !important;
  }

  /* Tarjeta de Asignación en Celda */
  .cell-slot {
    border: none !important;
    box-shadow: none !important;
    background-color: transparent !important;
    padding: 0 1px !important;
    margin: 0 !important;
    min-height: 29px !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  .slot-subject {
    font-size: 10.5px !important;
    font-weight: 900 !important;
    color: #000000 !important;
    line-height: 1.1 !important;
    letter-spacing: -0.15px !important;
  }

  .slot-docente {
    font-size: 9px !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    line-height: 1 !important;
    margin-top: 0.5px !important;
  }

  .slot-room {
    font-size: 8px !important;
    font-weight: 900 !important;
    color: #1e293b !important;
    text-align: right !important;
    line-height: 1 !important;
    margin-top: 0.5px !important;
  }

  /* Celda Dividida para Subgrupos Simultáneos (Hogar / Industriales / Tecnologías) */
  .split-cell-wrapper {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 29px !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .split-sub-block {
    flex: 1 !important;
    padding: 0 1px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  .split-sub-block .slot-subject {
    font-size: 9px !important;
    font-weight: 900 !important;
    line-height: 1.05 !important;
  }

  .split-sub-block .slot-docente {
    font-size: 8px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
  }

  .split-sub-block .slot-room {
    font-size: 7.5px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
  }

  .split-sub-block:first-child {
    border-right: 1px dashed #64748b !important;
  }

  /* Filas de Recreo y Almuerzo */
  tr.break-row {
    height: 9px !important;
    max-height: 10px !important;
    background-color: #e2e8f0 !important;
    border-top: 1px solid #000000 !important;
    border-bottom: 1px solid #000000 !important;
  }

  tr.break-row td {
    padding: 0 2px !important;
    font-size: 7.5px !important;
    font-weight: 800 !important;
    text-align: center !important;
    color: #0f172a !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    line-height: 9px !important;
  }

  tr.lunch-row {
    height: 11px !important;
    max-height: 12px !important;
    background-color: #cbd5e1 !important;
    border-top: 1.5px solid #000000 !important;
    border-bottom: 1.5px solid #000000 !important;
  }

  tr.lunch-row td {
    font-size: 8px !important;
    font-weight: 900 !important;
    line-height: 11px !important;
    padding: 0 2px !important;
  }

  /* Pie de página con fecha de generación - estrictamente fijado en la misma hoja */
  #viewer-print-footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: 1px !important;
    padding-top: 1px !important;
    border-top: 1px solid #94a3b8 !important;
    font-size: 7.5px !important;
    color: #475569 !important;
    page-break-before: avoid !important;
    break-before: avoid !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}

/* ================= AJUSTE MANUAL INTERACTIVO (DRAG & DROP) ================= */
.editor-draggable {
  cursor: grab !important;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.editor-draggable:active {
  cursor: grabbing !important;
}
.editor-draggable:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px -2px rgba(99, 102, 241, 0.25) !important;
}

.editor-dragging {
  opacity: 0.35 !important;
  transform: scale(0.95) !important;
  filter: grayscale(0.5);
}

.editor-selected-card {
  outline: 3px solid #6366f1 !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3) !important;
  animation: pulse-editor-border 1.5s infinite ease-in-out;
}

@keyframes pulse-editor-border {
  0%, 100% { outline-color: #4f46e5; }
  50% { outline-color: #a5b4fc; }
}

/* Casilleros destino según validación */
td.slot-target-valid {
  background-color: #ecfdf5 !important;
  border: 2px dashed #10b981 !important;
  cursor: pointer !important;
  position: relative;
}
td.slot-target-valid:hover {
  background-color: #d1fae5 !important;
  box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.2);
}

td.slot-target-swap {
  background-color: #eff6ff !important;
  border: 2px dashed #3b82f6 !important;
  cursor: pointer !important;
  position: relative;
}
td.slot-target-swap:hover {
  background-color: #dbeafe !important;
  box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.2);
}

td.slot-target-invalid {
  background-color: #fff1f2 !important;
  border: 1.5px dashed #f43f5e !important;
  opacity: 0.7 !important;
  cursor: not-allowed !important;
  position: relative;
}
td.slot-target-invalid:hover {
  background-color: #ffe4e6 !important;
}

td.slot-target-dragover {
  transform: scale(1.02);
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15) !important;
}

/* ==========================================================================
   MARCA DE AGUA ANTI-ABUSO PARA IMPRESIÓN EN MODO DEMOSTRACIÓN
   ========================================================================== */
body.is-demo-mode::after {
  content: "";
  display: none;
}

@media print {
  body.is-demo-mode::after {
    display: block !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) rotate(-28deg) !important;
    transform-origin: center center !important;
    content: "VERSIÓN DE DEMOSTRACIÓN — CHRONOS SCHOOL AI\A NO VÁLIDO PARA USO OFICIAL EN CENTROS EDUCATIVOS" !important;
    white-space: pre-wrap !important;
    text-align: center !important;
    font-size: 26pt !important;
    font-weight: 900 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    color: rgba(220, 38, 38, 0.14) !important;
    -webkit-text-stroke: 1px rgba(220, 38, 38, 0.22) !important;
    text-transform: uppercase !important;
    width: 120% !important;
    line-height: 1.5 !important;
    letter-spacing: 2px !important;
    pointer-events: none !important;
    z-index: 9999999 !important;
  }
}

