/* css/popups.css */

/* ========================================
   LEYENDA
   ======================================== */
.legend-container {
    position: absolute;
    bottom: 30px;
    right: 15px;
    width: 130px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 10px;
    font-family: 'Segoe UI', sans-serif;
}

.legend-header {
    font-size: 11px;
    font-weight: bold;
    color: #333;
    text-transform: uppercase;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 11px;
    gap: 8px;
}

.legend-symbol.line {
    width: 20px;
    height: 4px;
    background-color: #ce0cae;
    border-radius: 2px;
}

/* ========================================
   POPUP RESPONSIVE — Leaflet nativo
   ======================================== */
.leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    max-height: 70vh !important;
}

.leaflet-popup-content {
    margin: 12px !important;
    max-height: 65vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.leaflet-popup-content::-webkit-scrollbar {
    width: 4px;
}

.leaflet-popup-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.leaflet-popup-tip {
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
}

/* Pantallas pequeñas */
@media (max-width: 576px) {
    .leaflet-popup-content {
        max-width: calc(100vw - 24px) !important;
        max-height: 50vh !important;
        font-size: 12px !important;
    }

    .leaflet-popup-content-wrapper {
        max-height: 55vh !important;
    }

    /* Anular min-width inline de los templates */
    .leaflet-popup-content [style*="min-width"] {
        min-width: auto !important;
        width: 100% !important;
    }

    .leaflet-popup-content hr {
        margin: 4px 0 !important;
    }
}

/* ========================================
   PANEL FLOTANTE (arrastrable)
   ======================================== */
.floating-popup-panel {
    position: absolute;
    z-index: 10000;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.25);
    width: min(380px, calc(100vw - 32px));
    max-height: 70vh;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
    bottom: 24px;
    right: 24px;
    animation: floatingPopupIn 0.25s ease-out;
}

.floating-popup-panel.visible {
    display: flex;
}

@keyframes floatingPopupIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.floating-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
}

.floating-popup-header:active {
    cursor: grabbing;
}

.floating-popup-title {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.floating-popup-title i {
    color: #C68A2C;
    font-size: 14px;
}

.floating-popup-close {
    border: none;
    background: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.floating-popup-close:hover {
    background: #e9ecef;
    color: #000;
}

.floating-popup-body {
    overflow-y: auto;
    padding: 14px 16px;
    flex: 1;
    max-height: calc(70vh - 46px);
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.floating-popup-body::-webkit-scrollbar {
    width: 4px;
}

.floating-popup-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* Ajustes de contenido dentro del panel flotante */
.floating-popup-body div[style*="min-width"] {
    min-width: auto !important;
    width: 100% !important;
}

.floating-popup-body .d-grid .btn {
    font-size: 12px;
    padding: 4px 10px;
}

/* Móvil: panel flotante ocupa todo el ancho */
@media (max-width: 576px) {
    .floating-popup-panel {
        bottom: 8px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: 60vh;
    }

    .floating-popup-body {
        padding: 10px 12px;
        max-height: calc(60vh - 46px);
    }
}
