/* Tailwind se compila a app/assets/builds/tailwind-build.css (ver package.json build:css) */

/* Sistema de autoguardado de borradores */
@import "document_drafts.css";
@import "superadmin_business_picker.css";

/* ========================================
                  SPINNER DE CARGA
   ======================================== */

/* Animación de rotación */
@keyframes spin-loading {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Overlay - Fondo semi-transparente */
.loading-spinner-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
}

.loading-spinner-overlay.hidden {
  display: none !important;
}

/* Container del spinner */
.loading-spinner-container {
  position: relative !important;
  z-index: 1000000 !important;
}

/* SVG del spinner con animación */
.loading-spinner-svg {
  animation: spin-loading 1.2s linear infinite !important;
  filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.4)) !important;
}

/* Personalización del editor Trix */
trix-editor {
  border: 1px solid #d1d8e0 !important;
  border-radius: 12px !important;
  padding: 24px !important;
  min-height: 400px !important;
  background: white !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
}

trix-toolbar .trix-button-row {
  flex-wrap: wrap;
  justify-content: flex-start;
}

trix-toolbar .trix-button-group {
  margin-bottom: 8px;
  border: none;
  margin-right: 10px;
  padding: 0;
  background: none;
}

/* Estilos para los botones de la toolbar */
trix-toolbar .trix-button {
  border: 1px solid #d1d8e0;
  background: white;
  margin-right: 4px;
  border-radius: 4px;
  padding: 6px 8px;
}

trix-toolbar .trix-button:hover {
  background: #f5f5f5;
}

trix-toolbar .trix-button.trix-active {
  background: #486284;
  color: white;
  border-color: #486284;
}

/* Estilos para contenido renderizado de Trix */
.trix-content {
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
}

.trix-content h1 {
  font-size: 1.875rem;
  font-weight: bold;
  margin: 1em 0 0.5em 0;
  line-height: 1.2;
}

.trix-content h2 {
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0.9em 0 0.45em 0;
  line-height: 1.3;
}

.trix-content h3 {
  font-size: 1.25rem;
  font-weight: bold;
  margin: 0.8em 0 0.4em 0;
  line-height: 1.4;
}

.trix-content h4 {
  font-size: 1.125rem;
  font-weight: bold;
  margin: 0.7em 0 0.35em 0;
  line-height: 1.5;
}

.trix-content p {
  margin: 0 0 0.8em 0;
}

.trix-content strong,
.trix-content b {
  font-weight: 700;
}

.trix-content em,
.trix-content i {
  font-style: italic;
}

.trix-content u {
  text-decoration: underline;
}

.trix-content s,
.trix-content strike,
.trix-content del {
  text-decoration: line-through;
}

.trix-content ul {
  list-style-type: disc;
  padding-left: 1.5em;
  margin: 0 0 0.8em 0;
}

.trix-content ol {
  list-style-type: decimal;
  padding-left: 1.8em;
  margin: 0 0 0.8em 0;
}

.trix-content li {
  margin: 0.3em 0;
}

.trix-content blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 4px solid #d1d5db;
  color: #6b7280;
  font-style: italic;
}

.trix-content pre {
  background-color: #f3f4f6;
  padding: 1em;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.8em 0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
}

.trix-content code {
  background-color: #f3f4f6;
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
}

.trix-content a {
  color: #2563eb;
  text-decoration: underline;
}

.trix-content a:hover {
  color: #1d4ed8;
}

.trix-content img {
  max-width: 100%;
  height: auto;
  margin: 1em 0;
}

.trix-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 1.5em 0;
}

/* Fuerza que hidden realmente oculte */
.hidden {
  display: none !important;
}

/* Cuando el modal está abierto */
.modal-open {
  display: flex !important;
}

/* Paginación: ver will_paginate.css (cargada después, sin @tailwind). */

/* Dropdown de notificaciones (navbar): en móvil el panel es más ancho que el <li> del icono,
   el anchor right-0 desborda el viewport; además .transform-dropdown-show pisa translate-x de Tailwind.
   Solución: panel fijo entre márgenes del viewport solo en pantallas pequeñas. */
@media (max-width: 639px) {
  #notifications-dropdown-panel {
    position: fixed !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    top: max(4.5rem, calc(env(safe-area-inset-top) + 3.25rem)) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    z-index: 60 !important;
  }

  #notifications-dropdown-panel.transform-dropdown {
    transform: perspective(999px) rotateX(-10deg) translateZ(0) translate3d(0, 0, 0) !important;
  }

  #notifications-dropdown-panel.transform-dropdown-show {
    transform: perspective(999px) rotateX(0deg) translateZ(0) translate3d(0, 0, 5px) !important;
  }
}

