/* ========================================
   Castor Bezerra - Pagina de rastreio da entrega
   Fase 2 do redesign. Depende de design-tokens.css.
   Zero marrom, zero gradiente dourado-vermelho — tudo azul + dourado via tokens.
   ======================================== */

body {
    background: var(--cor-fundo);
    font-family: var(--fonte-texto);
    color: var(--cor-tinta);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
}

* { box-sizing: border-box; }

/* Container */
.zr-container {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--esp-7) var(--esp-5) var(--esp-8);
}

/* Logo */
.zr-logo {
    text-align: center;
    margin-bottom: var(--esp-6);
    background: var(--cor-azul-escuro);
    padding: var(--esp-5) var(--esp-5);
    border-radius: var(--raio-lg);
    position: relative;
    overflow: hidden;
}
.zr-logo::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(242,183,5,0.06) 0%, transparent 50%);
    pointer-events: none;
}

.zr-logo-img {
    max-width: 230px;
    height: auto;
}

/* Saudacao */
.zr-greeting {
    text-align: center;
    color: var(--cor-tinta-media);
    font-size: 15px;
    font-weight: 500;
    margin-bottom: var(--esp-5);
    animation: zrFadeIn 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Card principal */
.zr-card {
    background: var(--cor-superficie);
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio-lg);
    padding: var(--esp-6);
    box-shadow: var(--sombra-1);
    margin-bottom: var(--esp-5);
    animation: zrFadeIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* ===== FORMULARIO DE BUSCA ===== */

.zr-title {
    font-family: var(--fonte-titulo);
    font-size: 26px;
    font-weight: 700;
    color: var(--cor-azul-escuro);
    margin: 0 0 var(--esp-2) 0;
    text-align: center;
    line-height: 1.2;
}

.zr-subtitle {
    color: var(--cor-tinta-media);
    text-align: center;
    margin: 0 0 var(--esp-6) 0;
    font-size: 15px;
}

.zr-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--cor-tinta);
    margin-bottom: var(--esp-2);
}

.zr-input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio-md);
    font-size: 16px;
    font-family: inherit;
    color: var(--cor-tinta);
    background: var(--cor-superficie);
    transition: border-color 160ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.zr-input-group input::placeholder {
    color: var(--cor-tinta-leve);
}

.zr-input-group input:hover {
    border-color: var(--cor-borda-forte);
}
.zr-input-group input:focus {
    outline: none;
    border-color: var(--cor-azul);
    box-shadow: var(--sombra-foco);
}

.zr-btn {
    width: 100%;
    padding: 14px;
    background: var(--cor-azul-escuro);
    color: #fff;
    border: none;
    border-radius: var(--raio-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.zr-btn:hover {
    background: var(--cor-azul);
}
.zr-btn:active {
    transform: translateY(1px);
}
.zr-btn:focus-visible {
    outline: none;
    box-shadow: var(--sombra-foco);
}

/* Erro */
.zr-error {
    background: var(--cor-erro-fundo);
    border-left: 3px solid var(--cor-erro);
    color: var(--cor-erro);
    padding: var(--esp-4) var(--esp-5);
    border-radius: var(--raio-sm);
    margin-bottom: var(--esp-5);
    font-size: 14px;
    font-weight: 500;
}

/* ===== RESULTADO - HEADER ===== */

.zr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--esp-6);
    padding-bottom: var(--esp-5);
    border-bottom: 1px solid var(--cor-borda);
    gap: var(--esp-4);
}

.zr-order-num {
    font-family: var(--fonte-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--cor-azul-escuro);
    letter-spacing: 0.03em;
}

