/* ─────────────────────────────────────────────────
   STO Map Widget – Styles
   Dark industrial aesthetic: precise, confident, bold
───────────────────────────────────────────────── */

/* WRAPPER */
.sto-map-wrapper {
    position: relative;
    display: flex;
    border-radius: 16px;
    overflow: hidden;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #1A1D23;
    box-shadow: 0 24px 64px rgba(0,0,0,0.35);
    align-items: stretch;
}

.sto-map-wrapper.has-sidebar.sidebar-left  { flex-direction: row; }
.sto-map-wrapper.has-sidebar.sidebar-right { flex-direction: row-reverse; }
.sto-map-wrapper.has-sidebar.sidebar-bottom{ flex-direction: column; }

/* ─── MAP CONTAINER ─── */
.sto-map-container {
    flex: 1;
    min-width: 0;
    height: 560px;
    z-index: 1;
    flex-shrink: 0;
    align-self: auto;
}

/* ─── LEAFLET OVERRIDES ─── */
.sto-map-wrapper .leaflet-tile-pane { filter: saturate(0.9) brightness(0.95); }

.sto-map-wrapper .leaflet-popup-content-wrapper {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}
.sto-map-wrapper .leaflet-popup-content { margin: 0; }
.sto-map-wrapper .leaflet-popup-tip-container { display: none; }
.sto-map-wrapper .leaflet-popup-close-button {
    color: #8B92A5 !important;
    font-size: 18px !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 10;
}
.sto-map-wrapper .leaflet-popup-close-button:hover { color: #fff !important; }

.sto-map-wrapper .leaflet-control-zoom a {
    background: #22262F;
    color: #CBD0DC;
    border-color: #2F3440;
}
.sto-map-wrapper .leaflet-control-zoom a:hover {
    background: #2F3440;
    color: #fff;
}

/* ─── SIDEBAR ─── */
.sto-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: #1A1D23;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.06);
    z-index: 2;
}
.sidebar-right .sto-sidebar { border-right: none; border-left: 1px solid rgba(255,255,255,0.06); }

.sto-sidebar-bottom {
    width: 100%;
    height: 140px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* SIDEBAR HEADER */
.sto-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sto-sidebar-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.03em;
    margin: 0;
}
.sto-count {
    font-size: 12px;
    color: #8B92A5;
    background: rgba(255,255,255,0.06);
    padding: 3px 10px;
    border-radius: 20px;
}

/* LIST */
.sto-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sto-list::-webkit-scrollbar { width: 4px; }
.sto-list::-webkit-scrollbar-track { background: transparent; }
.sto-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.sto-list-horizontal {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    gap: 8px;
}

