:root {
    --map-primary: #147a67;
    --map-primary-dark: #0d5e50;
    --map-primary-soft: #e7f5f1;
    --map-text: #17231f;
    --map-muted: #6a7874;
    --map-border: #dfe8e5;
    --map-background: #e6efec;
    --map-surface: rgba(255, 255, 255, 0.96);
    --map-danger: #d33a2c;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    direction: rtl;
    color: var(--map-text);
    background: var(--map-background);
    font-family: "Vazir", "Vazirmatn", Tahoma, Arial, sans-serif;
}

button,
select,
input,
textarea {
    font: inherit;
}

button,
select {
    -webkit-tap-highlight-color: transparent;
}

.event-map-page {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    isolation: isolate;
    color: var(--map-text);
    background: var(--map-background);
}

.map-container {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-height: 100%;
    background: #dbe7e3;
}

.map-topbar {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 62px;
    padding: 10px 12px;
    color: #fff;
    background: rgba(20, 34, 30, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    box-shadow: 0 12px 35px rgba(14, 36, 30, 0.18);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.brand-section {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.brand-icon {
    display: grid;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #fff;
    background: var(--map-primary);
    border-radius: 13px;
}

    .brand-icon svg,
    .sheet-heading-icon svg,
    .select-leading-icon svg,
    .select-arrow svg,
    .button-icon svg,
    .information-icon svg,
    .edit-panel-icon svg {
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8px;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .brand-icon svg {
        width: 23px;
        height: 23px;
    }

.brand-content {
    min-width: 0;
}

    .brand-content h1 {
        max-width: 220px;
        margin: 0;
        overflow: hidden;
        font-size: 0.94rem;
        font-weight: 800;
        line-height: 1.5;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .brand-content p {
        margin: 1px 0 0;
        color: rgba(255, 255, 255, 0.7);
        font-size: 0.69rem;
    }

.online-badge {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
}

.online-dot {
    width: 7px;
    height: 7px;
    background: #55d8ac;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(85, 216, 172, 0.14);
}

.control-sheet {
    --sheet-peek-height: calc(58px + env(safe-area-inset-bottom));
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    max-height: 62dvh;
    overflow: hidden;
    background: var(--map-surface);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-bottom: 0;
    border-radius: 27px 27px 0 0;
    box-shadow: 0 -16px 42px rgba(22, 48, 41, 0.15);
    transform: translateY(0);
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease;
    will-change: transform;
    -webkit-backdrop-filter: blur(24px);
    backdrop-filter: blur(24px);
}

    .control-sheet.is-collapsed {
        transform: translateY( calc(100% - var(--sheet-peek-height)) );
        box-shadow: 0 -8px 28px rgba(22, 48, 41, 0.12);
    }

.sheet-toggle {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
    min-height: 58px;
    padding: 8px 16px 7px;
    color: var(--map-muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    touch-action: none;
    font-family: "Vazir", "Vazirmatn", Tahoma, Arial, sans-serif;
}

    .sheet-toggle::after {
        position: absolute;
        right: 16px;
        bottom: 0;
        left: 16px;
        height: 1px;
        content: "";
        background: rgba(223, 232, 229, 0.76);
        opacity: 1;
        transition: opacity 180ms ease;
    }

.control-sheet.is-collapsed .sheet-toggle::after {
    opacity: 0;
}

.sheet-handle {
    grid-column: 2;
    width: 43px;
    height: 5px;
    margin: 0 auto;
    background: #cdd9d5;
    border-radius: 999px;
    transition: width 180ms ease, background-color 180ms ease;
}

.sheet-toggle:hover .sheet-handle,
.sheet-toggle:focus-visible .sheet-handle {
    width: 52px;
    background: #adbfba;
}

.sheet-toggle-label {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    color: var(--map-muted);
    font-size: 0.68rem;
    font-weight: 750;
}

.sheet-toggle-icon {
    grid-column: 3;
    grid-row: 1;
    display: grid;
    justify-self: end;
    width: 30px;
    height: 30px;
    place-items: center;
    color: var(--map-primary);
    background: var(--map-primary-soft);
    border-radius: 10px;
    transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), background-color 180ms ease;
}

    .sheet-toggle-icon svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.control-sheet.is-collapsed .sheet-toggle-icon {
    transform: rotate(180deg);
}

.sheet-content {
    max-height: calc( 62dvh - 58px - env(safe-area-inset-bottom) );
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c7d5d1 transparent;
}

    .sheet-content::-webkit-scrollbar {
        width: 5px;
    }

    .sheet-content::-webkit-scrollbar-thumb {
        background: #c7d5d1;
        border-radius: 999px;
    }

.sheet-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 11px;
}

.sheet-eyebrow {
    display: block;
    margin-bottom: 1px;
    color: var(--map-primary);
    font-size: 0.68rem;
    font-weight: 800;
}

.sheet-heading h2 {
    margin: 0;
    color: var(--map-text);
    font-size: 1.08rem;
    font-weight: 850;
    line-height: 1.5;
}

.sheet-heading-icon {
    display: grid;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    place-items: center;
    color: var(--map-primary);
    background: var(--map-primary-soft);
    border-radius: 13px;
}

    .sheet-heading-icon svg {
        width: 22px;
        height: 22px;
    }

.destination-field {
    display: block;
    margin-bottom: 9px;
}

.field-label {
    display: block;
    margin: 0 4px 6px;
    color: var(--map-muted);
    font-size: 0.69rem;
    font-weight: 700;
}

.select-shell {
    position: relative;
    display: flex;
    align-items: center;
}

.destination-field select {
    width: 100%;
    min-height: 51px;
    padding: 0 45px 0 40px;
    color: var(--map-text);
    background: #f5f8f7;
    border: 1px solid var(--map-border);
    border-radius: 15px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    font-family: "Vazir", "Vazirmatn", Tahoma, Arial, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

    .destination-field select:focus {
        background: #fff;
        border-color: var(--map-primary);
        box-shadow: 0 0 0 4px rgba(20, 122, 103, 0.12);
    }

.select-leading-icon,
.select-arrow {
    position: absolute;
    z-index: 1;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.select-leading-icon {
    right: 14px;
    color: var(--map-primary);
}

.select-arrow {
    left: 13px;
    color: var(--map-muted);
}

    .select-leading-icon svg,
    .select-arrow svg {
        width: 20px;
        height: 20px;
    }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 47px;
    padding: 0 13px;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    font-family: "Vazir", "Vazirmatn", Tahoma, Arial, sans-serif;
    font-size: 0.8rem;
    font-weight: 800;
    transition: transform 120ms ease, opacity 120ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

    .button:active:not(:disabled) {
        transform: scale(0.975);
    }

    .button:disabled {
        cursor: not-allowed;
        opacity: 0.46;
    }

.button-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--map-primary), var(--map-primary-dark));
    box-shadow: 0 8px 20px rgba(13, 94, 80, 0.22);
}

.button-secondary {
    color: #40504b;
    background: #f1f5f4;
    border: 1px solid var(--map-border);
}

.button-edit {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.button-location {
    width: 100%;
    min-height: 51px;
}

.button-icon {
    display: grid;
    place-items: center;
}

    .button-icon svg {
        width: 19px;
        height: 19px;
    }

.secondary-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.map-information {
    margin-top: 11px;
}

.status-message {
    min-height: 41px;
    padding: 9px 11px;
    color: #38504a;
    background: var(--map-primary-soft);
    border: 1px solid rgba(20, 122, 103, 0.1);
    border-radius: 13px;
    font-family: "Vazir", "Vazirmatn", Tahoma, Arial, sans-serif;
    font-size: 0.7rem;
    line-height: 1.75;
}

.information-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
}

.information-card {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 56px;
    gap: 8px;
    padding: 8px 9px;
    background: #f7f9f8;
    border: 1px solid #e6ece9;
    border-radius: 13px;
    font-family: "Vazir", "Vazirmatn", Tahoma, Arial, sans-serif;
}

.information-card-primary {
    background: #eff8f5;
    border-color: #d4eae4;
}

.information-icon {
    display: grid;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    place-items: center;
    color: var(--map-primary);
    background: #e6f2ef;
    border-radius: 9px;
}

    .information-icon svg {
        width: 16px;
        height: 16px;
    }

.information-card > div {
    min-width: 0;
}

.information-card span:not(.information-icon) {
    display: block;
    color: var(--map-muted);
    font-size: 0.59rem;
    line-height: 1.5;
}

.information-card strong {
    display: block;
    max-width: 100%;
    margin-top: 2px;
    overflow: hidden;
    color: var(--map-text);
    font-size: 0.69rem;
    font-weight: 800;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#coordinatesValue,
#distanceValue,
#accuracyValue,
#clickedCoordinateValue {
    direction: ltr;
    unicode-bidi: embed;
}

.edit-panel {
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + 74px);
    right: 12px;
    left: 12px;
    z-index: 1100;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 10px;
    color: #fff;
    background: rgba(24, 39, 35, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 17px;
    box-shadow: 0 12px 30px rgba(14, 32, 27, 0.18);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

    .edit-panel[hidden] {
        display: none;
    }

.edit-panel-copy {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
}

    .edit-panel-copy strong {
        display: block;
        font-size: 0.75rem;
    }

    .edit-panel-copy p {
        margin: 1px 0 0;
        color: rgba(255, 255, 255, 0.7);
        font-size: 0.64rem;
    }

.edit-panel-icon {
    display: grid;
    flex: 0 0 auto;
    width: 33px;
    height: 33px;
    place-items: center;
    color: #fff;
    background: var(--map-primary);
    border-radius: 10px;
}

    .edit-panel-icon svg {
        width: 17px;
        height: 17px;
    }

.edit-panel output {
    grid-column: 1 / -1;
    display: block;
    width: 100%;
    padding: 8px 10px;
    overflow: hidden;
    color: #d7f3ec;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-family: monospace;
    font-size: 0.68rem;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaflet-container,
.leaflet-popup-content,
.leaflet-tooltip,
.leaflet-control {
    font-family: "Vazir", "Vazirmatn", Tahoma, Arial, sans-serif;
}

.leaflet-top.leaflet-left {
    top: calc(max(12px, env(safe-area-inset-top)) + 72px);
    left: 10px;
}

.leaflet-control-zoom {
    overflow: hidden;
    border: 0 !important;
    border-radius: 13px !important;
    box-shadow: 0 8px 24px rgba(23, 44, 38, 0.16) !important;
}

    .leaflet-control-zoom a {
        width: 36px !important;
        height: 36px !important;
        color: var(--map-text) !important;
        background: rgba(255, 255, 255, 0.95) !important;
        border-bottom-color: var(--map-border) !important;
        line-height: 36px !important;
    }

.leaflet-popup-content-wrapper {
    border-radius: 15px;
    box-shadow: 0 12px 32px rgba(24, 44, 38, 0.18);
}

.leaflet-popup-content {
    min-width: 125px;
    margin: 11px 13px;
    direction: rtl;
    color: var(--map-text);
    font-size: 0.75rem;
    line-height: 1.8;
    text-align: right;
}

.leaflet-popup-tip {
    box-shadow: none;
}

.custom-location-icon {
    background: transparent;
    border: 0;
}

.location-icon-wrapper {
    position: relative;
    width: 28px;
    height: 32px;
}

.location-icon-image {
    display: grid;
    width: 26px;
    height: 26px;
    padding: 5px;
    place-items: center;
    background: var(--marker-color);
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
    transform: rotate(-45deg);
}

    .location-icon-image img {
        width: 14px;
        height: 14px;
        object-fit: contain;
        filter: brightness(0) invert(1);
        transform: rotate(45deg);
    }

.location-number {
    display: none;
}

.user-location-dot {
    position: relative;
    width: 22px;
    height: 22px;
    background: #1976d2;
    border: 4px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(21, 74, 126, 0.34), 0 0 0 7px rgba(25, 118, 210, 0.15);
}

    .user-location-dot::after {
        position: absolute;
        inset: -9px;
        content: "";
        border: 2px solid rgba(25, 118, 210, 0.32);
        border-radius: 50%;
        animation: user-location-pulse 1.8s ease-out infinite;
    }

.coordinate-marker {
    width: 18px;
    height: 18px;
    background: #e0a100;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 5px rgba(224, 161, 0, 0.22);
}

@keyframes user-location-pulse {
    0% {
        opacity: 1;
        transform: scale(0.65);
    }

    100% {
        opacity: 0;
        transform: scale(1.45);
    }
}

@media (max-width: 374px) {
    .map-topbar {
        right: 8px;
        left: 8px;
    }

    .brand-content p,
    .online-badge {
        display: none;
    }

    .brand-content h1 {
        max-width: 230px;
    }

    .control-sheet {
        max-height: 66dvh;
    }

    .sheet-content {
        max-height: calc( 66dvh - 58px - env(safe-area-inset-bottom) );
        padding-right: 11px;
        padding-left: 11px;
    }

    .sheet-heading h2 {
        font-size: 0.98rem;
    }

    .information-card {
        padding: 7px 8px;
    }
}

@media (min-width: 850px) {
    .map-topbar {
        top: 18px;
        right: 18px;
        left: auto;
        width: min(410px, calc(100% - 36px));
    }

    .control-sheet {
        top: 95px;
        right: 18px;
        bottom: 18px;
        left: auto;
        width: 370px;
        max-height: none;
        border: 1px solid rgba(255, 255, 255, 0.88);
        border-radius: 23px;
        box-shadow: 0 14px 45px rgba(24, 50, 43, 0.18);
        transform: none !important;
    }

    .sheet-toggle {
        display: none;
    }

    .sheet-content {
        max-height: 100%;
        padding: 15px;
    }

    .information-grid {
        grid-template-columns: 1fr;
    }

    .information-card {
        min-height: 61px;
    }

    .edit-panel {
        top: 18px;
        right: auto;
        left: 18px;
        width: 310px;
    }

    .leaflet-top.leaflet-left {
        top: 18px;
        left: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