/* Dashboard / documentos: títulos más compactos en móvil (misma área que .mobile-hidden ≤767px). */
@media (max-width: 767px) {
  .app-layout-main-inner h2.text-2xl,
  .app-layout-main-inner h3.text-2xl {
    font-size: 1.25rem;
    line-height: 1.35;
  }

  .app-layout-main-inner h3.text-xl {
    font-size: 1.1rem;
    line-height: 1.35;
  }

  .app-layout-main-inner h5.text-slate-600 {
    font-size: 0.875rem;
    line-height: 1.4;
  }

  .compact-action-btn {
    min-width: 1.75rem;
    justify-content: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  .compact-action-btn span {
    display: none;
  }

  .compact-action-btn i {
    margin-right: 0;
  }
}

/* Móvil / tablet (< xl 1200px): el aside tenía ml-4 siempre; -translate-x-full mueve el 100% del
   ancho del panel pero NO el margen, así que quedaba ~1rem de panel blanco a la izquierda.
   En el HTML el margen izquierdo pasa a ml-0 y solo xl:ml-4; aquí devolvemos ml-4 cuando el
   drawer está abierto (clase translate-x-0 que pone el JS de la hamburguesa). */
@media (max-width: 1199px) {
  body.app-layout-shell aside.side-menu-root.translate-x-0 {
    margin-left: 1rem !important;
  }
}

/* Shell a ancho completo (evita hueco a la derecha con overflow-x-hidden + margen legacy). */
html,
body.app-layout-shell {
  width: 100%;
  max-width: 100%;
}

body.app-layout-shell {
  box-sizing: border-box;
}

/* Área principal: ocupa todo el ancho restante (sin ml-68.5 del tema fixed-sidenav). */
body.app-layout-shell .app-layout-main {
  flex: 1 1 0%;
  min-width: 0;
  width: auto;
  max-width: none;
}

body.app-layout-shell .app-layout-main-inner {
  width: 100%;
  max-width: 100%;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.app-layout-shell .app-layout-content {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

body.app-layout-shell .app-layout-main-inner nav[navbar-main] {
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  max-width: 100%;
}

/* Escritorio (>= xl 1200px): menú lateral en flujo de columna, altura según viewport (sin .h-sidenav). */
@media (min-width: 1200px) {
  body.app-layout-shell {
    flex-direction: row;
    align-items: stretch;
    width: 100%;
  }

  aside.side-menu-root {
    position: sticky !important;
    top: 1rem;
    inset: auto;
    align-self: flex-start;
    height: calc(100vh - 2rem);
    min-height: calc(100vh - 2rem);
    max-height: calc(100vh - 2rem);
    overflow-x: visible;
    overflow-y: auto;
    flex: 0 0 15.625rem;
    width: 15.625rem;
    max-width: 15.625rem;
  }

  aside.side-menu-root .side-menu-nav {
    height: 100% !important;
    max-height: 100% !important;
    overflow-y: visible !important;
  }
}

/* Móvil / tablet: menú overlay; contenido a ancho completo. */
@media (max-width: 1199px) {
  body.app-layout-shell .app-layout-main,
  body.app-layout-shell .app-layout-main-inner {
    width: 100%;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* Superadmin dashboard */
.sa-dashboard {
  padding: 1.5rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.sa-dashboard__header {
  margin-bottom: 1.25rem;
}

.sa-dashboard__header h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.2;
  color: #0f172a;
  font-weight: 700;
}

.sa-dashboard__header p {
  margin: 0.4rem 0 0;
  color: #64748b;
  font-size: 0.95rem;
}

.sa-kpis-grid,
.sa-main-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.sa-kpis-grid {
  margin-bottom: 1rem;
}

.sa-kpi-card,
.sa-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.sa-kpi-card {
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.sa-kpi-card__icon {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.95rem;
}

.sa-kpi-card__icon.is-cyan { background: linear-gradient(135deg, #06b6d4, #0284c7); }
.sa-kpi-card__icon.is-purple { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.sa-kpi-card__icon.is-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.sa-kpi-card__icon.is-emerald { background: linear-gradient(135deg, #10b981, #059669); }

.sa-kpi-card__content {
  min-width: 0;
}

.sa-label {
  margin: 0;
  font-size: 0.73rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
}

.sa-value {
  margin: 0.3rem 0 0;
  font-size: 1.6rem;
  line-height: 1.15;
  color: #0f172a;
  font-weight: 700;
}

.sa-meta {
  margin: 0.35rem 0 0;
  color: #475569;
  font-size: 0.82rem;
}

.sa-panel {
  padding: 1rem;
}

.sa-panel__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
  color: #1e293b;
  font-size: 0.86rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}

.sa-panel__title i {
  color: #3b82f6;
}

.sa-span-2 {
  grid-column: span 2;
}

.sa-income-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.sa-income-box {
  border-radius: 0.8rem;
  border: 1px solid #e2e8f0;
  padding: 0.8rem;
}

.sa-income-box p {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
}

.sa-income-box strong {
  display: block;
  margin-top: 0.35rem;
  color: #0f172a;
  font-size: 1.2rem;
  line-height: 1.2;
}

.sa-income-box.is-success { background: #ecfdf5; border-color: #a7f3d0; }
.sa-income-box.is-warning { background: #fffbeb; border-color: #fde68a; }
.sa-income-box.is-info { background: #eff6ff; border-color: #bfdbfe; }
.sa-income-box.is-neutral { background: #f8fafc; border-color: #cbd5e1; }

.sa-bars-chart {
  height: 12rem;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
}

.sa-bar-col {
  text-align: center;
}

.sa-bar-track {
  border-radius: 0.45rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  height: 8.75rem;
  display: flex;
  align-items: end;
  padding: 0.14rem;
}

.sa-bar {
  width: 100%;
  border-radius: 0.3rem;
  transition: transform 0.2s ease;
}

.sa-bar:hover {
  transform: translateY(-2px);
}

.sa-bar.is-cyan { background: linear-gradient(180deg, #22d3ee 0%, #0891b2 100%); }
.sa-bar.is-indigo { background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%); }

.sa-bar-col p {
  margin: 0.35rem 0 0;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 600;
}

.sa-bar-col small {
  color: #94a3b8;
  font-size: 0.68rem;
}

.sa-donut-wrap {
  display: flex;
  justify-content: center;
  padding: 0.4rem 0 0.8rem;
}

.sa-donut {
  width: 9rem;
  height: 9rem;
  border-radius: 9999px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sa-donut::after {
  content: "";
  position: absolute;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 9999px;
  background: #fff;
}

.sa-donut span {
  position: relative;
  z-index: 1;
  color: #0f172a;
  font-weight: 700;
}

.sa-footnote {
  margin: 0;
  text-align: center;
  color: #64748b;
  font-size: 0.8rem;
}

.sa-list {
  display: grid;
  gap: 0.5rem;
}

.sa-list-row {
  border-radius: 0.65rem;
  border: 1px solid #e2e8f0;
  padding: 0.55rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  color: #334155;
  font-size: 0.82rem;
}

.sa-list-row strong {
  color: #0f172a;
}

.sa-list-row.is-stack {
  display: block;
}

.sa-list-row.is-stack span {
  display: block;
  margin-top: 0.2rem;
  color: #64748b;
  font-size: 0.75rem;
}

.sa-empty {
  margin: 0.15rem 0 0;
  color: #94a3b8;
  font-size: 0.86rem;
}

@media (max-width: 1399px) {
  .sa-kpis-grid,
  .sa-main-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sa-span-2 {
    grid-column: span 2;
  }
}

@media (max-width: 767px) {
  .sa-dashboard {
    padding: 1rem;
  }

  .sa-kpis-grid,
  .sa-main-grid,
  .sa-income-grid {
    grid-template-columns: 1fr;
  }

  .sa-span-2 {
    grid-column: span 1;
  }

  .sa-bars-chart {
    grid-template-columns: repeat(6, minmax(2.4rem, 1fr));
    overflow-x: auto;
    padding-bottom: 0.35rem;
  }
}

/* Crear documento: ocultar columnas de menor si todas las filas son Titular */
#recipients-table.recipients-all-titular th.minor-col,
#recipients-table.recipients-all-titular td.minor-col {
  display: none;
}

/* Crear documento: panel opciones de envio */
.send-options-panel { padding: 12px 14px; }
.send-options-grid { gap: 10px; }
.send-options-card { padding: 10px 12px; }
.send-options-copy-child { margin-top: 8px; }

/* Toggles propios (evita colision con DaisyUI .toggle) */
.sig-toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  vertical-align: middle;
}
.sig-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.sig-toggle .sig-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background-color: #fecaca;
  border: 1px solid #ef4444;
  border-radius: 9999px;
  transition: background-color .2s ease, border-color .2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
.sig-toggle .sig-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 2px;
  border-radius: 9999px;
  background-color: #fff;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.sig-toggle input[type="checkbox"]:checked + .sig-slider {
  background-color: #22c55e;
  border-color: #16a34a;
}
.sig-toggle input[type="checkbox"]:checked + .sig-slider::before { transform: translateX(18px); }
.sig-toggle input[type="checkbox"]:not(:checked) + .sig-slider::before { transform: translateX(0); }
.sig-toggle input[type="checkbox"]:disabled + .sig-slider { opacity: .9; }
