/* Home dashboard shipment route map (MapLibre GL JS).
   Loaded after dashboard.css — see the <link> order in index.html. */

.ship-map-panel {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.1rem 1.15rem 1.15rem;
    margin-top: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.ship-map-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}

.ship-map-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

.ship-map-sub {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.76rem;
    color: var(--muted);
}

.ship-map-legend {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.ship-map-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    font-size: 0.71rem;
    font-weight: 600;
    color: var(--ink-soft);
    white-space: nowrap;
}

.ship-map-chip i {
    font-size: 0.7rem;
    color: var(--faint);
}

.ship-map-body {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
}

.ship-map-canvas {
    width: 100%;
    height: 440px;
    background: #EAF1F9;
}

/* Loading / empty overlay. Hidden by adding .is-hidden from JS. */
.ship-map-state {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(248, 250, 252, 0.92);
    color: var(--ink-soft);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
}

.ship-map-state.is-hidden { display: none; }
.ship-map-state i { color: var(--brand); font-size: 1.05rem; }

/* Route counters pinned to the bottom-left of the map, mirroring the KPI strip. */
.ship-map-stats {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 4;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    pointer-events: none;
}

.ship-map-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.4rem 0.65rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #D8E2EE;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
    backdrop-filter: blur(4px);
}

.ship-map-stat strong {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
}

.ship-map-stat span {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ship-map-stat em {
    font-size: 0.68rem;
    font-weight: 700;
    font-style: normal;
    color: var(--ink-soft);
    padding-left: 0.1rem;
}

/* Status tones. The buckets are exclusive and exhaustive, so a reader can add
   the pills up to the total - the colour only says how to feel about each one. */
.ship-map-stat.info { border-color: var(--brand-line); background: rgba(239, 246, 255, 0.92); }
.ship-map-stat.info strong, .ship-map-stat.info em { color: var(--brand-hover); }

.ship-map-stat.warn { border-color: #FDE68A; background: rgba(255, 251, 235, 0.94); }
.ship-map-stat.warn strong, .ship-map-stat.warn em { color: #B45309; }

.ship-map-stat.ok { border-color: #A7F3D0; background: rgba(236, 253, 245, 0.92); }
.ship-map-stat.ok strong, .ship-map-stat.ok em { color: #047857; }

.ship-map-stat.bad { border-color: #FECACA; background: rgba(254, 242, 242, 0.94); }
.ship-map-stat.bad strong, .ship-map-stat.bad em { color: #B91C1C; }

.ship-map-stat.muted { border-color: var(--line); background: rgba(248, 250, 252, 0.92); }
.ship-map-stat.muted strong, .ship-map-stat.muted em { color: var(--muted); }

.ship-map-stat.is-clickable {
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.ship-map-stat.is-clickable:hover {
    transform: translateY(-1px);
    border-color: #93C5FD;
    box-shadow: 0 3px 8px rgba(35, 47, 140, 0.12);
}

/* MapLibre popup restyled to match the light map surface. */

.ship-map-pop-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.3rem;
}

.ship-map-pop-lane {
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 0.35rem;
}

@media (max-width: 900px) {
    .ship-map-canvas { height: 330px; }
    .ship-map-legend { gap: 0.3rem; }
}

/* ============================================================
   Port drill-through
   Hovering a port explains it; clicking it opens the panel below with the
   individual shipments moving through that port inside the rolling window.
   ============================================================ */

.ship-map-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.3rem;
    font-size: 0.72rem;
    color: var(--faint);
}

.ship-map-hint i { font-size: 0.68rem; }

/* ---- hover card ---- */

.ship-map-pop-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.14rem 0;
}

.ship-map-pop-row span:first-child { color: var(--muted); }
.ship-map-pop-row span:last-child { color: var(--ink); font-weight: 600; }

.ship-map-pop-win {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--line);
}

.ship-map-pop-win-head {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 0.4rem;
}

.ship-map-pop-moves { display: flex; gap: 0.4rem; }

.ship-map-pop-move {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.35rem 0.45rem;
    border-radius: 8px;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ship-map-pop-move strong { font-size: 0.95rem; font-weight: 800; line-height: 1; }
.ship-map-pop-move.dep { background: var(--brand-soft); color: #3730A3; }
.ship-map-pop-move.arr { background: #ECFDF5; color: #047857; }

.ship-map-pop-cta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.45rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--brand);
}

@media (max-width: 700px) {
    .ship-map-hint { display: none; }
}
