/* ===========================
   Resumen - Diseño Ultra Premium (Radical)
   =========================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@700&display=swap');

:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  
  /* Paleta Oscura (Header) */
  --header-bg-1: #0f172a; /* Slate 900 */
  --header-bg-2: #064e3b; /* Emerald 900 */
  
  /* Acentos */
  --accent: #10b981; /* Emerald 500 */
  --accent-glow: rgba(16, 185, 129, 0.4);
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;

  --shadow-sm: 0 2px 4px rgba(15,23,42,0.04);
  --shadow-md: 0 8px 16px rgba(15,23,42,0.06);
  --shadow-lg: 0 20px 25px -5px rgba(15,23,42,0.1), 0 8px 10px -6px rgba(15,23,42,0.1);
  --shadow-float: 0 25px 50px -12px rgba(15,23,42,0.25);
  
  --radius-xl: 20px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body.detalle-activo {
  background-image: none !important;
  background-color: #ffffff !important; /* Fondo completamente blanco */
  color: var(--text-main);
}
/* Eliminamos la regla body.detalle-activo para no tapar la imagen de los camiones */

.layout { min-height: 100vh; display: flex; flex-direction: column; }

/* ===========================
   HEADER: TARJETA FLOTANTE OSCURA
   =========================== */
.header {
  margin: 1.5rem auto;
  width: calc(100% - 3rem);
  max-width: 1600px;
  background: linear-gradient(135deg, var(--header-bg-1), var(--header-bg-2));
  border-radius: var(--radius-xl);
  padding: 2rem;
  color: #ffffff;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

/* Efecto de luz en el header */
.header::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 50% 0%, rgba(16,185,129,0.15), transparent 50%);
  pointer-events: none;
}

.header__title {
  margin: 0 0 1.25rem 0;
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  position: relative;
  z-index: 2;
}

.badge--id {
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.9rem;
  background: rgba(16,185,129,0.15);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(16,185,129,0.3);
}

.doc-badge {
  font-family: 'JetBrains Mono', monospace;
  background: transparent;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  position: relative;
  z-index: 2;
}

/* Chips estilo Glassmorphism */
.chip {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}
.chip:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.12);
}

.chip strong {
  color: #94a3b8;
  font-weight: 600;
  margin-right: 0.35rem;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.chip--estado {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
}
.chip--estado strong { color: #a7f3d0; }

/* ===========================
   CONTENIDO PRINCIPAL
   =========================== */
.content {
  padding: 0 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: #ffffff !important;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.tools__right {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search input {
  width: 450px;
  max-width: 100%;
  background: #f8fafc;
  color: var(--text-main);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.search input:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
}
.toggle input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===========================
   TABLA PREMIUM
   =========================== */
.table-wrap {
  background: #ffffff !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: auto;
  box-shadow: var(--shadow-md);
  max-height: calc(100vh - 400px);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
}

/* Cabecera oscura solicitada */
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #1e293b; /* Slate 800 - Elegante y oscuro */
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
thead th:hover { background: #334155; }
thead th.is-sorted::after { content: attr(data-dir); margin-left: 6px; color: var(--accent); }

tbody td {
  padding: 1rem;
  border-bottom: 1px solid #f1f5f9;
  text-align: center;
  color: var(--text-main);
  vertical-align: middle;
  background: #ffffff !important; /* Fondo blanco sólido y forzado para evitar transparencias */
}

tbody tr:nth-child(even) td { background: #f8fafc; }
tbody tr:hover td { background: #f0fdf4; }

.warning-row td {
  background: #fef9c3 !important;
  font-weight: 600;
  color: #854d0e;
}

/* Fix para la primera columna pegajosa */
#tablaArticulos td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: inherit;
  border-right: 1px solid var(--border);
  font-weight: 700;
}
#tablaArticulos th:first-child {
  position: sticky;
  left: 0;
  z-index: 11;
  background: #1e293b;
  border-right: 1px solid rgba(255,255,255,0.1);
}

.empty {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
  background: #ffffff;
  font-weight: 500;
  font-size: 1.1rem;
}

/* ===========================
   ACTION BAR FLOTANTE (ISLA)
   =========================== */
.action-bar {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 3rem);
  max-width: 1200px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 100px;
  padding: 0.75rem 1rem;
  z-index: 50;
  box-shadow: var(--shadow-float), 0 0 0 1px rgba(0,0,0,0.05);
}

.action-bar__row {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

/* Botones genéricos */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Botón Regresar (Ghost) */
.btn-back {
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
}
.btn-back:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

/* Botón Principal TV PICKING (Glowing) */
.btn--primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 15px var(--accent-glow);
  font-size: 1.05rem;
  padding: 0.75rem 2.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
.btn--primary::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shine 3s infinite;
}
@keyframes shine {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}
.btn--primary:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.4);
}
.btn--primary:active {
  transform: translateY(0);
}

