/* ============================================================
   Shipment Tracker Modal Styles
   ============================================================ */

/* ── Overlay ──────────────────────────────────────────────── */
.tracker-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(6, 12, 34, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: trackerFadeIn 0.25s ease;
}

@keyframes trackerFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal shell ──────────────────────────────────────────── */
.tracker-modal {
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 860px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255,255,255,0.06);
    animation: trackerSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overscroll-behavior: contain;
}

@keyframes trackerSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ─────────────────────────────────────────────────  */
.tracker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 18px;
    border-bottom: 1px solid #f0f2f5;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    border-radius: 20px 20px 0 0;
}

.tracker-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.tracker-ship-icon {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #0d6efd, #0056d6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 4px 14px rgba(13, 110, 253, 0.35);
    flex-shrink: 0;
}

.tracker-header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f1624;
    margin: 0 0 2px;
    line-height: 1.2;
}

.tracker-header-sub {
    font-size: 0.82rem;
    color: #6b7280;
    margin: 0;
    font-weight: 400;
}

.tracker-close-btn {
    background: #f3f4f6;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.35rem;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.tracker-close-btn:hover {
    background: #e5e7eb;
    color: #111827;
}

/* ── Body ────────────────────────────────────────────────── */
.tracker-body {
    padding: 24px 28px 28px;
}

/* ── Status Banner ───────────────────────────────────────── */
.tracker-status-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.tracker-status-dot {
    width: 12px;
    height: 12px;
    background: #2563eb;
    border-radius: 50%;
    flex-shrink: 0;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
    50%       { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

.tracker-status-text {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Legacy tracker layout (non–light-style modal); avoid blue-on-dark in live tracker */
.tracker-modal:not(.light-style) .tracker-status-text {
    color: #1d4ed8;
}

#tracker-overlay.tracker-overlay--dark .tracker-status-text {
    color: #f3f4f6 !important;
}

.tracker-location-chip {
    margin-left: auto;
    background: #fff;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.8rem;
    color: #374151;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tracker-location-chip i {
    color: #ef4444;
    margin-right: 4px;
    font-size: 0.75rem;
}

/* ── Map ─────────────────────────────────────────────────── */
.tracker-map-wrapper {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.07);
}

#tracker-map {
    height: 380px;
    width: 100%;
    background: #cae0f5;
}

/* Leaflet overrides for clean look */
.tracker-map-wrapper .leaflet-control-attribution {
    font-size: 9px;
    opacity: 0.7;
}

/* ── Custom ship marker ──────────────────────────────────── */
.ship-marker-wrapper {
    position: relative;
}

.ship-marker-icon {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
    display: block;
    transform-origin: center center;
    animation: shipBob 3s ease-in-out infinite;
}

@keyframes shipBob {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-3px); }
}

.ship-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.2);
    animation: shipPulseRing 2s ease-out infinite;
    pointer-events: none;
}

@keyframes shipPulseRing {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* route start / end markers */
.tracker-point-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ── Grid below map ──────────────────────────────────────── */
.tracker-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 20px;
}

/* ── Progress card ───────────────────────────────────────── */
.tracker-progress-card,
.tracker-countdown-card,
.tracker-details-card {
    background: #f9fafb;
    border: 1px solid #f0f2f5;
    border-radius: 14px;
    padding: 18px 20px;
}

.tracker-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin: 0 0 10px;
}

/* Progress bar */
.tracker-progress-bar-track {
    height: 10px;
    background: #e5e7eb;
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 8px;
}

.tracker-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #06b6d4);
    border-radius: 100px;
    transition: width 1s linear;
    min-width: 2%;
}

.tracker-progress-pct {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f1624;
    line-height: 1;
    margin-bottom: 4px;
}

.tracker-progress-label {
    font-size: 0.82rem;
    color: #6b7280;
}

/* ── Countdown card ──────────────────────────────────────── */
.tracker-countdown-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.tracker-countdown-unit {
    text-align: center;
}

.tracker-countdown-num {
    font-size: 1.45rem;
    font-weight: 800;
    color: #0f1624;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    display: block;
}

.tracker-countdown-lbl {
    font-size: 0.7rem;
    color: #9ca3af;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 3px;
    display: block;
}

/* ── Details card (full width) ───────────────────────────── */
.tracker-details-card {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.tracker-detail-item .tracker-detail-lbl {
    font-size: 0.76rem;
    color: #9ca3af;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
}

.tracker-detail-item .tracker-detail-val {
    font-size: 0.92rem;
    font-weight: 600;
    color: #0f1624;
}

/* ── Stage Steps ─────────────────────────────────────────── */
.tracker-stages {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 16px 0 0;
    border-top: 1px solid #f0f2f5;
    overflow-x: auto;
    scrollbar-width: none;
}
.tracker-stages::-webkit-scrollbar { display: none; }

.tracker-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 72px;
    position: relative;
}

.tracker-stage:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 13px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: #e5e7eb;
    z-index: 0;
}

.tracker-stage.done::after  { background: #2563eb; }
.tracker-stage.active::after { background: linear-gradient(90deg, #2563eb, #e5e7eb); }

.tracker-stage-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid #e5e7eb;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #d1d5db;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    transition: all 0.4s ease;
}

.tracker-stage.done .tracker-stage-dot {
    border-color: #2563eb;
    background: #2563eb;
    color: #fff;
}

.tracker-stage.active .tracker-stage-dot {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.tracker-stage-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #9ca3af;
    margin-top: 7px;
    text-align: center;
    white-space: nowrap;
    line-height: 1.2;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tracker-stage.done .tracker-stage-label,
.tracker-stage.active .tracker-stage-label {
    color: #374151;
}

/* ── Arrived state ───────────────────────────────────────── */
.tracker-arrived-banner {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 1px solid #6ee7b7;
    border-radius: 12px;
    padding: 18px 22px;
    text-align: center;
    margin-bottom: 20px;
}

.tracker-arrived-banner h3 {
    margin: 0 0 6px;
    color: #065f46;
    font-size: 1.1rem;
    font-weight: 700;
}

.tracker-arrived-banner p {
    margin: 0;
    color: #047857;
    font-size: 0.9rem;
}

.tracker-arrived-banner .tracker-arrived-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

/* ── Track button in order rows / cards ──────────────────── */
.btn-track {
    background: linear-gradient(135deg, #2563eb, #1d56d4);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s, transform 0.15s;
    white-space: nowrap;
}

.btn-track:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.btn-track i {
    font-size: 0.78rem;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 680px) {
    .tracker-modal {
        border-radius: 16px 16px 0 0;
        max-height: 96vh;
        margin-top: auto;
    }

    .tracker-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .tracker-header { padding: 18px 20px 14px; }
    .tracker-body   { padding: 16px 20px 24px; }

    #tracker-map { height: 250px; }

    .tracker-info-grid       { grid-template-columns: 1fr; }
    .tracker-details-card    { grid-template-columns: repeat(2, 1fr); }
    .tracker-location-chip   { display: none; }
    .tracker-status-banner   { flex-wrap: wrap; }

    .tracker-countdown-num { font-size: 1.2rem; }
    .tracker-progress-pct  { font-size: 1.3rem; }
}

@media (max-width: 420px) {
    .tracker-details-card { grid-template-columns: 1fr 1fr; }
}
