/* Escolar JEP — mejoras de operación e impresión (2026-08-25). */

.jep-search-toolbar,
.jep-program-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line, #dfe5e1);
  background: #f8faf9;
}

.jep-search-toolbar label {
  display: grid;
  gap: 6px;
  min-width: 180px;
  color: #4f5a53;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.jep-search-toolbar label.jep-search-text {
  flex: 1 1 280px;
}

.jep-search-toolbar select,
.jep-search-toolbar input {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #cbd6ce;
  border-radius: 9px;
  background: #fff;
  color: #111713;
  font: 600 12px Arial, sans-serif;
  text-transform: none;
}

.jep-search-toolbar input:focus,
.jep-search-toolbar select:focus {
  border-color: var(--green, #149647);
  outline: 3px solid rgb(20 150 71 / 14%);
}

.jep-search-help,
.jep-empty-state {
  color: #69736c;
  font-size: 10px;
}

.jep-empty-state {
  margin: 0;
  padding: 28px 20px;
  text-align: center;
  background: #fff;
  font-weight: 800;
}

.jep-hidden-original-search,
.jep-row-hidden,
.jep-card-hidden,
.jep-table-waiting {
  display: none !important;
}

.jep-program-toolbar {
  align-items: center;
  margin-bottom: 16px;
  border: 1px solid var(--line, #dfe5e1);
  border-radius: 12px;
}

.jep-program-toolbar > strong {
  margin-right: 4px;
  color: #526058;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.jep-program-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid #cbd6ce;
  border-radius: 999px;
  background: #fff;
  color: #175d31;
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
}

.jep-program-button span {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e7f6eb;
  color: #087634;
  font-size: 9px;
}

.jep-program-button[aria-expanded="true"] {
  border-color: #149647;
  background: #0f1913;
  color: #fff;
}

.jep-program-button[aria-expanded="true"] span {
  background: #43c86e;
  color: #07140c;
}

.jep-busy-button {
  cursor: wait !important;
  opacity: .72 !important;
  pointer-events: none !important;
}

.jep-busy-button::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: jep-spin .7s linear infinite;
}

@keyframes jep-spin {
  to { transform: rotate(360deg); }
}

.jep-operation-toast {
  position: fixed;
  z-index: 100000;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 13px 17px;
  border: 1px solid #b9dfc4;
  border-left: 5px solid #159b48;
  border-radius: 10px;
  background: #eef9f1;
  color: #075f2a;
  box-shadow: 0 12px 38px rgb(14 31 20 / 20%);
  font: 800 11px/1.45 Arial, sans-serif;
}

.jep-operation-toast.is-error {
  border-color: #efc1c1;
  border-left-color: #b52828;
  background: #fff1f1;
  color: #8f1c1c;
}

/* Mejor lectura de calendarios fechados sin alterar su orientación. */
.scheduled-program-page .program-level-title small { font-size: 8px; font-weight: 950; }
.scheduled-program-page .program-level-title h2 { font-size: 25px; font-weight: 900; }
.scheduled-program-page .program-level-title p { font-size: 10px; font-weight: 700; }
.scheduled-program-table th { font-size: 8px; font-weight: 950; }
.scheduled-program-table td { font-size: 8.3px; font-weight: 600; line-height: 1.42; }
.scheduled-program-table td b { font-weight: 950; }
.scheduled-program-table td small { font-size: 7px; font-weight: 650; }

/* Ficha de registro: mismas medidas y orientación, tipografía un poco mayor. */
.ficha-page .ficha-field b { font-size: 8.7px; }
.ficha-page .ficha-field span { font-size: 9.8px; }
.ficha-page .ficha-docs span { font-size: 9.6px; }
.ficha-page .period-grid span { font-size: 8.6px; }
.ficha-page .privacy p { font-size: 10.6px; line-height: 1.62; }

/* Vista previa: conserva las proporciones originales para que nada se mueva. */
.credential-body {
  grid-template-columns: 130px minmax(0, 1fr) !important;
}
.photo-space {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  align-self: center;
  justify-self: center;
}

/* La vista previa también conserva frente y reverso juntos. */
.credential-modal {
  width: min(980px, calc(100vw - 28px)) !important;
}
.credential-modal .credential-sheets {
  display: grid !important;
  grid-template-columns: 516px 516px !important;
  grid-template-rows: 324px !important;
  justify-content: center !important;
  align-items: start !important;
  gap: 1mm !important;
  overflow-x: auto !important;
}
.credential-modal .credential-print {
  width: 516px !important;
  min-width: 516px !important;
  height: 324px !important;
  min-height: 324px !important;
  border-radius: 0 !important;
  overflow: hidden !important;
}
.credential-modal .credential-brand,
.credential-modal .credential-footer,
.credential-modal .back-footer {
  border-radius: 0 !important;
}

/* El calendario puede ocupar todas las hojas que necesite. */
.scheduled-program-page {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}
.scheduled-program-page + .scheduled-program-page {
  break-before: page !important;
  page-break-before: always !important;
}
.scheduled-program-table thead {
  display: table-header-group !important;
}
.scheduled-program-table tr {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

@media print {
  /* Asistencia: carta horizontal y escala física 100 %. */
  .attendance-modal {
    width: 279.4mm !important;
    max-width: 279.4mm !important;
  }
  .attendance-modal .document-scroll,
  .attendance-pages {
    width: 279.4mm !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .attendance-pages .attendance-sheet,
  .attendance-sheet {
    page: jep-attendance !important;
    box-sizing: border-box !important;
    width: 279.4mm !important;
    min-width: 279.4mm !important;
    max-width: 279.4mm !important;
    height: 215.9mm !important;
    min-height: 215.9mm !important;
    max-height: 215.9mm !important;
    margin: 0 !important;
    padding: 8.5mm !important;
    overflow: hidden !important;
    transform: none !important;
    zoom: 1 !important;
  }
  .attendance-sheet header b { font-size: 15px !important; font-weight: 950 !important; }
  .attendance-sheet header span { font-size: 9px !important; font-weight: 950 !important; }
  .attendance-info { font-size: 10px !important; font-weight: 750 !important; }
  .attendance-sheet th,
  .attendance-sheet td { font-size: 7.5px !important; font-weight: 700 !important; }
  .attendance-sheet td:nth-child(3) { font-size: 8.5px !important; font-weight: 800 !important; }
  .attendance-topics { font-size: 5.8pt !important; font-weight: 650 !important; }

  /* Programa con fechas: se mantiene carta horizontal con texto más legible. */
  .program-document-page.scheduled-program-page {
    page: jep-scheduled-program !important;
    width: 279.4mm !important;
    min-width: 279.4mm !important;
    max-width: 279.4mm !important;
    height: auto !important;
    min-height: 196.9mm !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 9.5mm 11.5mm !important;
    transform: none !important;
    zoom: 1 !important;
    overflow: visible !important;
    break-after: page !important;
    page-break-after: always !important;
  }
  .program-document-page.scheduled-program-page:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  /* Frente y reverso juntos, alineados y separados 1 mm para el doblez. */
  .credential-modal {
    page: jep-credential !important;
    width: 279.4mm !important;
    height: 215.9mm !important;
  }
  .credential-modal .credential-sheets {
    box-sizing: border-box !important;
    grid-template-columns: 85.6mm 85.6mm !important;
    grid-template-rows: 53.98mm !important;
    place-content: center !important;
    align-items: stretch !important;
    gap: 1mm !important;
    width: 279.4mm !important;
    height: 215.9mm !important;
    min-height: 215.9mm !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .credential-modal .credential-print {
    width: 85.6mm !important;
    min-width: 85.6mm !important;
    max-width: 85.6mm !important;
    height: 53.98mm !important;
    min-height: 53.98mm !important;
    max-height: 53.98mm !important;
    margin: 0 !important;
    transform: none !important;
    border-radius: 0 !important;
  }
  .credential-modal .credential-body {
    grid-template-columns: 25mm minmax(0, 1fr) !important;
    gap: 2.2mm !important;
  }
  .credential-modal .photo-space {
    width: 25mm !important;
    height: 30mm !important;
  }
}

@page jep-attendance { size: letter landscape; margin: 0; }
@page jep-scheduled-program { size: letter landscape; margin: 0; }
@page jep-credential { size: letter landscape; margin: 0; }

@media (max-width: 760px) {
  .jep-search-toolbar { align-items: stretch; }
  .jep-search-toolbar label { min-width: 100%; }
  .jep-program-toolbar { align-items: stretch; }
  .jep-program-button { justify-content: space-between; width: 100%; }
  .credential-modal {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
  }
  .credential-modal .credential-sheets {
    max-width: 100% !important;
    justify-content: start !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
}
