/* KRONOS Web — Custom CSS */

/* Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

body { font-family: 'Inter', sans-serif; }

/* ─── Org tree lines ──────────────────────────────────── */
.org-tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.org-tree-list:not(.root) {
  position: relative;
  padding-left: 1.25rem;
}

.org-tree-list:not(.root)::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0.75rem;
  width: 1px;
  background: #e2e8f0;
}

.org-tree-item {
  position: relative;
}

.org-tree-list:not(.root) > .org-tree-item::before {
  content: '';
  position: absolute;
  left: -0.75rem;
  top: 1.1rem;
  width: 0.75rem;
  height: 1px;
  background: #e2e8f0;
}

.org-node {
  position: relative;
}

.org-node.selected {
  background-color: #ebf4ff;
  border-radius: 0.5rem;
}

.toggle-btn i {
  transition: transform 0.2s ease;
}

/* ─── Sidebar ─────────────────────────────────────────── */
aside {
  background: #1a365d;
  transition: transform 0.3s ease;
}

@media (max-width: 1024px) {
  aside {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 30;
    transform: translateX(-100%);
  }
  aside.open {
    transform: translateX(0);
  }
}

/* ─── Chamfered "highlight" cards (bisel) ─────────────────
   Reservado a metricas puntuales destacadas (KPIs de Dashboard, panel
   de detalle y tarjetas del organigrama) — NO usar en tablas, listas,
   formularios ni botones: el bisel significa "esto es un número
   importante", no es un estilo de card genérico. No combinar con
   rounded-*, el borde recto de acá reemplaza el redondeado. */
.kronos-chamfer {
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
}

/* ─── Cards ───────────────────────────────────────────── */
.stat-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.05);
  transition: box-shadow 0.2s ease;
}

.stat-card:hover {
  box-shadow: 0 4px 12px 0 rgba(0,0,0,0.08);
}