.zr-badge {
    padding: 6px 14px;
    border-radius: var(--raio-pill);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.zr-badge.transito  { background: var(--cor-atencao-fundo); color: var(--cor-atencao); }
.zr-badge.entregue  { background: var(--cor-sucesso-fundo); color: var(--cor-sucesso); }
.zr-badge.atrasado  { background: var(--cor-erro-fundo);    color: var(--cor-erro); }
.zr-badge.devolvido { background: var(--cor-info-fundo);    color: var(--cor-azul-escuro); }
.zr-badge.preparando { background: var(--cor-info-fundo);   color: var(--cor-azul-escuro); }

/* ===== INDICADOR DE ETAPAS (stepper horizontal 4 nós) ===== */

.zr-steps {
    display: flex;
    align-items: flex-start;
    margin-bottom: var(--esp-6);
}

.zr-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.zr-step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--cor-superficie);
    border: 1.5px solid var(--cor-borda-forte);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 160ms cubic-bezier(0.4, 0, 0.2, 1), border-color 160ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.zr-step.done .zr-step-circle {
    background: var(--cor-sucesso);
    border-color: var(--cor-sucesso);
}

.zr-step.active .zr-step-circle {
    border-color: var(--cor-azul);
    background: var(--cor-superficie);
    /* Nao pulsa — o unico pulse ativo e o do evento atual na timeline. */
}

.zr-step-dot {
    width: 10px;
    height: 10px;
    background: var(--cor-azul);
    border-radius: 50%;
}

.zr-step-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--cor-tinta-leve);
    margin-top: var(--esp-2);
    text-align: center;
    white-space: nowrap;
}

.zr-step.done .zr-step-label {
    color: var(--cor-sucesso);
}

.zr-step.active .zr-step-label {
    color: var(--cor-azul-escuro);
    font-weight: 600;
}

.zr-step.done .zr-step-circle {
    box-shadow: 0 2px 6px rgba(15, 123, 92, 0.2);
}

.zr-step.active .zr-step-circle {
    box-shadow: 0 0 0 4px rgba(26, 86, 201, 0.1);
}

.zr-step-line {
    flex: 1;
    height: 2px;
    background: var(--cor-borda);
    margin-top: 15px; /* metade do circulo */
    border-radius: 1px;
    min-width: 20px;
    transition: background 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.zr-step-line.filled {
    background: var(--cor-sucesso);
}

/* ===== CARD DE ENTREGA ===== */

.zr-delivery {
    background: linear-gradient(135deg, var(--cor-azul-escuro) 0%, var(--cor-azul-fundo) 100%);
    padding: var(--esp-6);
    border-radius: var(--raio-lg);
    color: #fff;
    margin-bottom: var(--esp-5);
    position: relative;
    overflow: hidden;
    animation: zrSlideUp 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: 100ms;
}
.zr-delivery::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(242,183,5,0.07) 0%, transparent 70%);
    pointer-events: none;
}

.zr-delivery-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--esp-4);
    gap: var(--esp-4);
}

.zr-delivery-label {
    font-size: 12px;
    opacity: 0.75;
    margin-bottom: var(--esp-1);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.zr-delivery-date {
    font-family: var(--fonte-titulo);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
}

.zr-delivery-weekday {
    font-size: 13px;
    opacity: 0.7;
    margin-top: var(--esp-1);
    font-weight: 500;
}

.zr-delivery-icon {
    opacity: 0.18;
    flex-shrink: 0;
}

.zr-delivery-address {
    display: flex;
    align-items: flex-start;
    gap: var(--esp-3);
    font-size: 14px;
    opacity: 0.85;
    padding-top: var(--esp-4);
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    line-height: 1.5;
}

.zr-delivery-address svg {
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 0.75;
}

/* ===== ALERTA DE ATRASO ===== */

.zr-delay-alert,
.zr-preparing-alert {
    background: var(--cor-atencao-fundo);
    border-left: 3px solid var(--cor-atencao);
    padding: var(--esp-4) var(--esp-5);
    border-radius: var(--raio-sm);
    margin-bottom: var(--esp-5);
    color: var(--cor-atencao);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--esp-3);
    line-height: 1.5;
}
.zr-preparing-alert {
    background: var(--cor-info-fundo);
    border-left-color: var(--cor-azul-escuro);
    color: var(--cor-azul-escuro);
}

