/* ==========================================================================
   Zew — OpenStreetMap / Leaflet styles
   ========================================================================== */

:root {
    --zew-900: #04362A;
    --zew-800: #0A4D36;
    --zew-700: #0E6B45;
    --zew-600: #13854F;
    --zew-500: #1E9A5C;
    --zew-400: #23A35F;
    --zew-sage: #9DC7B0;
    --zew-mint: #EAF5EF;
    --zew-amber: #F2A93B;
    --zew-gray: #8A9A93;
    --zew-red: #E5484D;
}

.zew-map {
    position: relative;
    width: 100%;
    min-height: 260px;
    border-radius: 14px;
    overflow: hidden;
    background: #E8EFEB;
    z-index: 0;
    font-family: inherit;
}

.zew-map .leaflet-control-attribution {
    font-size: 10px;
    background: rgba(255, 255, 255, .8);
    border-radius: 6px 0 0 0;
}

.zew-map .leaflet-bar,
.zew-map .leaflet-control-zoom {
    border: 0 !important;
    border-radius: 10px !important;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(4, 54, 42, .16) !important;
}

.zew-map .leaflet-control-zoom a {
    width: 34px;
    height: 34px;
    line-height: 34px;
    color: var(--zew-800);
}

.zew-map .leaflet-control-zoom a:hover {
    background: var(--zew-mint);
    color: var(--zew-600);
}

.zew-map-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: #fff;
    color: var(--zew-800);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(4, 54, 42, .16);
    transition: background .15s, color .15s;
}

.zew-map-btn:hover {
    background: var(--zew-mint);
    color: var(--zew-600);
}

.zew-map-btn svg {
    width: 18px;
    height: 18px;
}

/* ---------- Search ---------- */

.zew-map-search {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: min(420px, calc(100% - 120px));
}

.zew-map-search__icon {
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--zew-600);
    pointer-events: none;
}

.zew-map-search__icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.zew-map-search__input {
    width: 100%;
    height: 42px;
    padding-inline: 38px 14px;
    border: 1px solid rgba(4, 54, 42, .08);
    border-radius: 12px;
    background: #fff;
    color: #1E2D27;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(4, 54, 42, .16);
    outline: none;
    transition: box-shadow .15s, border-color .15s;
}

.zew-map-search__input:focus {
    border-color: var(--zew-500);
    box-shadow: 0 0 0 3px rgba(30, 154, 92, .18), 0 6px 20px rgba(4, 54, 42, .16);
}

.zew-map-search.is-loading::after {
    content: "";
    position: absolute;
    inset-inline-end: 12px;
    top: 13px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--zew-sage);
    border-top-color: var(--zew-600);
    border-radius: 50%;
    animation: zew-spin .7s linear infinite;
}

.zew-map-search__results {
    display: none;
    margin: 6px 0 0;
    padding: 6px;
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(4, 54, 42, .2);
}

.zew-map-search__results.is-open {
    display: block;
}

.zew-map-search__results li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.35;
}

.zew-map-search__results li strong {
    font-size: 13.5px;
    color: #1E2D27;
    font-weight: 600;
}

.zew-map-search__results li small {
    font-size: 12px;
    color: #6B7B74;
}

.zew-map-search__results li:hover,
.zew-map-search__results li.is-active {
    background: var(--zew-mint);
}

.zew-map-search__results li.is-empty {
    cursor: default;
    color: #6B7B74;
    font-size: 13px;
}

/* ---------- Markers ---------- */

.zew-marker-wrap {
    background: none !important;
    border: 0 !important;
}

.zew-marker {
    position: relative;
    width: 40px;
    height: 48px;
}

.zew-marker__body {
    position: absolute;
    left: 2px;
    top: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% 50% 50% 4px;
    transform: rotate(-45deg);
    background: var(--zew-600);
    color: #fff;
    border: 3px solid #fff;
    box-shadow: 0 6px 14px rgba(4, 54, 42, .35);
}

.zew-marker__body svg {
    width: 18px;
    height: 18px;
    transform: rotate(45deg);
}

.zew-marker--store .zew-marker__body { background: var(--zew-900); }
.zew-marker--customer .zew-marker__body,
.zew-marker--parcel-receiver .zew-marker__body { background: #2F6FED; }
.zew-marker--parcel-sender .zew-marker__body { background: #8E4EC6; }
.zew-marker--pin .zew-marker__body { background: var(--zew-600); }

.zew-marker--driver.is-available .zew-marker__body { background: var(--zew-500); }
.zew-marker--driver.is-busy .zew-marker__body { background: var(--zew-amber); }
.zew-marker--driver.is-offline .zew-marker__body { background: var(--zew-gray); }
.zew-marker--driver.is-stale .zew-marker__body { background: #B9C4BF; }

.zew-marker__pulse {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 22px;
    height: 10px;
    margin-left: -11px;
    border-radius: 50%;
    background: rgba(30, 154, 92, .35);
    animation: zew-pulse 1.8s ease-out infinite;
}

.zew-marker.is-busy .zew-marker__pulse {
    background: rgba(242, 169, 59, .4);
}

.zew-marker__label {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    padding: 1px 7px;
    border-radius: 8px;
    background: #fff;
    color: var(--zew-900);
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}

/* ---------- Popups ---------- */

.zew-leaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(4, 54, 42, .22);
}

.zew-leaflet-popup .leaflet-popup-content {
    margin: 14px;
    min-width: 210px;
}

.zew-popup__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.zew-popup__head img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--zew-mint);
}

