/* ==========================================================
   RASTREA TU ENVÍO
   Campo de número de guía en el header + ventana emergente.
   Reutiliza la paleta y tipografía del sitio: rojo #ff3131,
   azul del header rgba(22,34,57,0.95), azul de secciones
   #172238, campos translúcidos rgba(250,250,250,0.1) y botones
   en mayúsculas 13px / 700 como los formularios existentes.
   La lógica está en assets/js/rastreo-envio.js
   ========================================================== */


/* ---------- Campo del header ---------- */

/* Va flotado a la derecha, a la derecha del menú principal */
.rastreo-header {
    float: right;
    display: flex;
    align-items: center;
    height: 80px;
    margin: 0 60px 0 0;
}

.rastreo-header input {
    width: 180px;
    height: 40px;
    padding: 0 12px;
    background-color: rgba(250,250,250,0.1);
    border: 1px solid rgba(250,250,250,0.25);
    border-right: none;
    border-radius: 0;
    color: #fff;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.rastreo-header input::placeholder {
    color: rgba(255,255,255,0.75);
}

.rastreo-header button {
    height: 40px;
    padding: 0 18px;
    background-color: #ff3131;
    border: none;
    border-radius: 0;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.rastreo-header button:hover {
    background-color: #e02a2a;
}

/* El ícono del camión solo se usa cuando el botón queda sin texto */
.rastreo-header button .fa {
    display: none;
}

/* El menú del escritorio se acerca al campo (antes tenía 60px de margen derecho) */
@media screen and (min-width: 951px) {
  .main-header .main-menu {
    padding-right: 20px;
  }
}

/* Portátiles (hasta 1359px): campo más corto y menos margen derecho */
@media screen and (max-width: 1359px) {
  .rastreo-header {
    margin-right: 30px;
  }
  .rastreo-header input {
    width: 145px;
  }
  .rastreo-header button {
    padding: 0 14px;
  }
}

/* Hasta 1279px ya no cabe el campo junto al menú: queda solo un botón
   cuadrado con ícono, y el número se escribe en la ventana emergente */
@media screen and (max-width: 1279px) {
  .rastreo-header {
    margin-right: 20px;
  }
  .rastreo-header input,
  .rastreo-header button span {
    display: none;
  }
  .rastreo-header button {
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 18px;
  }
  .rastreo-header button .fa {
    display: inline-block;
  }
}

/* La plantilla fija padding-right: 30px !important en <=1050px, por eso
   aquí también se necesita !important para acercar el menú al botón */
@media screen and (min-width: 951px) and (max-width: 1279px) {
  .main-header .main-menu {
    padding-right: 10px !important;
  }
}

/* Entre 951px y 1100px el menú completo apenas cabe: se reduce un poco el
   espacio interno de los enlaces (no afecta al submenú) */
@media screen and (min-width: 951px) and (max-width: 1100px) {
  .main-header .main-menu li a {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* Celulares y tablets: el botón queda a la izquierda del menú hamburguesa.
   El padding lo alinea verticalmente con el ícono de las tres rayas */
@media screen and (max-width: 950px) {
  .rastreo-header {
    margin-right: 12px;
    padding-top: 4px;
  }
}

@media screen and (max-width: 480px) {
  .rastreo-header {
    margin-right: 10px;
    padding-top: 0;
    padding-bottom: 6px;
  }
  .rastreo-header button {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
}


/* ---------- Foco visible (teclado) ---------- */

.rastreo-header input:focus,
.rastreo-modal input:focus {
    outline: 2px solid #FC3;
    outline-offset: 0;
}

.rastreo-header button:focus-visible,
.rastreo-modal button:focus-visible,
.rastreo-modal a:focus-visible {
    outline: 2px solid #FC3;
    outline-offset: 2px;
}

/* Bootstrap 4 pinta un contorno también al hacer clic con el ratón;
   en estos botones solo se muestra al navegar con el teclado */
.rastreo-header button:focus:not(:focus-visible),
.rastreo-modal button:focus:not(:focus-visible) {
    outline: none;
}


/* ---------- Ventana emergente ---------- */

/* <dialog> nativo: el navegador lo centra y lo muestra por encima de todo */
.rastreo-modal {
    width: 520px;
    max-width: calc(100% - 32px);
    max-height: none;
    padding: 0;
    border: none;
    background: transparent;
    color: #fff;
    overflow: visible;
}

/* Fondo oscuro detrás de la ventana: al hacer clic aquí se cierra */
.rastreo-modal::backdrop {
    background-color: rgba(12,18,40,0.85);
}

.rastreo-modal[open] {
    animation: rastreo-aparecer 0.25s ease-out;
}

@keyframes rastreo-aparecer {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
  .rastreo-modal[open] {
    animation: none;
  }
}

/* El scroll va en el contenido (no en el <dialog>) para que un clic en
   la barra de desplazamiento no se confunda con un clic fuera */
.rastreo-modal-contenido {
    position: relative;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 45px 40px 40px 40px;
    background-color: #172238;
    border-top: 4px solid #ff3131;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
}

.rastreo-modal-cerrar {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.3s;
}

.rastreo-modal-cerrar:hover {
    color: #ff3131;
}

.rastreo-modal h2 {
    margin: 0 0 10px 0;
    padding-right: 30px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
}

.rastreo-modal h2 em {
    font-style: normal;
    color: #ff3131;
}

.rastreo-modal-intro {
    margin-bottom: 25px;
    color: rgba(255,255,255,0.8);
}

.rastreo-modal label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rastreo-modal input {
    width: 100%;
    height: 44px;
    padding: 0 15px;
    background-color: rgba(250,250,250,0.1);
    border: 1px solid rgba(250,250,250,0.25);
    border-radius: 0;
    color: #fff;
    font-size: 15px;
    letter-spacing: 0.5px;
}

.rastreo-modal input::placeholder {
    color: rgba(255,255,255,0.6);
}

.rastreo-modal input[aria-invalid="true"] {
    border-color: #ff3131;
}

/* Rojo más claro que #ff3131 para que el texto se lea bien sobre el azul */
.rastreo-modal-error {
    margin: 8px 0 0 0;
    color: #ff6b6b;
    font-weight: 600;
}

.rastreo-modal-error:empty {
    margin: 0;
}

.rastreo-modal-consultar {
    width: 100%;
    height: 46px;
    margin-top: 20px;
    background-color: #ff3131;
    border: none;
    border-radius: 0;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.rastreo-modal-consultar:hover {
    background-color: #e02a2a;
}

/* Área donde se mostrarán los resultados de PEGASUS ERP */
.rastreo-modal-resultado {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid rgba(250,250,250,0.1);
}

.rastreo-mensaje {
    margin: 0;
    padding: 15px 18px;
}

.rastreo-mensaje.vacio {
    border: 1px dashed rgba(250,250,250,0.2);
    color: rgba(255,255,255,0.6);
    text-align: center;
}

.rastreo-mensaje.info {
    background-color: rgba(255,204,51,0.08);
    border-left: 3px solid #FC3;
    color: #fff;
}


/* ---------- Ficha de la guía (respuesta de PEGASUS ERP) ---------- */

/* Con la ficha a la vista la ventana se ensancha, para que el cumplido
   de entrega (foto o PDF) se lea bien */
.rastreo-modal.con-ficha {
    width: 720px;
}

.rastreo-ficha-datos {
    display: grid;
    grid-template-columns: minmax(140px, 35%) 1fr;
    margin: 0;
}

.rastreo-ficha-datos dt,
.rastreo-ficha-datos dd {
    margin: 0;
    padding: 12px 0;
    border-bottom: 1px solid rgba(250,250,250,0.1);
    overflow-wrap: anywhere;
}

.rastreo-ficha-datos dt {
    padding-right: 15px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rastreo-ficha-datos dd {
    color: #fff;
    font-size: 15px;
}

/* El estado es lo primero que busca el cliente */
.rastreo-ficha-datos .rastreo-ficha-estado {
    color: #FC3;
    font-size: 18px;
    font-weight: 800;
}

.rastreo-ficha h3 {
    margin: 30px 0 15px 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
}

.rastreo-sin-dato {
    margin: 0;
    color: rgba(255,255,255,0.6);
    font-style: italic;
}

/* Novedades: línea de tiempo, de la más reciente a la más antigua */
.rastreo-novedades li {
    position: relative;
    padding: 0 0 20px 22px;
    border-left: 2px solid rgba(250,250,250,0.15);
}

.rastreo-novedades li:last-child {
    padding-bottom: 0;
}

.rastreo-novedades li::before {
    content: '';
    position: absolute;
    top: 6px;
    left: -6px;
    width: 10px;
    height: 10px;
    background-color: #ff3131;
    border-radius: 50%;
}

.rastreo-novedad-tipo {
    margin: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.rastreo-novedad-estado {
    display: inline-block;
    margin-left: 8px;
    padding: 0 8px;
    border: 1px solid rgba(250,250,250,0.3);
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    line-height: 18px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: 1px;
}

/* Abierta: todavía afecta la entrega */
.rastreo-novedad-estado.abierta {
    border-color: #FC3;
    color: #FC3;
}

/* La escribe una persona: se respetan sus saltos de línea */
.rastreo-novedad-descripcion {
    margin: 4px 0 0 0;
    color: rgba(255,255,255,0.85);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.rastreo-novedades small {
    display: block;
    margin-top: 4px;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
}

/* Cumplido: fondo blanco por si la foto o el PDF tienen transparencias */
.rastreo-cumplido img,
.rastreo-cumplido iframe {
    display: block;
    width: 100%;
    background-color: #fff;
}

.rastreo-cumplido iframe {
    height: 60vh;
    min-height: 360px;
    border: 0;
}

.rastreo-cumplido-abrir {
    display: inline-block;
    margin-top: 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* En celulares el PDF no se muestra dentro de la ventana y el enlace
   queda solo */
.rastreo-cumplido-abrir:first-child {
    margin-top: 0;
}

.rastreo-cumplido-repetir {
    height: 40px;
    margin-top: 12px;
    padding: 0 18px;
    background-color: transparent;
    border: 1px solid #ff3131;
    border-radius: 0;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.rastreo-cumplido-repetir:hover {
    background-color: #ff3131;
}

@media screen and (max-width: 480px) {
  .rastreo-modal-contenido {
    padding: 40px 20px 25px 20px;
  }
  .rastreo-modal h2 {
    font-size: 18px;
  }
  /* Nombre del dato arriba y valor abajo */
  .rastreo-ficha-datos {
    grid-template-columns: 1fr;
  }
  .rastreo-ficha-datos dt {
    padding-bottom: 0;
    border-bottom: 0;
  }
  .rastreo-ficha-datos dd {
    padding-top: 4px;
  }
}