/* ─── Status badges ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-high     { background: #fee2e2; color: #991b1b; }
.badge-medium   { background: #fef9c3; color: #854d0e; }
.badge-low      { background: #dcfce7; color: #166534; }

/* ─── File type icons ─────────────────────────────────── */
.file-icon-pdf   { color: #ef4444; }
.file-icon-png   { color: #3b82f6; }
.file-icon-md    { color: #22c55e; }
.file-icon-other { color: #9ca3af; }

/* ─── Upload drag zone ────────────────────────────────── */
.upload-zone {
  border: 2px dashed #d1d5db;
  border-radius: 0.75rem;
  padding: 2rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.upload-zone.dragover {
  border-color: #2b6cb0;
  background: #eff6ff;
}

/* ─── Prose (markdown) ────────────────────────────────── */
.prose h1, .prose h2, .prose h3 { color: #1a365d; }
.prose a { color: #2b6cb0; }
.prose code { font-size: 0.85em; background: #f1f5f9; padding: 0.1em 0.3em; border-radius: 3px; }
.prose pre { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 0.5rem; overflow-x: auto; }
.prose blockquote { border-left: 3px solid #ed8936; padding-left: 1rem; color: #64748b; }
.prose table { width: 100%; border-collapse: collapse; }
.prose th, .prose td { border: 1px solid #e2e8f0; padding: 0.5rem 0.75rem; text-align: left; }
.prose th { background: #f8fafc; font-weight: 600; }

/* ─── Animations ──────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-alert { animation: fadeIn 0.3s ease; }

.children-container { animation: fadeIn 0.2s ease; }

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

/* ─── Tables ──────────────────────────────────────────── */
table { border-collapse: collapse; width: 100%; }
th { user-select: none; }

/* ─── Tabulator — tema KRONOS ─────────────────────────────
   Vendorizado desde tabulator_simple.min.css (base más liviana que el
   tema gris por defecto de Tabulator, con menos que pisar). Este
   bloque es el ÚNICO lugar donde se define la paleta de la tabla —
   no duplicar colores acá y en cada vista, todas las tablas del
   sistema (Usuarios, Roles, Procesos, Documentos, Trámites, Logs,
   Notificaciones, Tokens) comparten este tema para verse consistentes
   entre sí. Colores de texto/borde iguales a los que ya usa el resto
   del sistema (kronos-primary/secondary, gray-200/500/700 de Tailwind);
   paleta de estado fija (verde/ámbar/rojo/azul) igual a la que ya usan
   dashboard.js/organigrama.js para badges de estado dentro de celdas. */
.tabulator {
  /* border: 1px solid #e5e7eb; */
  /* border-radius: 0.75rem; */
  overflow: hidden;
  font-family: inherit;
  font-size: 0.875rem;
  background: #fff;
  margin-top: 1rem;
  padding: .6rem;
  border-radius: .8rem!important;
}

.tabulator .tabulator-header {
  /* background: #f9fafb; */
  /* border-bottom: 1px solid #e5e7eb; */
  border: 1px solid #e5e7eb;
  margin-left: -1px;
  border-radius: .5rem .5rem 0 0;
  color: #6b7280;
  font-weight: 600;
}

.tabulator .tabulator-col {
  background: #f2f4f8 !important;
  border-right: none;
  height: 3rem;
  padding-top: .5rem;
}

.tabulator .tabulator-col .tabulator-col-content {
  padding: 0.75rem 1rem;
}

.tabulator .tabulator-col.tabulator-sortable:hover {
  background: #f1f5f9;
}

.tabulator .tabulator-col-sorter {
  color: #9ca3af;
}

.tabulator .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-sorter,
.tabulator .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-sorter {
  color: #2b6cb0;
}

.tabulator .tabulator-header-filter input,
.tabulator .tabulator-header-filter select {
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
}

.tabulator-row {
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  min-height: 2.75rem;
}

/* Sin cebra — el resto del sistema usa divide-y plano, no filas alternadas. */
.tabulator-row.tabulator-row-even { background: #fff; }

.tabulator-row.tabulator-selectable:hover {
  background: #f9fafb;
}

.tabulator .tabulator-cell {
  padding: 0.6rem 1rem;
}

.tabulator .tabulator-cell:focus-visible,
.tabulator .tabulator-col.tabulator-sortable:focus-visible,
.tabulator .tabulator-page:focus-visible {
  outline: 2px solid #2b6cb0;
  outline-offset: -2px;
}

.tabulator .tabulator-placeholder {
  color: #9ca3af;
  font-size: 0.875rem;
}

.tabulator .tabulator-footer {
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
  padding: 0.5rem 0.75rem;
}

.tabulator .tabulator-footer .tabulator-page-size {
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  background: #fff;
}

.tabulator .tabulator-footer .tabulator-page {
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: #fff;
  color: #374151;
  padding: 0.3rem 0.65rem;
  margin: 0 0.15rem;
  font-size: 0.8125rem;
}

.tabulator .tabulator-footer .tabulator-page:hover:not(.disabled):not(.active) {
  background: #f1f5f9;
}

.tabulator .tabulator-footer .tabulator-page.active {
  background: #2b6cb0;
  border-color: #2b6cb0;
  color: #fff;
  font-weight: 600;
}

.tabulator .tabulator-footer .tabulator-page.disabled {
  opacity: 0.4;
}

.tabulator .tabulator-alert {
  background: rgba(255, 255, 255, 0.85);
  color: #6b7280;
}

.tabulator .tabulator-alert .tabulator-alert-msg.tabulator-alert-state-msg {
  border-color: #2b6cb0;
  color: #2b6cb0;
  background: #eff6ff;
}

/* ─── Focus rings ─────────────────────────────────────── */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #2b6cb0;
  outline-offset: 2px;
}

/* ─── Reduced motion ──────────────────────────────────────
   Cubre tanto las animaciones/transiciones definidas acá (fadeIn, sidebar,
   stat-card, etc.) como las utilidades transition-* de Tailwind usadas
   directamente en las vistas — sin esto ninguna respetaba la preferencia
   del sistema operativo. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
