/* --- Sistema de Estilos: Tech Editorial --- */
:root {
  /* Modo Oscuro (Predeterminado) */
  --bg-main: #05070f;       /* Fondo azul noche muy oscuro y premium */
  --bg-card: #0d111d;       /* Azul grisáceo oscuro */
  --border-color: #1e293b;  /* Slate 800 */
  
  --text-primary: #f8fafc;  /* Slate 50 */
  --text-secondary: #94a3b8;/* Slate 400 */
  --text-muted: #475569;     /* Slate 600 */
  
  --accent: #8842d5;        /* Violeta vibrante para Modo Oscuro */
  --accent-rgb: 136, 66, 213;
  
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  
  --danger: #ef4444;
  --danger-rgb: 239, 68, 68;
  
  --warning: #eab308;
  --warning-rgb: 234, 179, 8;

  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-sans: 'Inter', sans-serif;
  --font-display: 'Plus Jakarta Sans', sans-serif;
  
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Modo Claro */
.light-mode {
  --bg-main: #f8fafc;       /* Slate 50 - Fondo limpio y brillante */
  --bg-card: #ffffff;       /* Fondo blanco puro para cartas */
  --border-color: #e2e8f0;  /* Slate 200 */
  
  --text-primary: #0f172a;  /* Slate 900 */
  --text-secondary: #475569;/* Slate 600 */
  --text-muted: #94a3b8;     /* Slate 400 */
  
  --accent: #5b2b82;        /* Violeta Corporativo de OCA */
  --accent-rgb: 91, 43, 130;

  --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.04), 0 8px 10px -6px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.01);
}

/* --- Reseteo e Inicialización --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  display: flex;
  justify-content: center;
  padding: 0;
}

/* --- Contenedor Principal (Estilo Editorial) --- */
.editorial-container {
  width: 100%;
  max-width: 900px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2.5rem 1.5rem;
  margin: 0 auto;
}

/* --- Header Minimalista --- */
.editorial-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 3.5rem;
}

.logo-group {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-display);
}

.logo-main {
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -1px;
  color: var(--accent);
}

.logo-sub {
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

/* Botón de Tema Minimalista */
.btn-theme-minimal {
  background: transparent;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.btn-theme-minimal:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* Controlar textos del botón en base al tema */
.theme-label-light { display: none; }
.light-mode .theme-label-dark { display: none; }
.light-mode .theme-label-light { display: inline; }

/* --- Main Layout --- */
.editorial-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

/* --- Sección Intro / Buscador --- */
.intro-section {
  display: flex;
  flex-direction: column;
  max-width: 600px;
}

.editorial-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.75rem;
  letter-spacing: -1.5px;
  line-height: 1.05;
  margin-bottom: 0.75rem;
}

.editorial-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: 2rem;
}

/* Formulario de búsqueda (Estilo Input Consolidado) */
.editorial-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

@media(min-width: 540px) {
  .editorial-form {
    flex-direction: row;
    gap: 0px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    transition: var(--transition-fast);
  }
  
  .editorial-form:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
  }
}

.input-container {
  flex-grow: 1;
}

#tracking-input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 400;
  outline: none;
  font-family: var(--font-sans);
  transition: var(--transition-fast);
}

@media(min-width: 540px) {
  #tracking-input {
    border: none;
    border-radius: 0;
  }
}

#tracking-input::placeholder {
  color: var(--text-muted);
}

/* Botón de Enviar */
.btn-editorial-submit {
  background: var(--text-primary);
  color: var(--bg-main);
  border: 1px solid var(--text-primary);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
}

@media(min-width: 540px) {
  .btn-editorial-submit {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    border: none;
    border-left: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
  }
  
  .btn-editorial-submit:hover {
    background: var(--text-primary);
    color: var(--bg-main);
  }
}

.arrow-svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.btn-editorial-submit:hover .arrow-svg {
  transform: translateX(3px);
}

/* Accesos rápidos */
.editorial-shortcuts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.shortcut-label {
  color: var(--text-muted);
}

.btn-shortcut-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  padding: 2px 0;
}

.btn-shortcut-text:hover {
  color: var(--accent);
  text-decoration: underline;
}

.separator {
  color: var(--text-muted);
}

/* --- Paneles del Resultado (Tech Grid) --- */
.editorial-results {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  animation: fadeIn var(--transition-fast) forwards;
}

