/* Overlay */
#sff-map-overlay,
#sff-map-address-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

#sff-map-modal,
#sff-map-address-modal {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 95vw;
    max-width: 900px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#sff-map-header,
#sff-map-address-modal .sff-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(90deg, #0f5ef7, #1fb6ff);
    color: #ffffff;
}

#sff-map-title,
#sff-map-address-modal .sff-map-title {
    font-size: 15px;
    font-weight: 600;
}

#sff-map-close,
#sff-map-address-modal .sff-map-close {
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

#sff-map-container,
#sff-map-address-container {
    flex: 1;
}

#sff-map-footer,
#sff-map-address-modal .sff-map-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
    font-size: 13px;
}

#sff-map-coords,
#sff-map-address-coords {
    color: #333333;
}

#sff-map-actions,
#sff-map-address-modal .sff-map-actions {
    display: flex;
    gap: 8px;
}

#sff-map-actions button,
#sff-map-address-modal .sff-map-actions button {
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 500;
}

#sff-map-locate,
#sff-map-address-locate {
    background: #f0f7ff;
    color: #0f5ef7;
    border-color: #0f5ef7;
}

#sff-map-locate:hover,
#sff-map-address-locate:hover {
    background: #e0efff;
}

.sff-map-locate-btn {
    align-self: flex-start;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid #0f5ef7;
    background: #f0f7ff;
    color: #0f5ef7;
    cursor: pointer;
    margin-bottom: 4px;
}

.sff-map-locate-btn:hover {
    background: #e0efff;
}

#sff-map-cancel,
#sff-map-address-cancel {
    background: #ffffff;
    color: #555555;
    border-color: #d0d0d0;
}

#sff-map-cancel:hover,
#sff-map-address-cancel:hover {
    background: #f3f3f3;
}

#sff-map-save,
#sff-map-address-save {
    background: #0f5ef7;
    color: #ffffff;
    border-color: #0f5ef7;
}

#sff-map-save:disabled,
#sff-map-address-save:disabled {
    opacity: 0.6;
    cursor: default;
}

#sff-map-save:not(:disabled):hover,
#sff-map-address-save:not(:disabled):hover {
    background: #0b4ac4;
    border-color: #0b4ac4;
}

/* Wrapper и преглед около полето */
.sff-map-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
}

.sff-map-preview {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px dashed #c0c4cc;
    background: #f9fafb;
    font-size: 12px;
    color: #666666;
}

.sff-map-preview--has-value {
    border-style: solid;
    border-color: #0f5ef7;
    background: #eef3ff;
    color: #1a2a6b;
}

.sff-map-open-btn {
    align-self: flex-start;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    border: 1px solid #0f5ef7;
    background: #0f5ef7;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sff-map-open-btn:hover {
    background: #0b4ac4;
    border-color: #0b4ac4;
}

/* Leaflet override за да запълни контейнера в overlay */
#sff-map-container .leaflet-container,
#sff-map-address-container .leaflet-container,
#sff-poly-map-container .leaflet-container {
    width: 100%;
    height: 100%;
}

/* Skeleton докато картата се зарежда */
.sff-map-skeleton {
    background: linear-gradient(90deg, #e8ecf2 25%, #f0f3f7 50%, #e8ecf2 75%);
    background-size: 200% 100%;
    animation: sff-map-skeleton 1.2s ease-in-out infinite;
}

@keyframes sff-map-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Търсене на адрес (Map Pick Address) */
.sff-map-search-row {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.sff-map-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
}

.sff-map-search-btn {
    padding: 8px 14px;
    border: 1px solid #0f5ef7;
    background: #0f5ef7;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.sff-map-search-btn:hover {
    background: #0b4ac4;
    border-color: #0b4ac4;
}

/* Inline frame карта до полето */
.sff-map-frame {
    margin-top: 4px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dde3ee;
    background: #f5f7fb;
    height: 220px;
}

.sff-map-frame .leaflet-container {
    width: 100%;
    height: 100%;
}

/* ── Polygon overlay (ползва същата естетика) ───────────────────────────── */
#sff-poly-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

#sff-poly-modal {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 95vw;
    max-width: 900px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#sff-poly-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(90deg, #0f5ef7, #1fb6ff);
    color: #ffffff;
}

#sff-poly-title {
    font-size: 15px;
    font-weight: 600;
}

#sff-poly-close {
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

#sff-poly-map-container {
    flex: 1;
}

#sff-poly-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
    font-size: 13px;
}

#sff-poly-info {
    color: #333333;
}

#sff-poly-actions {
    display: flex;
    gap: 8px;
}

#sff-poly-actions button {
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 500;
}

#sff-poly-clear {
    background: #ffffff;
    color: #555555;
    border-color: #d0d0d0;
}

#sff-poly-locate {
    background: #f0f7ff;
    color: #0f5ef7;
    border-color: #0f5ef7;
}

#sff-poly-locate:hover {
    background: #e0efff;
}

#sff-poly-clear:hover {
    background: #f3f3f3;
}

#sff-poly-cancel {
    background: #ffffff;
    color: #555555;
    border-color: #d0d0d0;
}

#sff-poly-cancel:hover {
    background: #f3f3f3;
}

#sff-poly-save {
    background: #0f5ef7;
    color: #ffffff;
    border-color: #0f5ef7;
}

#sff-poly-save:disabled {
    opacity: 0.6;
    cursor: default;
}

#sff-poly-save:not(:disabled):hover {
    background: #0b4ac4;
    border-color: #0b4ac4;
}

