/**
 * Estilos específicos para el Módulo de Refacciones, Requisiciones y Órdenes de Compra
 * Sentinel Maintenance — EMOSA
 */

:root {
  --badge-normal: #10b981;
  --badge-warning: #f59e0b;
  --badge-critical: #ef4444;
  --badge-limp: #eab308;
  --card-glass: rgba(15, 27, 44, 0.78);
  --card-border: rgba(61, 214, 208, 0.22);
}

/* Badge de Tiempo Transcurrido (Elapsed Time) */
.badge-elapsed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', 'Segoe UI Mono', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.badge-elapsed-normal {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-elapsed-warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.badge-elapsed-limp {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.5);
}

.badge-elapsed-critical {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.badge-elapsed-delayed {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

/* Animación de pulso crítico para máquinas detenidas */
@keyframes blinkPulse {
  0% { transform: scale(1); box-shadow: 0 0 4px rgba(239, 68, 68, 0.4); }
  50% { transform: scale(1.04); box-shadow: 0 0 16px rgba(239, 68, 68, 0.85); background: rgba(239, 68, 68, 0.35); }
  100% { transform: scale(1); box-shadow: 0 0 4px rgba(239, 68, 68, 0.4); }
}

.blink-pulse {
  animation: blinkPulse 1.8s infinite ease-in-out;
}

/* Badges de Urgencia */
.badge-urgency {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 6px;
}

.urgency-normal {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.urgency-limp {
  background: rgba(245, 158, 11, 0.25);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.5);
}

.urgency-stopped {
  background: rgba(239, 68, 68, 0.28);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.65);
  font-weight: 800;
}

.badge-escalated-tag {
  margin-left: 6px;
  font-size: 0.65rem;
  background: #ff9f1c;
  color: #07111f;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 800;
}

/* Badges de Estado */
.badge-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.status-pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
.status-approved { background: rgba(59, 130, 246, 0.18); color: #93c5fd; border-color: rgba(59, 130, 246, 0.4); }
.status-quoting { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.4); }
.status-ordered { background: rgba(61, 214, 208, 0.18); color: #6ee7b7; border-color: rgba(61, 214, 208, 0.4); }
.status-partial { background: rgba(234, 179, 8, 0.18); color: #fde047; border-color: rgba(234, 179, 8, 0.4); }
.status-received { background: rgba(16, 185, 129, 0.25); color: #86efac; border-color: rgba(16, 185, 129, 0.5); font-weight: 700; }
.status-cancelled { background: rgba(156, 163, 175, 0.2); color: #d1d5db; border-color: rgba(156, 163, 175, 0.3); }

/* Tooltip informativo con icono (i) */
.info-tooltip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: var(--sentinel-cyan);
  background: rgba(61, 214, 208, 0.12);
  margin-left: 6px;
  cursor: help;
  font-size: 0.72rem;
  transition: all 0.2s ease;
  vertical-align: middle;
}

.info-tooltip-btn:hover,
.info-tooltip-btn:focus {
  background: var(--sentinel-cyan);
  color: #07111f;
  transform: scale(1.18);
  box-shadow: 0 0 8px rgba(61, 214, 208, 0.5);
  outline: none;
}

/* Custom Tooltip Popper */
.tooltip .tooltip-inner {
  background-color: #0d1e34 !important;
  color: #f3f7fb !important;
  border: 1px solid var(--sentinel-cyan) !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6) !important;
  font-size: 0.78rem !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  max-width: 280px !important;
  text-align: left !important;
  line-height: 1.4 !important;
}

.tooltip .tooltip-arrow::before {
  border-top-color: var(--sentinel-cyan) !important;
  border-bottom-color: var(--sentinel-cyan) !important;
}

/* Tarjetas y Paneles */
.ref-card {
  background: var(--card-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  margin-bottom: 20px;
}

.ref-table {
  width: 100%;
  margin: 0;
  color: #f3f7fb !important;
  border-collapse: separate;
  border-spacing: 0;
}

.ref-table thead th {
  background: rgba(12, 24, 41, 0.95) !important;
  color: var(--sentinel-cyan) !important;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  position: sticky;
  top: 0;
  z-index: 5;
}

.ref-table tbody td {
  padding: 12px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  vertical-align: middle;
  background: transparent !important;
}

.ref-table tbody tr:hover td {
  background: rgba(61, 214, 208, 0.05) !important;
}

/* Selector de Urgencia con Radio Cards */
.urgency-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.urgency-radio-card {
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.urgency-radio-card:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.urgency-radio-card input[type="radio"] {
  accent-color: var(--emosa-orange);
  width: 18px;
  height: 18px;
}

.urgency-radio-card.selected-normal {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

.urgency-radio-card.selected-limp {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}

.urgency-radio-card.selected-stopped {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
}

/* Autocomplete Dropdown */
.autocomplete-container {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  background: #0d1e34;
  border: 1px solid var(--sentinel-cyan);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
  max-height: 250px;
  overflow-y: auto;
  display: none;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  transition: background 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(61, 214, 208, 0.18);
  color: #fff;
}

.autocomplete-item .item-sku {
  font-weight: 700;
  color: var(--sentinel-cyan);
  font-family: monospace;
}

.autocomplete-item .item-stock {
  font-size: 0.75rem;
  color: #aebbd0;
}

/* QR Code Container */
.qr-preview-box {
  background: #ffffff;
  padding: 12px;
  border-radius: 8px;
  display: inline-block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.qr-label-card {
  background: #ffffff;
  color: #111827;
  padding: 14px;
  border-radius: 8px;
  border: 2px dashed #374151;
  max-width: 340px;
  margin: 0 auto;
  font-family: system-ui, sans-serif;
}

.qr-label-header {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #b45309;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

/* Acrónimos con tooltip on hover (MRO, OC, SLA, etc.) */
abbr.acronym, .acronym {
  text-decoration: underline dotted var(--sentinel-cyan) !important;
  text-underline-offset: 4px;
  cursor: help;
  color: inherit;
  font-weight: inherit;
  transition: color 0.15s ease;
}

abbr.acronym:hover, .acronym:hover {
  color: var(--sentinel-cyan) !important;
}

/* Botones Cyan de Alta Visibilidad para Tema Oscuro */
.btn-outline-cyan {
  color: #38bdf8 !important;
  border: 1.5px solid #38bdf8 !important;
  background: rgba(56, 189, 248, 0.12) !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.btn-outline-cyan:hover, .btn-outline-cyan.active {
  color: #07111f !important;
  background: #38bdf8 !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.btn-cyan {
  background: #0ea5e9 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  border: 1px solid #38bdf8 !important;
  transition: all 0.2s ease;
}

.btn-cyan:hover {
  background: #0284c7 !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.5);
}

/* ==========================================================================
   FORMATO DE IMPRESIÓN OFICIAL Y RECABADO DE FIRMAS MANUALES (EMOSA MRO)
   ========================================================================== */

.modal-dialog-print {
  max-width: 900px;
}

.print-actions-bar {
  background: rgba(13, 30, 52, 0.95);
  border: 1px solid var(--sentinel-cyan);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.print-sheet {
  background: #ffffff;
  color: #111827;
  border-radius: 8px;
  padding: 24px 28px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.88rem;
  line-height: 1.4;
  position: relative;
}

/* Header de Documento Oficial */
.print-doc-header {
  border-bottom: 2px solid #1e3a5f;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.print-doc-header .company-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
  margin: 0;
  text-transform: uppercase;
}

.print-doc-header .company-sub {
  font-size: 0.76rem;
  color: #475569;
  font-weight: 600;
}

.print-doc-header .doc-folio-badge {
  text-align: right;
}

.print-folio-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #b45309;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}

.print-folio-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0284c7;
}

/* Tablas y Cajas de Información */
.print-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.print-info-item .info-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}

.print-info-item .info-value {
  font-size: 0.84rem;
  color: #0f172a;
  font-weight: 700;
}

.print-urgency-banner {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.print-urgency-banner.banner-critical {
  background: #fef2f2;
  border: 2px solid #ef4444;
  color: #b91c1c;
}

.print-urgency-banner.banner-limp {
  background: #fffbeb;
  border: 2px solid #f59e0b;
  color: #b45309;
}

.print-urgency-banner.banner-normal {
  background: #f0fdf4;
  border: 1px solid #22c55e;
  color: #15803d;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  font-size: 0.82rem;
}

.print-table th {
  background: #1e293b;
  color: #ffffff;
  padding: 6px 10px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  border: 1px solid #1e293b;
}

.print-table td {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  vertical-align: middle;
}

.print-table tr:nth-child(even) {
  background: #f8fafc;
}

.print-table-total {
  font-weight: 800;
  font-size: 0.95rem;
  color: #0f172a;
  text-align: right;
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-top: none;
  margin-bottom: 16px;
}

/* SECCIÓN PRINCIPAL: RECABADO DE FIRMAS MANUALES */
.print-signatures-section {
  margin-top: 18px;
  page-break-inside: avoid;
}

.print-signatures-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #334155;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 4px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.print-signatures-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  page-break-inside: avoid;
}

.print-sig-box {
  border: 1.5px solid #94a3b8;
  border-radius: 6px;
  padding: 10px 8px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 160px;
  position: relative;
  text-align: center;
}

.print-sig-box.sig-box-director {
  border-color: #0284c7;
  background: #f8fafc;
}

.print-sig-box.sig-box-pending {
  border-style: dashed;
  border-color: #dc2626;
  background: #fffafa;
}

.print-sig-header {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.print-sig-status {
  margin-bottom: 8px;
}

.stamp-digital-badge {
  display: inline-block;
  background: #ecfdf5;
  border: 1.5px solid #059669;
  color: #047857;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  line-height: 1.2;
}

.stamp-pending-badge {
  display: inline-block;
  background: #fef2f2;
  border: 1.5px dashed #dc2626;
  color: #b91c1c;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  line-height: 1.2;
}

.print-sig-line {
  margin-top: auto;
  border-top: 1px solid #475569;
  padding-top: 4px;
}

.print-sig-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.print-sig-role {
  font-size: 0.64rem;
  color: #64748b;
  margin-top: 1px;
}

.print-sig-date {
  font-size: 0.62rem;
  color: #94a3b8;
  font-family: monospace;
}

.print-doc-footer {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid #cbd5e1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  color: #64748b;
}

/* ==========================================================================
   ESTILOS ESPECÍFICOS DE @MEDIA PRINT (Página Carta / Letter)
   ========================================================================== */
@media print {
  @page {
    size: letter portrait;
    margin: 8mm 10mm;
  }

  /* Ocultar interfaz del sistema y mostrar exclusivamente la hoja */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body * {
    visibility: hidden;
  }

  .top-bar,
  header,
  nav,
  .btn,
  .dir-auth-overlay,
  .rafaga-action-bar,
  .modal-backdrop,
  .print-actions-bar,
  .modal-header,
  .modal-footer {
    display: none !important;
    visibility: hidden !important;
  }

  #modalImpresionOC,
  #modalImpresionOC .modal-dialog,
  #modalImpresionOC .modal-content,
  #modalImpresionOC .modal-body,
  #modalImpresionOC .print-sheet,
  #modalImpresionOC .print-sheet * {
    visibility: visible !important;
  }

  #modalImpresionOC {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    display: block !important;
  }

  #modalImpresionOC .modal-dialog {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  #modalImpresionOC .modal-content {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  #modalImpresionOC .modal-body {
    padding: 0 !important;
  }

  .print-sheet {
    box-shadow: none !important;
    border: 1px solid #334155 !important;
    border-radius: 0 !important;
    padding: 16px 20px !important;
    width: 100% !important;
    margin: 0 !important;
    page-break-inside: avoid;
  }

  .print-table th {
    background: #334155 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .stamp-digital-badge,
  .stamp-pending-badge,
  .print-urgency-banner {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

