/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Sidebar nav item — APM orange when active */
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.875rem; border-radius: 0.75rem;
  color: #94a3b8; font-size: 0.875rem; font-weight: 500;
  transition: all 0.15s ease; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(255,109,42,0.18), rgba(66,176,213,0.10));
  color: #FF6D2A; font-weight: 600;
  border-left: 3px solid #FF6D2A; padding-left: calc(0.875rem - 3px);
}
.nav-item.active svg { stroke-width: 2.5; }

/* Status badge */
.badge {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.25rem 0.75rem; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.025em;
}
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-reviewing { background: #d1eef9; color: #155870; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-expired { background: #f1f5f9; color: #64748b; }

/* Priority badge */
.priority-high { border-left: 4px solid #FF6D2A; }
.priority-medium { border-left: 4px solid #f59e0b; }
.priority-low { border-left: 4px solid #42B0D5; }

/* Stat card hover */
.stat-card { transition: all 0.2s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }
/* Repintar la misma página (datos nuevos, un guardado) no es navegar: sin
   animación de entrada, para que no se note el cambio (tg-02, navigateTo). */
.tg-repinte .fade-in, .tg-repinte .worker-card { animation: none !important; opacity: 1; transform: none; }
@keyframes workerIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.worker-card { animation: workerIn 0.25s ease forwards; }
@keyframes pulse-badge { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }
.pulse-badge { animation: pulse-badge 2s ease-in-out infinite; }
@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }
.toast-enter { animation: toastIn 0.3s ease forwards; }
.toast-exit { animation: toastOut 0.3s ease forwards; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-enter { animation: modalIn 0.25s ease forwards; }

.table-row:hover { background-color: #f8fafc; }

/* Timeline */
.timeline-item::before {
  content: ''; position: absolute; left: 15px; top: 32px; bottom: -16px;
  width: 2px; background: #e2e8f0;
}
.timeline-item:last-child::before { display: none; }

/* Form section */
.form-section {
  border: 1px solid #e2e8f0; border-radius: 1rem;
  padding: 1.5rem; margin-bottom: 1.5rem; background: white;
}
.form-section-title {
  font-size: 1rem; font-weight: 600; color: #1e293b;
  margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 0.5rem;
}

/* Input focus — APM orange ring */
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 109, 42, 0.25);
  border-color: #FF6D2A;
}

/* Responsive table */
.responsive-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ========================================
   PAGINATION
   ======================================== */
.pagination-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.625rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover:not(.page-btn-disabled):not(.page-btn-active) {
  background: #f0f9ff;
  border-color: #42B0D5;
  color: #0e7490;
}
.page-btn-active {
  background: linear-gradient(135deg, #42B0D5 0%, #0e7490 100%);
  border-color: #0e7490;
  color: white;
  cursor: default;
}
.page-btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 2.25rem;
  color: #94a3b8;
  font-weight: 700;
}
.pagination-info {
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
}

/* ========================================
   APP FOOTER - Marca de agua (no fija, parte del scroll)
   ======================================== */
.app-footer-watermark {
  margin-top: 1.5rem;
  background: transparent;
  border-top: 1px dashed rgba(148, 163, 184, 0.25);
  user-select: none;
  pointer-events: auto;
}
.app-footer-watermark p {
  letter-spacing: 0.02em;
}
.app-footer-watermark a {
  text-decoration: none;
  transition: color 0.2s;
}

/* Print */
@media print { #sidebar, header, .no-print { display: none !important; } main { padding: 0 !important; } }

/* Select dropdown background fix */
select option { background: white; color: #1e293b; }

/* Stepper — uses APM blue */
.step-line { flex: 1; height: 2px; background: #e2e8f0; margin: 0 0.5rem; }
.step-line.completed { background: #42B0D5; }
.step-line.active { background: linear-gradient(90deg, #42B0D5 50%, #e2e8f0 50%); }

/* Document approve/reject buttons */
.doc-action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 0.5rem;
  transition: all 0.15s ease; cursor: pointer; border: none; flex-shrink: 0;
}
.doc-action-approve { background: #d1fae5; color: #059669; }
.doc-action-approve:hover { background: #059669; color: white; }
.doc-action-reject { background: #fee2e2; color: #dc2626; }
.doc-action-reject:hover { background: #dc2626; color: white; }

/* Worker card */
.worker-card-container {
  border: 1px solid #e2e8f0; border-radius: 0.875rem;
  background: white; overflow: hidden;
}
.worker-card-header {
  background: linear-gradient(to right, #fff3ed, #e8f7fc);
  padding: 0.75rem 1rem; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
}

/* Company docs item */
.company-doc-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.75rem; background: white;
  border: 1px solid #e2e8f0; border-radius: 0.625rem;
  animation: fadeIn 0.2s ease forwards;
}

/* Empty worker state */
.worker-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem; border: 2px dashed #e2e8f0; border-radius: 0.875rem;
  color: #94a3b8; text-align: center; cursor: pointer;
  transition: all 0.2s ease;
}
.worker-empty-state:hover {
  border-color: #FF6D2A; color: #FF6D2A; background: #fff3ed;
}

/* Specific document upload boxes */
.special-doc-box {
  border: 2px dashed #ffc9a3; background: #fff3ed;
  border-radius: 0.75rem; padding: 0.875rem;
  transition: all 0.2s ease;
}
.special-doc-box:hover { border-color: #FF6D2A; background: #ffe4d1; }

.special-doc-box.blue {
  border-color: #a3ddf3; background: #e8f7fc;
}
.special-doc-box.blue:hover { border-color: #42B0D5; background: #d1eef9; }

/* Rejected request alert in inbox */
.rejected-alert {
  background: linear-gradient(135deg, #fee2e2 0%, #fff3ed 100%);
  border: 1px solid #fca5a5; border-radius: 1rem;
  padding: 1.25rem;
}

/* Access control card (visualizador) */
.access-company-card {
  background: white; border: 1px solid #e2e8f0;
  border-radius: 0.875rem; overflow: hidden;
  transition: all 0.2s ease;
}
.access-company-card:hover {
  border-color: #42B0D5;
  box-shadow: 0 4px 12px -2px rgba(66,176,213,0.15);
}

.worker-access-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9;
}
.worker-access-row:last-child { border-bottom: none; }
.worker-access-row.authorized { background: #f0fdf4; }
.worker-access-row.unauthorized { background: #fef2f2; }
.worker-access-row.pending { background: #fefce8; }

/* Buttons with APM colors */
.btn-accent {
  background-color: #FF6D2A; color: white;
  padding: 0.5rem 1rem; border-radius: 0.5rem;
  font-weight: 500; font-size: 0.875rem;
  transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: none; cursor: pointer;
}
.btn-accent:hover { background-color: #e55a1a; }
.btn-brand {
  background-color: #42B0D5; color: white;
  padding: 0.5rem 1rem; border-radius: 0.5rem;
  font-weight: 500; font-size: 0.875rem;
  transition: all 0.15s ease;
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: none; cursor: pointer;
}
.btn-brand:hover { background-color: #2a9cbd; }

/* Force password change modal */
.force-pw-modal { backdrop-filter: blur(8px); }

/* ========================================
   Independent scrolling: sidebar + main content
   ======================================== */
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

/* Login screen: scroll independiente */
#loginScreen {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

#appContainer {
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

/* Right column wrapping topbar + main content */
#appContainer > div.flex-1,
#appContainer > main.flex-1 {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Topbar stays fixed at the top */
#appContainer > div.flex-1 > header,
#appContainer > div.flex-1 > .topbar,
#appContainer > main.flex-1 > header {
  flex-shrink: 0;
}

/* Main content scrolls independently */
#mainContent {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;              /* móvil: scroll horizontal si el contenido es más ancho */
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbars (subtle) */
#sidebar::-webkit-scrollbar,
#mainContent::-webkit-scrollbar { width: 8px; }
#sidebar::-webkit-scrollbar-thumb,
#mainContent::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.3); border-radius: 4px; }
#sidebar::-webkit-scrollbar-thumb:hover,
#mainContent::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.5); }
#sidebar::-webkit-scrollbar-track,
#mainContent::-webkit-scrollbar-track { background: transparent; }


/* ========================================
   MÓVIL / PWA — la app se acomoda a la pantalla
   y permite scroll en ambas direcciones
   ======================================== */
@media (max-width: 768px) {
  /* Tablas: siempre desplazables al ancho que necesiten */
  .responsive-table { overflow-x: auto; }
  .responsive-table table { min-width: 640px; }

  /* Contenido principal sin desbordes invisibles */
  #mainContent > div { min-width: 0; }
  #mainContent .grid { min-width: 0; }

  /* Formularios y cards a todo el ancho disponible */
  .form-section { padding: 1rem; }

  /* Modales: que nunca excedan la pantalla */
  .modal-enter, [class*="max-w-"] { max-width: calc(100vw - 1.5rem) !important; }

  /* Botones de acción que se envuelven en vez de desbordar */
  .flex.gap-2.flex-wrap { row-gap: 0.5rem; }

  /* Texto base un poco más compacto */
  body { font-size: 15px; }
}

/* Pantallas muy pequeñas (handhelds) */
@media (max-width: 420px) {
  #mainContent { padding-left: 0; padding-right: 0; }
  .p-4.md\:p-6 { padding: 0.75rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Utilidades que faltan en tailwind.css
   ═══════════════════════════════════════════════════════════════════════
   tailwind.css es un archivo COMPILADO UNA VEZ y confirmado: no hay paso de
   compilación en package.json, así que no se regenera al escribir una clase
   nueva. Una clase que no esté ya dentro no hace nada, y el navegador no
   avisa.

   Costó una pantalla rota para darse cuenta: una cabecera escrita con
   `sm:flex-row sm:items-start sm:w-auto` se veía bien en un teléfono —esas
   clases móviles sí existían— y en un escritorio el botón se quedaba en
   w-full estirado a lo alto, ocupando la cabecera entera.

   Aquí van las que el código usa y la hoja compilada no trae. La regla 12 de
   scripts/check-repo.mjs comprueba que no vuelva a usarse ninguna que no esté
   definida ni aquí ni allí.

   El breakpoint sm de este proyecto es 640px, igual que en tailwind.css.
   ═══════════════════════════════════════════════════════════════════════ */

/* — Tamaños y espaciado — */
.w-20  { width: 5rem; }
.h-20  { height: 5rem; }
.w-4\.5 { width: 1.125rem; }
.h-4\.5 { height: 1.125rem; }
.px-3\.5 { padding-left: 0.875rem; padding-right: 0.875rem; }
.max-h-\[45vh\] { max-height: 45vh; }
.max-h-\[50vh\] { max-height: 50vh; }

/* — Texto — */
.whitespace-nowrap { white-space: nowrap; }
.tracking-widest   { letter-spacing: 0.1em; }
.text-slate-200    { --tw-text-opacity: 1; color: rgb(226 232 240 / var(--tw-text-opacity, 1)); }

/* — Color con transparencia — */
.bg-accent-500\/15 { background-color: rgb(255 109 42 / 0.15); }
.bg-amber-100\/50  { background-color: rgb(254 243 199 / 0.5); }

/* — Degradados en púrpura (la revisión documental) — */
.from-purple-600 { --tw-gradient-from: #9333ea var(--tw-gradient-from-position);
                   --tw-gradient-to: rgb(147 51 234 / 0) var(--tw-gradient-to-position);
                   --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to); }
.to-purple-700   { --tw-gradient-to: #7e22ce var(--tw-gradient-to-position); }
.accent-purple-600 { accent-color: #9333ea; }

/* — Estados — */
.hover\:text-accent-700:hover { --tw-text-opacity: 1; color: rgb(192 71 18 / var(--tw-text-opacity, 1)); }
.hover\:text-amber-900:hover  { --tw-text-opacity: 1; color: rgb(120 53 15 / var(--tw-text-opacity, 1)); }
.hover\:text-purple-900:hover { --tw-text-opacity: 1; color: rgb(88 28 135 / var(--tw-text-opacity, 1)); }
.focus\:border-accent-400:focus { --tw-border-opacity: 1; border-color: rgb(255 138 71 / var(--tw-border-opacity, 1)); }

/* — Otros — */
.divide-amber-200 > :not([hidden]) ~ :not([hidden]) {
  --tw-divide-opacity: 1; border-color: rgb(253 230 138 / var(--tw-divide-opacity, 1));
}
.duration-700 { transition-duration: 700ms; }
.transition-colors {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* El borde morado al pasar por encima, para la tarjeta de Revisión
   Documental en Nueva Solicitud. tailwind.css está congelado y trae
   border-purple-300 pero no la variante :hover de la 400. */
.hover\:border-purple-400:hover { border-color: #a78bfa; }

/* La barra lateral, escondida a propósito en pantalla grande. En móvil no
   hace falta: ahí ya se esconde sola y se abre como cajón. */
@media (min-width: 1024px) {
  #sidebar.tg-barra-oculta { display: none; }
}

/* La última fila de un listado no lleva raya: la raya separa filas, y debajo
   de la última no hay nada que separar. La usan los listados de
   vencimientos (tg-30). No está en el tailwind.css congelado. */
.last\:border-0:last-child { border-width: 0; }

/* — Variantes responsivas (sm = 640px, lg = 1024px) — */
@media (min-width: 640px) {
  .sm\:w-auto         { width: auto; }
  .sm\:w-6            { width: 1.5rem; }
  .sm\:w-12           { width: 3rem; }
  .sm\:h-6            { height: 1.5rem; }
  .sm\:h-12           { height: 3rem; }
  .sm\:p-5            { padding: 1.25rem; }
  .sm\:gap-3          { gap: 0.75rem; }
  .sm\:text-lg        { font-size: 1.125rem; line-height: 1.75rem; }
  .sm\:text-xl        { font-size: 1.25rem; line-height: 1.75rem; }
  .sm\:items-start    { align-items: flex-start; }
  .sm\:justify-between{ justify-content: space-between; }
  /* Las carpetas de Control de Acceso: en una fila a lo ancho desde 640px,
     apiladas debajo en un teléfono. */
  .sm\:flex-nowrap   { flex-wrap: nowrap; }
}
@media (min-width: 1024px) {
  .lg\:col-span-3 { grid-column: span 3 / span 3; }
}

/* ── Ficha del trabajador (tg-32) ───────────────────────────── */
.ficha-foto { width: 6rem; height: 7rem; }
@media (min-width: 640px) { .ficha-foto { width: 7rem; height: 8rem; } }
.ficha-tab { border-bottom: 2px solid transparent; }
.ficha-tab-activa { border-bottom-color: rgb(255 109 42); color: rgb(229 90 26); }   /* accent-500 / accent-600 */
.ficha-contenido { min-height: 180px; }

/* Vencimientos → documento (tg-30): el documento al que se llega desde
   "Documentos Por vencer" / "Documentos Vencidos" se resalta un momento. */
.doc-resaltado {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
  border-radius: 0.5rem;
  animation: doc-resaltado 0.9s ease-in-out 3;
}
@keyframes doc-resaltado {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.35); }
}


/* ── Módulos apagados por la terminal (tg-37) ────────────────────────────
   Lo que depende de un módulo lleva data-modulo="clave"; tg-37 pone en
   <html> una clase tg-sin-<clave> por cada módulo apagado. Con esto se
   oculta en cualquier sitio —páginas, ventanas, lo que se repinte— sin
   que cada pantalla tenga que preguntarlo. "solicitudes" y "evaluaciones"
   son combinadas: se apagan cuando lo están sus dos módulos.
   Es solo la pantalla: lo que protege está en la base (sql/85, sql/86). */
html.tg-sin-dashboard [data-modulo="dashboard"],
html.tg-sin-contractors [data-modulo="contractors"],
html.tg-sin-workers [data-modulo="workers"],
html.tg-sin-requests [data-modulo="requests"],
html.tg-sin-documents [data-modulo="documents"],
html.tg-sin-document_review [data-modulo="document_review"],
html.tg-sin-medical [data-modulo="medical"],
html.tg-sin-induction [data-modulo="induction"],
html.tg-sin-trainings [data-modulo="trainings"],
html.tg-sin-access_control [data-modulo="access_control"],
html.tg-sin-qr [data-modulo="qr"],
html.tg-sin-reports [data-modulo="reports"],
html.tg-sin-audit [data-modulo="audit"],
html.tg-sin-solicitudes [data-modulo="solicitudes"],
html.tg-sin-evaluaciones [data-modulo="evaluaciones"] {
  display: none !important;
}

/* Panel de configuración (tg-38): las flechas de subir/bajar en el extremo
   de la lista quedan apagadas. */
.pc-flecha:disabled { opacity: .3; cursor: default; }

/* Fase 10 (tg-39): un campo que la terminal desactivó, o el asterisco de uno
   que no es obligatorio. Clase propia y no "hidden": algunos contenedores ya
   usan hidden para otra cosa (el contacto se ve al elegir el tipo). */
.tg-campo-oculto { display: none !important; }

/* Evaluaciones del Personal con el filtro de departamento (personal propio):
   una columna más en el filtro. tailwind.css está congelado y no la trae. */
@media (min-width: 768px) {
  .md\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
