/*!
 * Custom CSS del proyecto ICG.
 * Estilos compartidos: lookups responsive, formularios de documento,
 * y ajustes de usabilidad para tablet/móvil.
 */

/* ====================================================================
   Navegación PRO: barra de progreso superior (estilo Vercel/Linear) +
   revelado del contenido. Minimalista, rápido y sin tapar la pantalla.
   Lo controla el JS de base.html (#icg-progress + ICGNav).
   ==================================================================== */
#icg-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2.5px; width: 0;
  z-index: 4000;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, #04a9f5 0%, #1de9b6 100%);
  box-shadow: 0 0 10px rgba(4, 169, 245, 0.65), 0 0 5px rgba(29, 233, 182, 0.5);
  transition: width 0.25s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.3s ease;
}
#icg-progress.active { opacity: 1; }
/* "Cometa": brillo en la cabeza de la barra */
#icg-progress::after {
  content: '';
  position: absolute;
  right: 0; top: -2px;
  height: 6.5px; width: 90px;
  border-radius: 50%;
  box-shadow: 0 0 14px 3px rgba(4, 169, 245, 0.85);
  transform: translateX(35%);
}

/* Revelado del contenido al llegar (todas las páginas) */
.pc-content { animation: icg-content-in 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
@keyframes icg-content-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* Transición ESPECIAL al abrir un documento (detalle): zoom suave */
body.icg-doc-enter .pc-content { animation: icg-doc-in 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
@keyframes icg-doc-in {
  from { opacity: 0; transform: scale(0.965) translateY(12px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  #icg-progress { transition: opacity 0.15s ease; }
  .pc-content, body.icg-doc-enter .pc-content { animation: none !important; }
}

/* ====================================================================
   Lookups (búsqueda de artículo / cliente / proveedor)
   ==================================================================== */
.lookup-results {
  position: absolute;
  z-index: 1050;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  max-height: 320px;
  overflow-y: auto;
  width: 100%;
  margin-top: 2px;
  -webkit-overflow-scrolling: touch;
}
.lookup-results-floating {
  position: fixed !important;
  z-index: 1090;   /* por encima de mensajes flash (1080), tooltips, cards */
}
.lookup-results .item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 120ms ease;
  min-height: 44px;            /* objetivo táctil cómodo */
}
.lookup-results .item:last-child { border-bottom: 0; }
.lookup-results .item:hover,
.lookup-results .item.active { background-color: #eef5ff; }
.lookup-results .item small { color: #888; display: block; margin-top: 2px; }

/* ====================================================================
   Totales de los formularios de documento
   ==================================================================== */
.icg-totales {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
}
.icg-total-final {
  font-size: 20px;
  font-weight: 600;
}

/* ====================================================================
   Tabla de líneas (creación de documentos)
   ==================================================================== */
.table-lineas td { vertical-align: middle; }
.table-lineas input { font-size: 14px; }

/* Chips de info fija (cabecera de requisición) */
.info-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: #f1f3f5; border: 1px solid #e9ecef;
  border-radius: 999px; line-height: 1.4; white-space: nowrap; font-size: 13px;
}
.info-chip .info-label { color: #6c757d; text-transform: uppercase; letter-spacing: .04em; font-size: 11px; font-weight: 500; }
.info-chip .info-value { color: #1a1a1a; font-weight: 600; font-size: 13px; }
.info-chip-accent { background: #e7f5ff; border-color: #b6e0fe; }
.info-chip-accent .info-value { color: #0b5cad; }

/* ====================================================================
   Responsive — tablet y móvil
   ==================================================================== */
@media (max-width: 767.98px) {
  /* Lookups a casi todo el ancho y opciones más grandes en móvil */
  .lookup-results-floating { width: calc(100vw - 24px) !important; }
  .lookup-results .item { padding: 12px 14px; min-height: 48px; }

  /* Inputs y botones más cómodos al tacto dentro de tablas/formularios */
  .table-lineas .form-control-sm,
  .form-control-sm, .btn-sm { min-height: 40px; }

  /* La tabla de líneas mantiene un ancho mínimo y se desplaza horizontalmente */
  .table-lineas { min-width: 560px; }

  /* Cabeceras de página: título y acciones se apilan limpio */
  .page-header .page-block .d-flex { row-gap: .5rem; }

  /* Botones de acción a ancho completo en pantallas muy chicas */
  .icg-actions .btn { flex: 1 1 auto; }
}

/* ====================================================================
   Overlay "Procesando…" (envío de formularios / acciones)
   ==================================================================== */
.icg-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(17, 24, 39, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(1px);
}
.icg-overlay.d-none { display: none !important; }
.icg-overlay-box {
  text-align: center;
  padding: 1.5rem 2rem;
}

/* ====================================================================
   Modal de confirmación unificado (.icg-confirm)
   ==================================================================== */
.icg-confirm .modal-content {
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
}
.icg-confirm .modal-header {
  border-bottom: 0;
  padding: 1rem 1.25rem;
}
.icg-confirm .modal-title { font-size: 1.05rem; font-weight: 600; }
.icg-confirm .modal-body { padding: 1.25rem; font-size: .95rem; }
.icg-confirm .modal-footer { border-top: 0; padding: .75rem 1.25rem 1.25rem; }
.icg-confirm .icg-confirm-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .25);
}
.icg-confirm .icg-confirm-icon i { width: 18px; height: 18px; }

/* Variantes de color del encabezado */
.icg-confirm-danger  { background: #dc3545; color: #fff; }
.icg-confirm-warning { background: #f5a623; color: #1b1b1b; }
.icg-confirm-primary { background: #04a9f5; color: #fff; }
.icg-confirm-danger .btn-close,
.icg-confirm-primary .btn-close { filter: invert(1) grayscale(1) brightness(2); }

/* ====================================================================
   Accesibilidad: foco visible consistente
   ==================================================================== */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.page-link:focus-visible,
a.pc-head-link:focus-visible,
.lookup-results .item:focus-visible {
  outline: 2px solid #04a9f5;
  outline-offset: 2px;
}
.lookup-results .item:focus { background: #eef6ff; }

/* ====================================================================
   Impresión: ocultar cromo (sidebar/nav/botones) y dejar el contenido
   ==================================================================== */
@media print {
  .pc-sidebar, .pc-header, #icg-overlay, .flash-stack,
  .icg-actions, .icg-list-toolbar, .card-footer,
  footer, .pc-footer, .breadcrumb, form.icg-action-form,
  #theme-toggle, .btn { display: none !important; }

  body { background: #fff !important; }
  .pc-container, .pc-content { margin: 0 !important; padding: 0 !important; }
  .card { border: 1px solid #ddd !important; box-shadow: none !important; }
  a[href]:after { content: ""; }   /* no imprimir URLs tras los enlaces */
  .table { font-size: 12px; }
}

/* En tablet, dar un poco más de aire a las celdas */
@media (min-width: 768px) and (max-width: 991.98px) {
  .table-lineas td, .table-lineas th { padding-top: .4rem; padding-bottom: .4rem; }
}

/* ====================================================================
   Homologación de listas y detalles
   ==================================================================== */
.icg-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.icg-list-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.icg-list-toolbar .icg-search { flex: 1 1 240px; min-width: 0; }