.zr-delay-alert svg {
    flex-shrink: 0;
}

/* ===== INFO DO PRODUTO ===== */

.zr-product-info {
    background: var(--cor-fundo);
    border: 1px solid var(--cor-borda);
    border-radius: var(--raio-md);
    padding: var(--esp-4) var(--esp-5);
    margin-bottom: var(--esp-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--esp-4);
    flex-wrap: wrap;
}

.zr-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cor-azul-escuro);
}

.zr-product-details {
    font-size: 13px;
    color: var(--cor-tinta-media);
    display: flex;
    gap: var(--esp-4);
    flex-wrap: wrap;
}

.zr-product-detail {
    white-space: nowrap;
}

/* ===== TIMELINE DE EVENTOS ===== */

.zr-timeline-title {
    font-family: var(--fonte-titulo);
    font-size: 17px;
    font-weight: 700;
    color: var(--cor-azul-escuro);
    margin: 0 0 var(--esp-5) 0;
}

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

.zr-timeline::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--cor-borda);
    border-radius: 1px;
}

.zr-event {
    position: relative;
    margin-bottom: var(--esp-6);
    padding: 4px 0;
    animation: zrSlideUp 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.zr-event:nth-child(1) { animation-delay: 60ms; }
.zr-event:nth-child(2) { animation-delay: 120ms; }
.zr-event:nth-child(3) { animation-delay: 180ms; }
.zr-event:nth-child(4) { animation-delay: 240ms; }
.zr-event:nth-child(5) { animation-delay: 300ms; }
.zr-event:nth-child(6) { animation-delay: 360ms; }
.zr-event:nth-child(n+7) { animation-delay: 400ms; }

.zr-event:last-child {
    margin-bottom: 0;
}

/* Icone do evento */
.zr-event-icon {
    position: absolute;
    left: -45px;
    top: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cor-superficie);
    border: 1.5px solid var(--cor-borda-forte);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 160ms cubic-bezier(0.4, 0, 0.2, 1), background 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Status: concluido */
.zr-event.done .zr-event-icon {
    border-color: var(--cor-sucesso);
    background: var(--cor-sucesso);
}

.zr-event.done .zr-event-icon::after {
    content: '';
    width: 12px;
    height: 9px;
    background: center/contain no-repeat;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='m5 12 5 5 9-10'/></svg>");
}

/* Status: ativo */
.zr-event.active {
    background: var(--cor-info-fundo);
    margin-left: -16px;
    margin-right: -16px;
    padding: var(--esp-4);
    border-radius: var(--raio-md);
}

.zr-event.active .zr-event-icon {
    left: -29px;
    border-color: var(--cor-azul);
    background: var(--cor-superficie);
    animation: zrEventPulse 2s infinite;
}

.zr-event.active .zr-event-icon::after {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--cor-azul);
    border-radius: 50%;
}

@keyframes zrEventPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(26, 86, 201, 0.35); }
    70% { box-shadow: 0 0 0 10px rgba(26, 86, 201, 0); }
}

/* Status: atraso */
.zr-event.status-atraso .zr-event-icon {
    border-color: var(--cor-atencao);
    background: var(--cor-atencao-fundo);
}

.zr-event.status-atraso .zr-event-icon::after {
    content: '!';
    color: var(--cor-atencao);
    font-size: 17px;
    font-weight: 800;
}

.zr-event.status-atraso .zr-event-desc { color: var(--cor-atencao); }

/* Status: saiu para entrega */
.zr-event.status-saiu_entrega .zr-event-icon {
    border-color: var(--cor-sucesso);
    background: var(--cor-sucesso-fundo);
}

.zr-event.status-saiu_entrega .zr-event-icon::after {
    content: '';
    width: 12px;
    height: 12px;
    background: center/contain no-repeat;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230F7B5C' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h14'/><path d='m13 6 6 6-6 6'/></svg>");
}

