/* WorkerNet ERP — Map Popups & Bottom Sheets
   Стили для информационных окон на карте и мобильных панелей.
   Использует Glassmorphism переменные из design-tokens.css.
*/

/* --- Анимация появления попапа --- */
@keyframes erpds-popup-fade {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Leaflet Popup Customization --- */
.erpds-mpopup-wrap .leaflet-popup-content-wrapper {
    position: relative;
    background: transparent !important;
    color: var(--erpds-text, #1a1a1a) !important;
    border-radius: 16px;
    overflow: hidden;
    isolation: isolate;
    height: auto !important; /* Override legacy height: 0px hack */
}

.erpds-mpopup-wrap .leaflet-popup-content-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--erpds-glass-bg, rgba(255, 255, 255, 0.75));
    border: var(--erpds-glass-border);
    border-radius: inherit;
    box-shadow: var(--erpds-glass-shadow, 0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08));
    backdrop-filter: var(--erpds-glass-blur, blur(12px) saturate(180%));
    -webkit-backdrop-filter: var(--erpds-glass-blur, blur(12px) saturate(180%));
}

.erpds-mpopup-wrap .leaflet-popup-content-wrapper > * {
    position: relative;
    z-index: 1;
}

.erpds-mpopup-wrap .leaflet-popup-content {
    margin: 14px 16px;
    min-width: 280px;
}

.erpds-mpopup-wrap .leaflet-popup-tip {
    background: var(--erpds-glass-bg, rgba(255, 255, 255, 0.75)) !important;
    backdrop-filter: var(--erpds-glass-blur, blur(12px) saturate(180%));
    -webkit-backdrop-filter: var(--erpds-glass-blur, blur(12px) saturate(180%));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    border: var(--erpds-glass-border);
}

.erpds-mpopup-wrap .leaflet-popup-close-button {
    color: var(--erpds-text-muted, #555) !important;
    font-size: 16px !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    text-align: center !important;
    border-radius: 50% !important;
    top: 8px !important;
    right: 8px !important;
    transition: background 0.2s, color 0.2s;
    text-decoration: none !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.erpds-mpopup-wrap .leaflet-popup-close-button:hover {
    background: rgba(0, 0, 0, 0.05) !important;
    color: var(--erpds-text, #1a1a1a) !important;
}

/* --- Popup Content Structure --- */
.erpds-mpopup {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 280px;
    max-width: 360px;
    background: transparent;
    border-radius: 0;
    font-family: var(--erpds-sans, inherit);
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.erpds-mpopup__name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
    margin: 0;
    padding: 0;
    padding-right: 24px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.erpds-mpopup__name i {
    color: var(--erpds-text-faint, #6B7280);
    margin-top: 3px;
    font-size: 13px;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.erpds-mpopup__name > div { flex: 1; min-width: 0; }
.erpds-mpopup__name a { color: var(--erpds-text, #1a1a1a); text-decoration: none; transition: color 0.2s; }
.erpds-mpopup__name a:hover { color: var(--erpds-accent, #2A6AE0); }

.erpds-mpopup__address {
    font-size: 13px;
    color: var(--erpds-text-muted, #555);
    line-height: 1.4;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.erpds-mpopup__address i {
    color: var(--erpds-text-faint, #6B7280);
    margin-top: 3px;
    font-size: 14px;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.erpds-mpopup__address > div { flex: 1; min-width: 0; }

.erpds-mpopup__phone {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--erpds-text-muted, #555);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.erpds-mpopup__phone i {
    color: var(--erpds-text-faint, #6B7280);
    font-size: 13px;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.erpds-mpopup__phone a { color: var(--erpds-text-muted, #555); text-decoration: none; transition: color 0.2s; }
.erpds-mpopup__phone a:hover { color: var(--erpds-accent, #2A6AE0); }

.erpds-mpopup__balance {
    font-size: 13.5px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.erpds-mpopup__balance i {
    color: var(--erpds-text-faint, #6B7280);
    font-size: 12px;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.erpds-mpopup__balance > div { font-family: var(--erpds-mono, monospace); font-feature-settings: "tnum"; letter-spacing: -0.01em; }

.erpds-mpopup__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.erpds-mpopup__badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--erpds-radius-pill, 999px);
    line-height: 1.2;
    flex-shrink: 0;
    letter-spacing: 0.01em;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.erpds-mpopup__badge i { font-size: 9px; opacity: 0.8; margin-top: 1px; }

.erpds-mpopup__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--erpds-accent, #2A6AE0);
    text-decoration: none;
    font-weight: 600;
    margin: 0;
    padding: 6px 12px;
    border-radius: var(--erpds-radius-sm, 6px);
    background: var(--erpds-accent-soft, #e5eafb);
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.erpds-mpopup__link:hover {
    background: var(--erpds-accent, #2A6AE0);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(42, 106, 224, 0.3);
}
.erpds-mpopup__link i { opacity: .85; transition: transform 0.2s; }
.erpds-mpopup__link:hover i { transform: translateX(2px); }

/* --- Bottom Sheet (Mobile) --- */
.erpds-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--erpds-glass-bg, rgba(255, 255, 255, 0.85));
    backdrop-filter: var(--erpds-glass-blur, blur(16px) saturate(180%));
    -webkit-backdrop-filter: var(--erpds-glass-blur, blur(16px) saturate(180%));
    border-top: var(--erpds-glass-border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    padding: 24px 20px 32px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: none;
}

.erpds-bottom-sheet.active {
    display: block;
    transform: translateY(0);
}

.erpds-bottom-sheet--ready {
    box-shadow: 0 -12px 40px rgba(42, 106, 224, 0.22);
}

.erpds-bottom-sheet--ready .erpds-bottom-sheet__handle {
    width: 48px;
    background: var(--erpds-accent, #2A6AE0);
    transition: width 0.15s ease, background 0.15s ease;
}

.erpds-bottom-sheet__handle {
    width: 36px;
    height: 4px;
    background: var(--erpds-border, #ddd);
    border-radius: 2px;
    margin: -12px auto 20px;
}

.erpds-bottom-sheet .erpds-mpopup {
    max-width: none;
    min-width: 0;
}

.erpds-bottom-sheet__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--erpds-text-muted);
    cursor: pointer;
}

/* Overlay for Bottom Sheet */
.erpds-bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.erpds-bottom-sheet-overlay.active {
    display: block;
    opacity: 1;
}

/* --- Map Pin Customization --- */
.erpds-mpin-icon {
    background: none !important;
    border: none !important;
}

.erpds-mpin-wrap {
    width: 36px;
    height: 36px;
    background: var(--erpds-accent, #2d6bff);
    color: #fff;
    border-radius: 12px 12px 12px 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(45, 107, 255, 0.4);
    transform: rotate(-45deg);
    border: 2px solid #fff;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.15s ease;
}

.erpds-mpin-wrap i {
    transform: rotate(45deg);
}

.erpds-mpin-wrap:hover {
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 6px 16px rgba(45, 107, 255, 0.5);
}
