/* ============================================
   ASDP - Delivery Tracking Page Styles
   Mobile-first, Arabic RTL
   ============================================ */

/* ---- Page Layout ---- */
.tracking-page {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-light);
    position: relative;
    overflow-x: hidden;
}

/* ---- Slim Header ---- */
.tracking-header {
    background: linear-gradient(135deg, var(--alzamil-blue-dark), var(--alzamil-blue));
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.tracking-header .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tracking-header .header-logo {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.tracking-header .header-info h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    margin: 0;
    line-height: 1.2;
}

.tracking-header .header-info .order-num {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    margin: 0;
    direction: ltr;
    text-align: right;
}

.tracking-header .back-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 1.2rem;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.tracking-header .back-link:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* ---- Map Section ---- */
.map-section {
    position: relative;
    width: 100%;
    height: 45vh;
    min-height: 260px;
}

.map-section #trackingMap {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ---- ETA Badge ---- */
.eta-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--alzamil-blue-dark);
    transition: all 0.4s ease;
}

.eta-badge .eta-icon {
    font-size: 1.1rem;
    color: var(--alzamil-blue-light);
}

.eta-badge.arrived {
    background: rgba(39, 174, 96, 0.95);
    color: white;
}

.eta-badge.arrived .eta-icon {
    color: white;
}

/* ---- Truck Marker ---- */
.truck-marker-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--alzamil-blue), var(--alzamil-blue-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 3px 12px rgba(26,82,118,0.4);
    border: 3px solid white;
    transition: transform 0.3s ease;
    animation: truck-pulse 2s infinite;
}

@keyframes truck-pulse {
    0%, 100% {
        box-shadow: 0 3px 12px rgba(26,82,118,0.4);
    }
    50% {
        box-shadow: 0 3px 20px rgba(26,82,118,0.6), 0 0 0 8px rgba(41,128,185,0.15);
    }
}

/* ---- Bottom Content ---- */
.tracking-content {
    padding: 16px;
    padding-bottom: 32px;
}

/* ---- Info Cards ---- */
.tracking-card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid var(--border-light);
}

.tracking-card .card-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--alzamil-blue-dark);
}

.tracking-card .card-title-row i {
    font-size: 1.1rem;
    color: var(--alzamil-blue-light);
}

.tracking-card .info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.88rem;
}

.tracking-card .info-row .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.tracking-card .info-row .value {
    font-weight: 700;
    color: var(--text-primary);
}

/* ---- Driver Card ---- */
.driver-card {
    display: flex;
    align-items: center;
    gap: 14px;
}

.driver-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e8f4f8, #d6eaf8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--alzamil-blue);
    flex-shrink: 0;
    border: 2px solid var(--border-light);
}

.driver-info {
    flex: 1;
    min-width: 0;
}

.driver-info .driver-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.driver-info .driver-vehicle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.driver-phone-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    text-decoration: none;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(39,174,96,0.3);
    transition: transform 0.2s;
}

.driver-phone-btn:hover {
    transform: scale(1.1);
    color: white;
}

/* ---- Status Timeline ---- */
.status-timeline {
    position: relative;
    padding: 0;
    margin: 0;
    list-style: none;
}

.status-timeline::before {
    content: '';
    position: absolute;
    right: 15px;
    top: 24px;
    bottom: 24px;
    width: 2px;
    background: var(--border-light);
}

.timeline-step {
    position: relative;
    padding-right: 48px;
    padding-bottom: 24px;
    min-height: 60px;
}

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

.timeline-step .step-dot {
    position: absolute;
    right: 4px;
    top: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    z-index: 2;
    transition: all 0.4s ease;
}

.timeline-step .step-dot.completed {
    background: var(--score-green);
    color: white;
    border: 3px solid #d5f5e3;
}

.timeline-step .step-dot.current {
    background: var(--alzamil-blue-light);
    color: white;
    border: 3px solid #d6eaf8;
    animation: pulse-dot 1.5s infinite;
}

.timeline-step .step-dot.upcoming {
    background: white;
    color: #bdc3c7;
    border: 2px solid #dfe6e9;
}

.timeline-step .step-content {
    padding-top: 0;
}

.timeline-step .step-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 1px;
}

.timeline-step .step-time {
    font-size: 0.78rem;
    color: var(--alzamil-blue-light);
    font-weight: 600;
    margin-bottom: 2px;
}

.timeline-step .step-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.timeline-step.completed-step .step-label {
    color: var(--text-primary);
}

.timeline-step.current-step .step-label {
    color: var(--alzamil-blue);
}

.timeline-step.upcoming-step .step-label {
    color: #95a5a6;
}

.timeline-step.upcoming-step .step-desc {
    color: #bdc3c7;
}

.timeline-step.upcoming-step .step-time {
    color: #bdc3c7;
}

/* ---- Completed line segment ---- */
.timeline-step.completed-step + .timeline-step::after {
    content: '';
    position: absolute;
    right: 15px;
    top: -24px;
    height: 24px;
    width: 2px;
    background: var(--score-green);
    z-index: 1;
}

/* ---- Phase 2 Card ---- */
.phase2-card {
    background: #fef9f0;
    border: 2px dashed #f0c987;
    border-radius: 14px;
    padding: 16px;
    margin-top: 14px;
}

.phase2-card .phase2-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.phase2-card .phase2-icon {
    font-size: 1.6rem;
}

.phase2-card .phase2-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.phase2-card .phase2-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.phase2-card .phase2-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 10px;
    background: #fdebd0;
    color: #b7950b;
    font-weight: 700;
    font-size: 0.82rem;
}

/* ---- Celebration Banner ---- */
.celebration-banner {
    position: fixed;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    width: calc(100% - 32px);
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    text-align: center;
    padding: 16px 24px;
    border-radius: 0 0 16px 16px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 6px 24px rgba(39,174,96,0.35);
    z-index: 2000;
    transition: top 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.celebration-banner.show {
    top: 0;
}

.celebration-banner .celebration-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ---- Confetti Particles ---- */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    top: -10px;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ---- Leaflet Custom Overrides ---- */
.leaflet-container {
    font-family: 'Tajawal', sans-serif;
}

.leaflet-popup-content-wrapper {
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.85rem;
    direction: rtl;
}

.leaflet-popup-content {
    margin: 10px 14px;
    font-weight: 600;
}

.warehouse-popup {
    display: flex;
    align-items: center;
    gap: 6px;
}

.customer-popup {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---- Desktop ---- */
@media (min-width: 481px) {
    .map-section {
        height: 50vh;
    }
}

/* ---- Very small screens ---- */
@media (max-width: 360px) {
    .tracking-content {
        padding: 12px;
    }

    .tracking-card {
        padding: 12px;
    }

    .eta-badge {
        font-size: 0.78rem;
        padding: 6px 12px;
    }

    .driver-avatar {
        width: 46px;
        height: 46px;
        font-size: 1.2rem;
    }

    .timeline-step {
        padding-right: 42px;
    }

    .timeline-step .step-dot {
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }

    .status-timeline::before {
        right: 14px;
    }
}