.hidden {
  display: none !important;
}

/* Tarjeta Principal de Estado */
.editorial-status-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.status-main-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.status-meta-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 6px;
}

.status-pill-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: var(--transition-fast);
}

.status-pill-badge.transito {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
}

.status-pill-badge.entregado {
  background: rgba(var(--success-rgb), 0.08);
  color: var(--success);
  border: 1px solid rgba(var(--success-rgb), 0.18);
}

.status-pill-badge.alerta {
  background: rgba(var(--danger-rgb), 0.08);
  color: var(--danger);
  border: 1px solid rgba(var(--danger-rgb), 0.18);
}

.status-pill-badge.preparando {
  background: rgba(var(--warning-rgb), 0.08);
  color: var(--warning);
  border: 1px solid rgba(var(--warning-rgb), 0.18);
}

.status-summary-info {
  display: flex;
  flex-direction: column;
}

.editorial-meta-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

#current-status-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 2px 0 6px 0;
}

#current-status-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Detalles Técnicos */
.status-tech-details {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

@media(min-width: 600px) {
  .status-tech-details {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tech-meta-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tech-meta-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.tech-meta-value {
  font-size: 0.9rem;
  font-weight: 500;
}

.mono-text {
  font-family: var(--font-mono);
}

/* --- Panel de Historial (Estilo Reporte / Logs) --- */
.editorial-history-panel {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.panel-section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* Contenedor de registros */
.logs-container {
  display: flex;
  flex-direction: column;
}

.log-row {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.5rem;
  transition: background-color var(--transition-fast);
}

.log-row:last-child {
  border-bottom: none;
}

.log-row:hover {
  background-color: rgba(255, 255, 255, 0.015);
}

.light-mode .log-row:hover {
  background-color: rgba(0, 0, 0, 0.015);
}

.log-timeline-node {
  display: none;
}

@media(min-width: 640px) {
  .log-row {
    display: grid;
    grid-template-columns: 155px 40px 1fr;
    gap: 0;
    align-items: start;
  }

  .log-timeline-node {
    display: flex;
    justify-content: center;
    align-items: start;
    height: 100%;
    min-height: 48px;
    position: relative;
    padding-top: 5px;
  }

  .log-timeline-node::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: -1.25rem; /* Extender la línea de tiempo a la siguiente celda */
    left: 50%;
    width: 2px;
    background: var(--border-color);
    transform: translateX(-50%);
    z-index: 1;
  }

  .log-row:last-child .log-timeline-node::before {
    bottom: auto;
    height: 12px; /* Detener la línea en el último elemento */
  }
}

/* Columna Fecha */
.log-date {
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: var(--text-secondary);
}

/* Columna Evento */
.log-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}

.log-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid var(--bg-card);
  z-index: 2;
  position: relative;
}

.log-row.active .log-status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.log-row.delivered .log-status-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(var(--success-rgb), 0.15);
}

.log-row.failed .log-status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(var(--danger-rgb), 0.15);
}

.log-event-text {
  font-size: 0.925rem;
  font-weight: 600;
}

.log-comment {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding-left: 0.8rem;
  border-left: 1px solid var(--border-color);
  margin-top: 4px;
}

.log-sucursal-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  background: rgba(var(--text-secondary-rgb, 148, 163, 184), 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  flex-shrink: 0;
}

/* --- Error Card --- */
.editorial-error-card {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
}

.error-badge {
  display: inline-block;
  background: rgba(var(--danger-rgb), 0.1);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  letter-spacing: 1px;
}

.editorial-error-card h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.editorial-error-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 380px;
  margin: 0 auto;
}

/* --- Skeletons (Tech Shimmer) --- */
.shimmer-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.shimmer-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shimmer-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.shimmer-block {
  background: linear-gradient(90deg, var(--border-color) 25%, rgba(255, 255, 255, 0.03) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

.light-mode .shimmer-block {
  background: linear-gradient(90deg, var(--border-color) 25%, rgba(0, 0, 0, 0.02) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
}

.w-40 { width: 40%; }
.w-20 { width: 20%; }
.w-60 { width: 60%; }
.h-8 { height: 28px; }
.h-4 { height: 14px; }

/* --- Footer Editorial --- */
.editorial-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  margin-top: 4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --- Animaciones --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