/* LIST ITEM */
.sto-sidebar-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #22262F;
    border-radius: 10px;
    padding: 14px 14px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .2s, border-left-color .2s, transform .15s;
    position: relative;
}
.sto-sidebar-item:last-child { margin-bottom: 0; }
.sto-sidebar-item:hover {
    background: #272C37;
    border-left-color: var(--pin-color, #E63946);
    transform: translateX(2px);
}
.sto-active-item {
    background: #272C37 !important;
    border-left-color: var(--pin-color, #E63946) !important;
}
.sto-sidebar-item.sto-hidden { display: none; }

/* Horizontal variant */
.sto-list-horizontal .sto-sidebar-item {
    flex-direction: column;
    min-width: 180px;
    margin-bottom: 0;
    flex-shrink: 0;
}

/* INDEX BADGE */
.sto-item-left { flex-shrink: 0; }
.sto-item-index {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #E63946;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ITEM BODY */
.sto-item-body { flex: 1; min-width: 0; }
.sto-item-name {
    font-size: 13.5px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 5px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sto-item-address {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    font-size: 12px;
    color: #8B92A5;
    line-height: 1.4;
    margin-bottom: 6px;
}
.sto-item-address svg { width: 12px; height: 12px; flex-shrink: 0; margin-top: 1px; }
.sto-item-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
}
.sto-item-meta svg { width: 11px; height: 11px; color: #8B92A5; flex-shrink: 0; }
.sto-item-meta span { font-size: 11.5px; color: #8B92A5; }

/* SERVICE TAGS */
.sto-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.sto-tag {
    font-size: 10.5px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(230,57,70,0.12);
    color: #E63946;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.sto-tag-more { background: rgba(255,255,255,0.07); color: #8B92A5; }

/* ─── POPUP (desktop) ─── */
.sto-popup-inner {
    background: #1A1D23;
    border-radius: 12px;
    overflow: hidden;
    width: 280px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
.sto-popup-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    position: relative;
}
.sto-popup-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8B92A5;
    margin-bottom: 5px;
}
.sto-popup-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    margin-bottom: 4px;
}
.sto-popup-address {
    font-size: 12px;
    color: #8B92A5;
    display: flex;
    align-items: flex-start;
    gap: 5px;
    line-height: 1.4;
}
.sto-popup-address svg { width: 12px; height: 12px; flex-shrink: 0; margin-top: 1px; }
.sto-popup-body { padding: 12px 18px 16px; }
.sto-popup-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}
.sto-popup-row:last-child { margin-bottom: 0; }
.sto-popup-row-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sto-popup-row-icon svg { width: 13px; height: 13px; color: #8B92A5; }
.sto-popup-row-content { flex: 1; }
.sto-popup-row-label {
    font-size: 10px;
    color: #5A6070;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}
.sto-popup-row-value {
    font-size: 12.5px;
    color: #CBD0DC;
    line-height: 1.45;
}
.sto-popup-row-value a { color: inherit; text-decoration: none; }
.sto-popup-row-value a:hover { color: #fff; }
.sto-popup-desc {
    font-size: 12px;
    color: #8B92A5;
    line-height: 1.6;
    padding: 10px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
}
.sto-popup-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 18px 0;
}
.sto-popup-actions {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid rgba(255,255,255,0.07);
}
.sto-popup-btn {
    flex: 1;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: opacity .15s, transform .15s;
    letter-spacing: 0.02em;
    display: inline-block;
    border: 1px solid;
}
.sto-popup-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.sto-popup-btn:not(.sto-popup-btn-outline) {
    background: #E63946;
    border-color: #E63946;
    color: #fff;
}
.sto-popup-btn-outline {
    background: transparent;
    color: #E63946;
    border-color: #E63946;
}

/* ─── CUSTOM PIN MARKER ─── */
.sto-pin-marker { position: relative; cursor: pointer; }
.sto-pin-outer {
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: transform .2s, box-shadow .2s;
    border: 2px solid rgba(255,255,255,0.25);
}
.sto-pin-outer:hover, .sto-pin-active .sto-pin-outer {
    transform: rotate(-45deg) scale(1.15);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.sto-pin-num {
    transform: rotate(45deg);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    font-family: 'DM Sans', sans-serif;
    line-height: 1;
}
.sto-pin-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    animation: stoPinPulse 2.5s infinite;
    opacity: 0;
}
@keyframes stoPinPulse {
    0%   { transform: translate(-50%,-50%) rotate(-45deg) scale(1); opacity: 0.5; }
    70%  { transform: translate(-50%,-50%) rotate(-45deg) scale(1.8); opacity: 0; }
    100% { opacity: 0; }
}

/* ══════════════════════════════════════════════
   MOBILE: тільки карта + bottom sheet
══════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Сайдбар — повністю прихований */
    .sto-sidebar {
        display: none !important;
    }
    /* Карта — на весь екран */
    .sto-map-container {
        height: 100svh !important;
        height: 100vh !important;
        border-radius: 0;
    }
    .sto-map-wrapper {
        border-radius: 0;
        box-shadow: none;
        flex-direction: column;
    }
    /* Popup leaflet на мобільному теж вимикаємо (через JS) */
}

/* ─── BOTTOM SHEET (mobile) ─── */
/* JS додає display:block на мобільних і керує класом sto-sheet-open */
.sto-mobile-sheet {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: #1A1D23;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.55);
    border-top: 1px solid rgba(255,255,255,0.08);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    transform: translateY(110%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    /* Безпечна зона знизу для iPhone */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sto-mobile-sheet.sto-sheet-visible {
    display: block; /* JS робить видимим на мобільних одразу при init */
}
.sto-mobile-sheet.sto-sheet-open {
    transform: translateY(0);
}

/* Ручка-індикатор */
.sto-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.18);
    border-radius: 2px;
    margin: 12px auto 0;
}

/* Кнопка закрити */
.sto-sheet-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 50%;
    color: #8B92A5;
    font-size: 18px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, color 0.2s;
}
.sto-sheet-close:hover,
.sto-sheet-close:active { background: rgba(255,255,255,0.16); color: #fff; }

/* Скролл-область */
.sto-sheet-content {
    max-height: 75vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 16px;
}

/* Шапка */
.sto-sheet-header {
    padding: 8px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sto-sheet-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8B92A5;
    margin-bottom: 5px;
}
.sto-sheet-name {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    margin-bottom: 6px;
}
.sto-sheet-address {
    font-size: 13px;
    color: #8B92A5;
    display: flex;
    align-items: flex-start;
    gap: 5px;
    line-height: 1.4;
}
.sto-sheet-address svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 2px; }

/* Рядки деталей */
.sto-sheet-body { padding: 12px 18px 8px; }
.sto-sheet-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.sto-sheet-row:last-child { margin-bottom: 0; }
.sto-sheet-row-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sto-sheet-row-icon svg { width: 14px; height: 14px; color: #8B92A5; }
.sto-sheet-row-content { flex: 1; padding-top: 2px; }
.sto-sheet-row-label {
    font-size: 10px;
    color: #5A6070;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}
.sto-sheet-row-value { font-size: 14px; color: #CBD0DC; line-height: 1.45; }
.sto-sheet-row-value a { color: inherit; text-decoration: none; }

/* Теги */
.sto-sheet-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px 18px 4px;
}

/* Опис */
.sto-sheet-desc {
    font-size: 13px;
    color: #8B92A5;
    line-height: 1.6;
    padding: 10px 18px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
}

/* Кнопки */
.sto-sheet-actions {
    display: flex;
    gap: 10px;
    padding: 12px 18px 4px;
    border-top: 1px solid rgba(255,255,255,0.07);
}
.sto-sheet-btn {
    flex: 1;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    letter-spacing: 0.02em;
    display: inline-block;
    border: 1px solid;
}
.sto-sheet-btn:active { opacity: 0.8; transform: scale(0.98); }
.sto-sheet-btn:not(.sto-sheet-btn-outline) {
    background: #E63946;
    border-color: #E63946;
    color: #fff;
}
.sto-sheet-btn-outline {
    background: transparent;
    color: #E63946;
    border-color: #E63946;
}

/* Overlay затемнення */
.sto-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    transition: opacity 0.3s;
}
.sto-sheet-overlay.sto-sheet-visible { display: block; }
.sto-sheet-overlay.sto-sheet-open   { opacity: 1; }
