/* ══════════════════════════════════════════════
   Root Tokens
   ══════════════════════════════════════════════ */
:root {
    --ff-body: "Plus Jakarta Sans", sans-serif;
    --ff-mono: "IBM Plex Mono", monospace;

    --clr-bg: #f0f2f5;
    --clr-surface: #ffffff;
    --clr-text: #141a24;
    --clr-text-mid: #4b5563;
    --clr-text-dim: #8b95a5;
    --clr-border: #e2e6ec;
    --clr-accent: #e85330;

    --clr-red: #ef4444;
    --clr-green: #10b981;
    --clr-amber: #f59e0b;
    --clr-blue: #3b82f6;
    --clr-purple: #8b5cf6;
    --clr-pink: #ec4899;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-marker: 0 2px 8px rgba(0, 0, 0, .18),
        0 0 0 3px #fff;
    --shadow-tooltip: 0 16px 48px rgba(20, 26, 36, .16),
        0 4px 12px rgba(20, 26, 36, .08);
}

/* ══════════════════════════════════════════════
   Reset & Base
   ══════════════════════════════════════════════ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: var(--ff-body);
    color: var(--clr-text);
}

/* ══════════════════════════════════════════════
   Map Section
   ══════════════════════════════════════════════ */
.map-section {
    position: relative;
    width: 100%;
    height: 100vh;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--clr-border);
    box-shadow: 0 2px 14px rgba(0, 0, 0, .06);
    overflow: hidden;
    z-index: 1;
}

/* ══════════════════════════════════════════════
   Custom Leaflet Markers
   ══════════════════════════════════════════════ */

/* --- Pin (circle + triangle tail) --- */
.marker-shell {
    position: relative;
    width: 44px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform .22s cubic-bezier(.34, 1.56, .64, 1);
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .22));
}

.marker-shell:hover {
    transform: scale(1.18) translateY(-3px);
}

.marker-shell.active {
    transform: scale(1.18) translateY(-3px);
}

.marker-face {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    font-family: var(--ff-body);
    line-height: 1;
    position: relative;
    z-index: 2;
}

/* Pin tail */
.marker-tail {
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 11px solid #fff;
    margin-top: -2px;
    position: relative;
    z-index: 1;
}

/* Logo variant */
.marker-face--logo {
    padding: 4px;
    overflow: hidden;
    background: #fff;
}

.marker-face--logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* Pin background colours */
.face-red {
    background: var(--clr-red);
}

.face-green {
    background: var(--clr-green);
}

.face-amber {
    background: var(--clr-amber);
}

.face-blue {
    background: var(--clr-blue);
}

.face-purple {
    background: var(--clr-purple);
}

.face-pink {
    background: var(--clr-pink);
}

.face-orange {
    background: #f97316;
}

/* Pulse ring on active/hovered */
.marker-shell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s ease;
}

.marker-shell:hover::before,
.marker-shell.active::before {
    animation: pulse-ring 1s ease-out forwards;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(232, 83, 48, .35);
        opacity: 1;
    }

    100% {
        box-shadow: 0 0 0 18px rgba(232, 83, 48, 0);
        opacity: 0;
    }
}

/* ══════════════════════════════════════════════
   Tooltip Card
   ══════════════════════════════════════════════ */
.supplier-tooltip {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px) scale(.96);
    transition: opacity .2s ease,
        transform .2s cubic-bezier(.34, 1.56, .64, 1);
    font-family: var(--ff-body);
    will-change: transform, opacity;
}

.supplier-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.supplier-tooltip.pinned {
    pointer-events: auto;
}

.tt-card {
    position: relative;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-tooltip);
    padding: 18px 20px 14px;
    min-width: 275px;
    max-width: 320px;
}

/* Close button (shown when pinned) */
.tt-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border: none;
    background: var(--clr-bg);
    border-radius: 50%;
    display: none;
    /* hidden unless pinned */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: var(--clr-text-mid);
    transition: background .15s ease, color .15s ease;
}

.tt-close:hover {
    background: var(--clr-border);
    color: var(--clr-text);
}

.supplier-tooltip.pinned .tt-close {
    display: flex;
}

/* Header */
.tt-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tt-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--clr-border);
    background: var(--clr-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tt-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
}

.tt-name-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

.tt-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .12);
}

.dot-red {
    background: var(--clr-red);
}

.dot-green {
    background: var(--clr-green);
}

.dot-amber {
    background: var(--clr-amber);
}

.dot-blue {
    background: var(--clr-blue);
}

.dot-purple {
    background: var(--clr-purple);
}

.dot-pink {
    background: var(--clr-pink);
}

.dot-orange {
    background: #f97316;
}

.tt-title-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tt-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    color: var(--clr-text);
    padding-right: 18px;
    /* room for close button */
}

.tt-zone {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .5px;
    color: var(--clr-text-mid);
    background: var(--clr-bg);
    padding: 2px 8px;
    border-radius: 5px;
    width: fit-content;
}

/* Divider */
.tt-divider {
    border: none;
    height: 1px;
    background: var(--clr-border);
    margin: 12px 0 10px;
}

/* Detail rows */
.tt-details {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.tt-details li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--clr-text);
}

.tt-details li i {
    font-size: 15px;
    color: var(--clr-accent);
    flex-shrink: 0;
    margin-top: 1px;
}

.tt-details li strong {
    font-weight: 600;
}

/* Coords */
.tt-coords {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--clr-border);
    font-family: var(--ff-mono);
    font-size: 11px;
    color: var(--clr-text-dim);
    letter-spacing: .3px;
}

/* Arrow */
.tt-arrow {
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 9px;
    overflow: hidden;
}

.tt-arrow::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 12px;
    height: 12px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 2px;
    transform: translateX(-50%) rotate(45deg);
}

/* Flipped arrow (when tooltip opens below marker) */
.supplier-tooltip.flipped .tt-arrow {
    bottom: auto;
    top: -7px;
}

.supplier-tooltip.flipped .tt-arrow::after {
    top: auto;
    bottom: 0;
}

/* ══════════════════════════════════════════════
   Override Leaflet defaults
   ══════════════════════════════════════════════ */
.leaflet-div-icon {
    background: none !important;
    border: none !important;
}

/* ══════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════ */
@media (max-width: 576px) {
    .map-section {
        padding: 8px;
    }

    .tt-card {
        min-width: 230px;
        max-width: 270px;
        padding: 14px 15px 11px;
    }

    .tt-name {
        font-size: 14px;
    }

    .tt-details li {
        font-size: 12px;
    }
}