/* Status: tentativa falha */
.zr-event.status-tentativa_falha .zr-event-icon {
    border-color: var(--cor-erro);
    background: var(--cor-erro-fundo);
}

.zr-event.status-tentativa_falha .zr-event-icon::after {
    content: '';
    width: 12px;
    height: 12px;
    background: center/contain no-repeat;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B4292A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 6 18 18'/><path d='M18 6 6 18'/></svg>");
}

.zr-event.status-tentativa_falha .zr-event-desc { color: var(--cor-erro); }

/* Status: devolvido */
.zr-event.status-devolvido .zr-event-icon {
    border-color: var(--cor-tinta-media);
    background: var(--cor-fundo);
}

.zr-event.status-devolvido .zr-event-icon::after {
    content: '';
    width: 12px;
    height: 12px;
    background: center/contain no-repeat;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F5D7A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M20 12a8 8 0 1 1-2.3-5.6'/><path d='M20 4v4h-4'/></svg>");
}

.zr-event.status-devolvido .zr-event-desc { color: var(--cor-tinta-media); }

/* Textos do evento */
.zr-event-desc {
    font-size: 15px;
    font-weight: 600;
    color: var(--cor-azul-escuro);
    margin-bottom: var(--esp-1);
    line-height: 1.4;
}

.zr-event-location {
    font-size: 13px;
    color: var(--cor-tinta-media);
    margin-bottom: 2px;
}

.zr-event-date {
    font-size: 13px;
    color: var(--cor-tinta-leve);
    font-family: var(--fonte-mono);
}

.zr-event-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: var(--raio-pill);
    font-size: 11px;
    font-weight: 600;
    background: var(--cor-info-fundo);
    color: var(--cor-azul-escuro);
    margin-top: var(--esp-2);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* ===== LINK VOLTAR (sem gradiente, link simples) ===== */

.zr-back {
    text-align: center;
    margin-top: var(--esp-5);
}

.zr-back a {
    color: var(--cor-azul);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: var(--esp-2) var(--esp-4);
    transition: color 160ms cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: var(--esp-2);
}

.zr-back a:hover {
    color: var(--cor-azul-escuro);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.zr-back a .ic {
    transition: transform 160ms cubic-bezier(0.4, 0, 0.2, 1);
}
.zr-back a:hover .ic {
    transform: rotate(180deg) translateX(3px);
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .zr-card,
    .zr-delivery,
    .zr-event,
    .zr-step-circle,
    .zr-step-line,
    .zr-event-icon {
        animation: none !important;
        transition: none !important;
    }
    .zr-event.active .zr-event-icon {
        animation: none !important;
        box-shadow: 0 0 0 3px rgba(26, 86, 201, 0.2);
    }
}

/* ===== RESPONSIVO ===== */

@media (max-width: 640px) {
    .zr-container {
        padding: var(--esp-5) var(--esp-4) var(--esp-7);
    }

    .zr-card {
        padding: var(--esp-5) var(--esp-4);
        border-radius: var(--raio-md);
    }

    .zr-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--esp-3);
    }

    .zr-order-num {
        font-size: 18px;
    }

    .zr-delivery {
        padding: var(--esp-5) var(--esp-4);
    }

    .zr-delivery-date {
        font-size: 24px;
    }

    .zr-delivery-icon {
        display: none;
    }

    .zr-step-circle {
        width: 28px;
        height: 28px;
    }

    .zr-step-dot {
        width: 8px;
        height: 8px;
    }

    .zr-step-label {
        font-size: 10px;
    }

    .zr-step-line {
        margin-top: 13px;
        min-width: 12px;
    }

    .zr-product-info {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--esp-2);
    }

    .zr-timeline {
        padding-left: 50px;
    }

    .zr-event.active {
        margin-left: -12px;
        margin-right: -12px;
        padding: var(--esp-3);
    }

    .zr-event.active .zr-event-icon {
        left: -27px;
    }
}
