/* =====================================================
   Portal de rastreo de guias
   =====================================================
   Se carga despues de main.css y main-moderna.css: toma los colores de la
   paleta de la licencia (--tpl-*) y la tipografia de la plantilla. Antes traia
   sus propios colores de Rodamel, y un reinicio global (* { margin: 0 }) con
   fuentes propias que desarmaba la cabecera y el pie compartidos.

   Los colores de los estados (entregada en verde, devuelta en rojo, ...) no
   siguen la marca a proposito: son un codigo que el cliente lee igual en
   cualquier empresa. */

/* HERO Section - Buscador */
#hero-rastreo {
  background: linear-gradient(135deg, #0b1a3a 0%, #12326f 100%);
  background: linear-gradient(135deg,
      color-mix(in srgb, var(--tpl-primario) 88%, #000) 0%,
      var(--tpl-primario) 55%,
      color-mix(in srgb, var(--tpl-primario) 70%, var(--tpl-acento)) 100%);
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* La cabecera es fija y el <main> de esta pagina arranca en cero: el buscador
     reserva su alto ademas del aire propio, para no quedar debajo de ella. */
  padding: calc(var(--header-height) + 64px) 0 80px 0;
  position: relative;
  overflow: hidden;
}

#hero-rastreo::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 10%;
  transform: translate(50%, -50%);
  width: 400px;
  height: 400px;
  border: 3px solid var(--tpl-acento);
  border-radius: 50%;
  opacity: 0.12;
  pointer-events: none;
}

#hero-rastreo h1 {
  font-size: 2.8rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 1rem;
  text-align: center;
}

#hero-rastreo p.subtitle {
  font-weight: 500;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 3rem;
  text-align: center;
}

.search-box {
  background: #fff;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  margin: 0 auto;
}

.search-box label {
  font-weight: 600;
  color: var(--tpl-titulo);
  margin-bottom: 15px;
  display: block;
  font-size: 1.1rem;
}

.search-box input {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid var(--tpl-border);
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--tpl-acento);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--tpl-acento) 18%, transparent);
}

.btn-buscar {
  width: 100%;
  background: var(--tpl-cta);
  color: #fff;
  border: none;
  padding: 15px 40px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-buscar:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.btn-buscar:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Resultado Section */
#resultado {
  padding: 60px 0;
  display: none;
  background: var(--tpl-page);
}

.result-card {
  background: #fff;
  border: 1px solid var(--tpl-border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 10px 40px rgba(9, 30, 66, 0.08);
  max-width: 900px;
  margin: 0 auto;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--tpl-border);
}

.result-header h2 {
  color: var(--tpl-titulo);
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0;
}

.badge-estado {
  padding: 10px 25px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 1rem;
  text-transform: uppercase;
}

.badge-recepcionada { background: #0d6efd; color: white; }
.badge-clasificada { background: #ffc107; color: #333; }
.badge-en_espera { background: var(--tpl-acento); color: white; }
.badge-en_despacho { background: #6f42c1; color: white; }
.badge-entregada { background: #198754; color: white; }
.badge-devuelta, .badge-novedad { background: #dc3545; color: white; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.info-item {
  padding: 15px;
  background: var(--tpl-page);
  border-radius: 10px;
}

.info-item label {
  font-weight: 600;
  color: var(--tpl-titulo);
  font-size: 0.9rem;
  display: block;
  margin-bottom: 5px;
}

.info-item p {
  color: var(--tpl-body);
  margin: 0;
  font-size: 1rem;
}

.historial-section h3 {
  color: var(--tpl-titulo);
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 25px;
}

.timeline {
  position: relative;
  padding-left: 40px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--tpl-acento), var(--tpl-border));
}

.timeline-item {
  position: relative;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--tpl-page);
  border-radius: 10px;
  border-left: 4px solid var(--tpl-acento);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -44px;
  top: 20px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--tpl-acento);
  border: 3px solid #fff;
  box-shadow: 0 0 0 3px var(--tpl-page);
}

.timeline-item .estado {
  font-weight: 700;
  color: var(--tpl-titulo);
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.timeline-item .fecha {
  font-size: 0.85rem;
  color: var(--tpl-muted);
  margin-bottom: 10px;
}

.timeline-item .observacion {
  color: var(--tpl-body);
  font-size: 0.95rem;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #25D366;
  color: white;
  padding: 15px 30px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  margin-top: 30px;
}

.btn-whatsapp:hover {
  background: #128C7E;
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(37, 211, 102, 0.3);
}

.btn-nueva-busqueda {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--tpl-primario);
  color: white;
  padding: 15px 30px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  margin-top: 30px;
  margin-left: 15px;
  border: none;
  cursor: pointer;
}

.btn-nueva-busqueda:hover {
  color: white;
  filter: brightness(1.18);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.error-message {
  text-align: center;
  padding: 40px;
}

.error-message i {
  font-size: 4rem;
  color: var(--tpl-acento);
  margin-bottom: 20px;
}

.error-message h3 {
  color: var(--tpl-titulo);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 15px;
}

.error-message p {
  color: var(--tpl-body);
  font-size: 1.1rem;
}

.spinner {
  border: 4px solid var(--tpl-border);
  border-top: 4px solid var(--tpl-acento);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  #hero-rastreo {
    padding-top: calc(var(--header-height) + 40px);
  }

  #hero-rastreo h1 {
    font-size: 2rem;
  }

  #hero-rastreo p.subtitle {
    font-size: 1rem;
  }

  .search-box {
    padding: 30px 20px;
  }

  .result-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .btn-whatsapp, .btn-nueva-busqueda {
    width: 100%;
    margin-left: 0;
    margin-top: 15px;
  }
}