.zew-popup__head strong {
    display: block;
    color: #1E2D27;
    font-size: 14px;
}

.zew-popup__head a {
    font-size: 12px;
    color: var(--zew-600);
}

.zew-popup__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.zew-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    background: #F1F4F3;
    color: #42524B;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: capitalize;
}

.zew-chip--available { background: var(--zew-mint); color: var(--zew-700); }
.zew-chip--busy { background: #FFF4E2; color: #A3670F; }
.zew-chip--offline, .zew-chip--stale { background: #EEF1F0; color: #6B7B74; }

.zew-popup__loc {
    margin: 0 0 4px;
    font-size: 12px;
    color: #42524B;
}

.zew-popup__time {
    margin: 0;
    font-size: 11px;
    color: #8A9A93;
}

.zew-popup__link {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--zew-600);
}

/* ---------- Live badge / legend ---------- */

.zew-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(4, 54, 42, .88);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(4, 54, 42, .25);
}

.zew-live-badge__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3DDC84;
    box-shadow: 0 0 0 0 rgba(61, 220, 132, .7);
    animation: zew-blink 1.6s infinite;
}

.zew-live-badge.is-error .zew-live-badge__dot {
    background: var(--zew-amber);
    animation: none;
}

.zew-live-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--zew-400);
    animation: zew-blink 1.6s infinite;
}

.zew-map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12.5px;
    color: #42524B;
}

.zew-map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.zew-map-legend i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* ---------- Live dispatch panel ---------- */

.zew-live-panel {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 28px rgba(4, 54, 42, .08);
    border: 1px solid rgba(4, 54, 42, .06);
}

.zew-live-panel__side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 620px;
    border-inline-end: 1px solid rgba(4, 54, 42, .08);
}

.zew-live-panel__head {
    padding: 16px;
    background: linear-gradient(160deg, var(--zew-900), var(--zew-600));
    color: #fff;
}

.zew-live-panel__head h5 {
    margin: 0 0 4px;
    color: #fff;
    font-size: 15px;
}

.zew-live-panel__head p {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, .75);
}

.zew-live-panel__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.zew-live-panel__stats div {
    padding: 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    text-align: center;
}

.zew-live-panel__stats strong {
    display: block;
    font-size: 18px;
    line-height: 1.1;
    color: #fff;
}

.zew-live-panel__stats small {
    font-size: 10.5px;
    color: rgba(255, 255, 255, .78);
}

.zew-live-panel__filters {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid rgba(4, 54, 42, .08);
}

.zew-live-panel__filters input {
    height: 38px;
    border-radius: 10px;
}

.zew-seg {
    display: flex;
    gap: 4px;
    padding: 3px;
    border-radius: 10px;
    background: #F1F4F3;
}

.zew-seg button {
    flex: 1;
    border: 0;
    padding: 6px 4px;
    border-radius: 8px;
    background: transparent;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: #42524B;
    cursor: pointer;
}

.zew-seg button.is-active {
    background: #fff;
    color: var(--zew-700);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

.zew-live-list {
    flex: 1;
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
}

.zew-live-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s;
}

.zew-live-list li:hover {
    background: var(--zew-mint);
}

.zew-live-list li.is-nolocation {
    opacity: .55;
    cursor: default;
}

.zew-live-list img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
}

.zew-live-list .zew-live-list__body {
    flex: 1;
    min-width: 0;
}

.zew-live-list strong {
    display: block;
    font-size: 13px;
    color: #1E2D27;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zew-live-list small {
    font-size: 11.5px;
    color: #6B7B74;
}

.zew-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
}

.zew-dot--available { background: var(--zew-500); }
.zew-dot--busy { background: var(--zew-amber); }
.zew-dot--offline { background: var(--zew-gray); }
.zew-dot--stale { background: #C8D1CD; }

.zew-live-list__empty {
    padding: 24px 12px;
    text-align: center;
    color: #6B7B74;
    font-size: 13px;
}

.zew-live-panel .zew-map {
    border-radius: 0;
    height: 620px;
}

@media (max-width: 991px) {
    .zew-live-panel {
        grid-template-columns: 1fr;
    }

    .zew-live-panel__side {
        max-height: 360px;
        border-inline-end: 0;
        border-bottom: 1px solid rgba(4, 54, 42, .08);
    }

    .zew-live-panel .zew-map {
        height: 460px;
    }
}

@media (max-width: 575px) {
    .zew-map-search {
        width: calc(100% - 70px);
        left: 12px;
        transform: none;
    }

    [dir="rtl"] .zew-map-search {
        left: auto;
        right: 12px;
    }
}

/* ---------- Leaflet-Geoman tweaks ---------- */

.zew-map .leaflet-pm-toolbar .button-container a.leaflet-buttons-control-button {
    width: 34px;
    height: 34px;
}

.zew-map .leaflet-pm-toolbar .button-container.active .leaflet-buttons-control-button {
    background-color: var(--zew-mint);
}

.zew-map .marker-icon {
    background-color: #fff;
    border: 2px solid var(--zew-600);
}

@keyframes zew-pulse {
    0% { transform: scale(.6); opacity: 1; }
    100% { transform: scale(2.4); opacity: 0; }
}

@keyframes zew-blink {
    0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, .7); }
    70% { box-shadow: 0 0 0 8px rgba(61, 220, 132, 0); }
    100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}

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