/* ==========================================================================
   ÁRGORAS 2025 - GESTIÓN INTEGRAL DE REPUESTOS EÓLICOS
   Estilos personalizados para la Intranet de Clientes
   ========================================================================== */

:root {
  --color-primary: #0d233a;
  --color-primary-light: #162a45;
  --color-primary-dark: #071524;
  --color-brand-orange: #f97f22;
  --color-brand-orange-hover: #e2690c;
  --color-accent-blue: #0284c7;
  --color-bg-light: #f8fafc;
  --color-surface: #ffffff;
}

/* Tipografía base */
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--color-bg-light);
  color: #1e293b;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}

/* Transiciones suaves */
.transition-view {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Badges de Estado con diseño corporativo fiel a los mockups */
.badge-disponible {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-mantenimiento {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-bajo-stock {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-critico {
  background-color: #ffe4e6;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.badge-agotado {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.badge-urgente {
  background-color: #fff7ed;
  color: #c2410c;
  border: 1px solid #ffedd5;
}

.badge-express {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #dbeafe;
}

/* Barra de desplazamiento estética */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Indicador pulsante de estado en tiempo real para el Tracking */
.pulse-indicator {
  position: relative;
}

.pulse-indicator::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 9999px;
  background-color: currentColor;
  opacity: 0.4;
  animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Estilo para el mapa esquemático de transporte */
.route-line {
  background: linear-gradient(90deg, #10b981 0%, #0284c7 60%, #cbd5e1 100%);
}

/* Tarjeta activa en menú lateral */
.sidebar-link.active {
  background-color: #1e3a5f;
  color: #ffffff;
  border-left: 4px solid var(--color-brand-orange);
  font-weight: 600;
}

.sidebar-link:not(.active):hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

/* Pestaña activa en ficha técnica */
.tab-button.active {
  border-bottom: 3px solid var(--color-brand-orange);
  color: #0f243e;
  font-weight: 700;
}

/* Sombras suaves de componentes */
.card-shadow {
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.04);
}

.card-shadow-hover:hover {
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
  transform: translateY(-2px);
  transition: all 0.2s ease-in-out;
}

/* Utilidades de Tailwind v4 usadas en el marcado que no existen en el CDN v3 */
.shadow-xs {
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.backdrop-blur-xs {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* Animación de error en el login (referenciada desde app.js) */
.shake-animation {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* ==========================================================================
   ADAPTACIÓN A MÓVIL Y TABLET
   ========================================================================== */

/* Menú lateral desplegable (off-canvas) por debajo de 1024 px */
@media (max-width: 1023.98px) {
  #appSidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  body.sidebar-open #appSidebar {
    transform: translateX(0);
  }
}

/* Barras de pestañas y filtros con desplazamiento horizontal en lugar de desbordar */
.scroll-x-tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-x-tabs::-webkit-scrollbar {
  display: none;
}
.scroll-x-tabs > * {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 639.98px) {
  /* iOS amplía la página al enfocar campos con texto < 16 px */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Check-list de OT: cada tarea pasa a ser una tarjeta apilada */
  .ot-table thead {
    display: none;
  }
  .ot-table, .ot-table tbody, .ot-table tr, .ot-table td {
    display: block;
    width: 100% !important;
  }
  .ot-table tr {
    padding: 0.5rem 0.25rem;
  }
  .ot-table td {
    padding: 0.25rem 0.5rem !important;
    text-align: left !important;
  }
  .ot-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 2px;
  }

  /* Notificaciones a todo el ancho */
  #toastContainer {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
  }
}

/* Estilos de impresión para Ficha Técnica y Albarán de Transporte */
@media print {
  aside, header, #viewLogin, .no-print, #toastContainer {
    display: none !important;
  }
  body, body > div {
    height: auto !important;
    overflow: visible !important;
  }
  main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    overflow: visible !important;
  }
  .print-only {
    display: block !important;
  }

  /* Impresión de la OT de preservación: solo el check-list */
  body.print-ot > div:not(#otModal) {
    display: none !important;
  }
  body.print-ot #otModal {
    position: static !important;
    display: block !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
  }
  body.print-ot #otModalScroll {
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: none !important;
    max-width: none !important;
  }
  body.print-ot input[type="text"], body.print-ot select {
    border: none !important;
    border-bottom: 1px solid #cbd5e1 !important;
    background: none !important;
  }
  .ot-phase {
    break-inside: avoid;
  }
}
