/**
 * 3PL Track & Trace - Custom CSS
 * Supplements Tailwind with custom animations and styles
 */

/* ===== Custom Navy colors (not in Tailwind default) ===== */
.from-navy-950 { --tw-gradient-from: #091629; }
.to-navy-800   { --tw-gradient-to:   #1e3a5f; }
.bg-navy-950   { background-color: #091629; }
.bg-navy-800   { background-color: #1e3a5f; }
.border-navy-800 { border-color: #1e3a5f; }

/* ===== HERO SECTION ===== */
.hero-section {
    background: linear-gradient(135deg, #091629 0%, #0f2240 40%, #0c4a6e 80%, #0e7490 100%);
    position: relative;
}

/* ===== ANIMATED BACKGROUND (floating packages/dots) ===== */
.hero-bg-animation {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.float-element {
    position: absolute;
    color: rgba(255, 255, 255, 0.04);
    animation: float-up linear infinite;
    font-size: 1.5rem;
}

/* Individual element positions & sizes & delays */
.float-element-1  { left: 5%;   bottom: -40px; font-size: 1.2rem; animation-duration: 12s; animation-delay: 0s; }
.float-element-2  { left: 12%;  bottom: -40px; font-size: 2rem;   animation-duration: 16s; animation-delay: 2s; }
.float-element-3  { left: 22%;  bottom: -40px; font-size: 1rem;   animation-duration: 11s; animation-delay: 4s; }
.float-element-4  { left: 33%;  bottom: -40px; font-size: 1.8rem; animation-duration: 14s; animation-delay: 1s; }
.float-element-5  { left: 44%;  bottom: -40px; font-size: 1.3rem; animation-duration: 13s; animation-delay: 3s; }
.float-element-6  { left: 55%;  bottom: -40px; font-size: 2.2rem; animation-duration: 18s; animation-delay: 5s; }
.float-element-7  { left: 63%;  bottom: -40px; font-size: 0.9rem; animation-duration: 10s; animation-delay: 0.5s; }
.float-element-8  { left: 72%;  bottom: -40px; font-size: 1.6rem; animation-duration: 15s; animation-delay: 2.5s; }
.float-element-9  { left: 81%;  bottom: -40px; font-size: 1.1rem; animation-duration: 12s; animation-delay: 6s; }
.float-element-10 { left: 90%;  bottom: -40px; font-size: 1.9rem; animation-duration: 17s; animation-delay: 1.5s; }
.float-element-11 { left: 8%;   bottom: -40px; font-size: 2.5rem; animation-duration: 20s; animation-delay: 7s; }
.float-element-12 { left: 28%;  bottom: -40px; font-size: 0.8rem; animation-duration: 9s;  animation-delay: 3.5s; }
.float-element-13 { left: 48%;  bottom: -40px; font-size: 2rem;   animation-duration: 16s; animation-delay: 8s; }
.float-element-14 { left: 68%;  bottom: -40px; font-size: 1.4rem; animation-duration: 13s; animation-delay: 4.5s; }
.float-element-15 { left: 88%;  bottom: -40px; font-size: 1.7rem; animation-duration: 15s; animation-delay: 0.8s; }

@keyframes float-up {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(-600px) rotate(360deg);
        opacity: 0;
    }
}

/* ===== Timeline styles ===== */
.timeline-container {
    position: relative;
}

.timeline-line {
    position: absolute;
    left: 18px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #0ea5e9, #e5e7eb);
}

.timeline-item {
    position: relative;
    padding-left: 50px;
    padding-bottom: 1.5rem;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: 8px;
    top: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 2px currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.timeline-dot.active {
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 2px currentColor; }
    50%       { box-shadow: 0 0 0 6px rgba(14, 165, 233, 0.3); }
}

/* ===== Tracking number textarea ===== */
#tracking-textarea {
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.04em;
    line-height: 1.7;
}

/* ===== Status badge animation ===== */
.status-pulse {
    animation: status-fade-in 0.4s ease-out;
}

@keyframes status-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Card hover effects ===== */
.order-card {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.order-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(14, 165, 233, 0.08);
}

/* ===== Button micro-interactions ===== */
button, a[href] {
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

button:active:not(:disabled) {
    transform: scale(0.97);
}

/* Search button special hover */
#search-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(13, 148, 136, 0.4);
}

#search-btn:not(:disabled):active {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}

/* Feature card hover */
.feature-card {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, background-color 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(13, 148, 136, 0.15);
}

/* ===== ANIMATED TRUCK LOADER ===== */
.truck-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.truck-animation {
    position: relative;
    width: 80px;
    height: 48px;
}

.truck-body {
    font-size: 2.5rem;
    animation: truck-drive 1.2s ease-in-out infinite;
    display: inline-block;
    color: #0d9488;
    line-height: 1;
}

@keyframes truck-drive {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    25%       { transform: translateY(-4px) rotate(0deg); }
    50%       { transform: translateY(0) rotate(2deg); }
    75%       { transform: translateY(-2px) rotate(0deg); }
}

.truck-road {
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, #0d9488 20%, #0d9488 80%, transparent 100%);
    border-radius: 2px;
    position: absolute;
    bottom: 0;
    animation: road-scroll 0.8s linear infinite;
}

@keyframes road-scroll {
    0%   { background-position: 0; }
    100% { background-position: 80px; }
}

/* Road dashes under truck */
.truck-dashes {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.truck-dash {
    height: 3px;
    border-radius: 2px;
    background: #cbd5e1;
    animation: dash-scroll 0.6s linear infinite;
}

.truck-dash:nth-child(1) { width: 24px; animation-delay: 0s; }
.truck-dash:nth-child(2) { width: 16px; animation-delay: 0.1s; }
.truck-dash:nth-child(3) { width: 20px; animation-delay: 0.2s; }
.truck-dash:nth-child(4) { width: 12px; animation-delay: 0.3s; }
.truck-dash:nth-child(5) { width: 18px; animation-delay: 0.4s; }

@keyframes dash-scroll {
    0%   { opacity: 0.3; }
    50%  { opacity: 1; }
    100% { opacity: 0.3; }
}

/* Loading dots animation */
.loading-dots span {
    display: inline-block;
    animation: dot-bounce 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ===== SKELETON LOADING ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f4f8 25%, #e2e8f0 50%, #f0f4f8 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

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

.skeleton-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1.25rem;
    overflow: hidden;
}

/* ===== EMPTY/NOT FOUND ILLUSTRATION ===== */
.empty-illustration {
    animation: float-gentle 3s ease-in-out infinite;
}

@keyframes float-gentle {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

/* ===== Loading spinner ===== */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Smooth page transitions ===== */
.fade-in {
    animation: fade-in 0.6s ease-out both;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Progress bar ===== */
.progress-bar {
    height: 4px;
    border-radius: 2px;
    background: #e5e7eb;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s ease;
}

/* ===== Scrollbar customization ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ===== Input focus ring ===== */
input:focus, textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* ===== Exception status flicker ===== */
.exception-indicator {
    animation: exception-pulse 2s ease-in-out infinite;
}

@keyframes exception-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* ===== Mobile responsiveness extras ===== */
@media (max-width: 640px) {
    .timeline-item {
        padding-left: 40px;
    }

    .timeline-line {
        left: 14px;
    }

    .timeline-dot {
        left: 5px;
        width: 18px;
        height: 18px;
    }

    #tracking-textarea {
        font-size: 0.875rem;
    }

    /* Ensure touch targets are 44px+ on mobile */
    #search-btn,
    #clear-btn {
        min-height: 48px;
    }

    button {
        min-height: 44px;
    }
}

/* ===== Textarea border transitions ===== */
#tracking-textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ===== Count badge transitions ===== */
#count-badge {
    transition: background-color 0.3s ease;
}

/* ===== Recent search chips ===== */
#recent-chips button {
    transition: background-color 0.15s ease, border-color 0.15s ease;
    backdrop-filter: blur(4px);
}

/* ===== Result card body collapse transition ===== */
.card-body-content {
    /* uses .hidden (display:none) toggle via JS – instant collapse */
}

/* ===== Progress step connecting line transition ===== */
.progress-step-line {
    transition: background-color 0.6s ease;
}

/* ===== Timeline item scroll animation (initial state is set in JS) ===== */
.timeline-item {
    will-change: opacity, transform;
}

/* ===== Service badge pill ===== */
.service-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 9999px;
}

/* ===== Export / collapse button ===== */
.card-action-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* ===== Toast notification ===== */
#result-toast,
#ajax-toast {
    transition: opacity 0.3s ease;
}

/* ===== Result grid cards stagger ===== */
.result-card {
    will-change: opacity, transform;
}

/* ===== 5-step progress bar label (hide on very small screens) ===== */
@media (max-width: 380px) {
    .progress-step-label { display: none !important; }
}

/* ===== Stats bar icons ===== */
.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ===== Nav active state ===== */
header a.nav-active {
    color: white;
}

/* ===== Gradient text for hero ===== */
.gradient-text {
    background: linear-gradient(135deg, #2dd4bf 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Card skeleton loader ===== */
.skeleton-result-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
}

/* ===== Ripple effect on cards ===== */
.order-card {
    position: relative;
    overflow: hidden;
}

/* ===== Smooth chevron rotation ===== */
.chevron-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Stats counter animation ===== */
@keyframes count-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stat-value {
    animation: count-up 0.6s ease-out both;
}

/* ===== Hero CTA pulse ===== */
@keyframes cta-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(13, 148, 136, 0); }
}

/* ===== Mobile stats bar layout ===== */
@media (max-width: 768px) {
    .stats-bar-item {
        flex: 1 1 calc(50% - 0.75rem);
        min-width: 120px;
        justify-content: center;
    }
}

/* ===== Hover underline effect for nav links ===== */
nav a {
    position: relative;
}

/* ===== Large truck bounce for loading ===== */
@keyframes truck-bounce {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    20% {
        transform: translateY(-8px) rotate(-3deg);
    }
    40% {
        transform: translateY(-2px) rotate(2deg);
    }
    60% {
        transform: translateY(-5px) rotate(-1deg);
    }
    80% {
        transform: translateY(-1px) rotate(1deg);
    }
}

.truck-bounce {
    animation: truck-bounce 1s ease-in-out infinite;
    display: inline-block;
}

/* ===== Package box bounce for empty state ===== */
@keyframes package-float {
    0%, 100% {
        transform: translateY(0) rotate(-2deg);
    }
    50% {
        transform: translateY(-12px) rotate(2deg);
    }
}

.package-float {
    animation: package-float 3s ease-in-out infinite;
    display: inline-block;
}

/* ===== Search form focus glow ===== */
.search-card-glow:focus-within {
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.1), 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* ===== Transition for collapsible sections ===== */
.collapsible-body {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

/* ===== New search button hover ===== */
.btn-primary {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}