/* Segmented Control iOS-style */
.segmented {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 4px;
}
.segmented button {
  background: transparent;
  color: var(--text-muted);
  border: 0;
  padding: 0.5rem 1.5rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 700;
  font-size: 0.9rem;
}
.segmented button:hover:not(.is-active) { color: var(--text-main); }
.segmented button.is-active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

/* Comentario en la Isla */
.comentario-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 400px;
}
.comentario-wrap span { display: none; /* Ocultamos la palabra comentario para ahorrar espacio */ }
.comentario-wrap textarea {
  width: 100%;
  height: 42px;
  resize: none;
  background: #f8fafc;
  color: var(--text-main);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.6rem 1.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s;
}
.comentario-wrap textarea:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===========================
   ESTADO API Y ALERTAS
   =========================== */
.mensaje-estado-api {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 700;
  display: none;
  text-align: center;
  animation: slideDown 0.3s ease forwards;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.mensaje-estado-api.is-danger {
  background: #ef4444;
  color: #ffffff;
}
.mensaje-estado-api.is-visible { display: block; }

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===========================
   MODALES + TOAST
   =========================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-content {
  background: #ffffff; color: var(--text-main);
  border: 1px solid rgba(255,255,255,0.2); border-radius: var(--radius-xl);
  width: min(92vw, 420px); padding: 2rem; text-align: center;
  box-shadow: var(--shadow-float);
  animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Modal Warning Cerrado */
.modal-warning {
  background: linear-gradient(to bottom, #ffffff, #fef2f2);
  border: 2px solid #fca5a5;
  max-width: 500px;
}
.modal-title { margin: 0 0 1rem; font-size: 2rem; color: #dc2626; font-weight: 900; letter-spacing: -0.03em; }
.modal-text { font-size: 1.1rem; margin: 0 0 2rem; color: var(--text-main); line-height: 1.6; }
.modal-actions { display: flex; gap: 1rem; justify-content: center; }
.btn-danger {
  background: #ef4444; color: #fff; border: 0; border-radius: 999px;
  padding: 0.8rem 2rem; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); }

/* Toast */
.toast {
  position: fixed; right: 2rem; top: 2rem; bottom: auto; min-width: 260px;
  padding: 1rem 1.5rem; border-radius: 16px; border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255, 255, 255, 0.9); color: var(--text-main); font-weight: 700;
  box-shadow: var(--shadow-float); opacity: 0; transform: translateY(-20px) scale(0.95);
  pointer-events: none; transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 300; backdrop-filter: blur(10px);
}
.toast.is-visible { opacity: 1; transform: translateY(0) scale(1); }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 1200px) {
  .comentario-wrap { max-width: 300px; }
  .header { padding: 1.5rem; }
  .header__title { font-size: 1.8rem; }
}

@media (max-width: 980px) {
  .action-bar { border-radius: var(--radius-lg); padding: 1rem; }
  .action-bar__row { flex-wrap: wrap; justify-content: center; }
  .comentario-wrap { max-width: 100%; width: 100%; order: -1; margin-bottom: 0.5rem; }
  body { padding-bottom: 180px; }
}

@media (max-width: 760px) {
  .header, .content, .action-bar { width: calc(100% - 1.5rem); margin: 0.75rem auto; }
  .tools { flex-direction: column; align-items: stretch; padding: 1rem; }
  .tools__right { justify-content: space-between; }
  .search input { width: 100%; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1; padding: 0.6rem; }
  .btn--primary { width: 100%; padding: 1rem; }
  body { padding-bottom: 220px; }
}
