/**
 * Estilos unificados para LocationPickerModal
 * Componente reutilizable de selección de ubicación
 */

/* Modal principal */
.location-modal {
    position: fixed !important;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999 !important;
    padding: 16px;
}

.location-modal[aria-hidden="false"],
.location-modal.show {
    display: flex !important;
}

/* Backdrop */
.location-modal-backdrop {
    position: fixed !important;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99998 !important;
}

/* Contenedor del modal */
.location-modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999 !important;
}

/* Header */
.location-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.location-modal-back {
    background: none;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.location-modal-back:hover {
    background: #f3f4f6;
}

.location-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    flex: 1;
}

/* Aviso de privacidad */
.location-modal-privacy-notice {
    padding: 12px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
    color: #6b7280;
    text-align: center;
}

.location-modal-privacy-notice p {
    margin: 0;
}

/* Contexto form: ocultar tabs */
.location-modal-form-context .location-modal-tabs {
    display: none !important;
}

.location-modal-form-context .location-modal-body {
    padding-top: 20px;
}

/* Tabs */
.location-modal-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid #e9ecef;
    gap: 0;
    flex-shrink: 0;
}

.location-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 16px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.location-tab:hover {
    color: #00b487;
}

.location-tab.active {
    color: #00b487;
    border-bottom-color: #00b487;
}

/* Body */
.location-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.location-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.location-tab-content.active {
    display: flex;
}

/* Mapa */
#locationMapContainer {
    width: 100% !important;
    min-width: 100% !important;
    height: 400px !important;
    min-height: 400px !important;
    max-height: 400px !important;
    position: relative !important;
    overflow: hidden !important;
    background-color: #f0f0f0 !important;
    border-radius: 8px;
    margin-top: 16px;
}

#locationMapContainer .leaflet-container {
    width: 100% !important;
    height: 100% !important;
    min-height: 400px !important;
}

.location-tab-content.active #locationMapContainer {
    display: block !important;
    visibility: visible !important;
}

#locationMapLoading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
    z-index: 1000;
}

#locationMapLoading i {
    font-size: 24px;
    margin-bottom: 10px;
    display: block;
}

/* Barra de búsqueda */
.location-search-bar {
    position: relative;
    margin-bottom: 16px;
    z-index: 1001;
}

.location-search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    z-index: 2;
    font-size: 18px;
    pointer-events: none;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Botón de geolocalización sobre el mapa (arriba a la derecha) */
.geolocate-btn-map {
    position: absolute;
    top: 12px;
    right: 12px;
    background: white;
    border: 2px solid #00b487;
    color: #00b487;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Modal de datos de localización */
.location-data-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100001 !important; /* Por encima del modal de ubicación (99999) */
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.location-data-modal.show {
    opacity: 1;
}

.location-data-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    z-index: 100002;
}

.location-data-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 100003 !important;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.location-data-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.location-data-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.location-data-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.location-data-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.location-data-modal-body {
    padding: 24px;
}

.location-data-field {
    margin-bottom: 20px;
}

.location-data-field:last-child {
    margin-bottom: 0;
}

.location-data-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.location-data-field input[type="text"],
.location-data-field input[type="number"],
.location-data-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #111827;
    transition: border-color 0.2s;
    font-family: inherit;
}

.location-data-field input[readonly] {
    background: #f9fafb;
    color: #6b7280;
    cursor: not-allowed;
}

.location-data-field input:focus,
.location-data-field textarea:focus {
    outline: none;
    border-color: #00b487;
    box-shadow: 0 0 0 3px rgba(0, 180, 135, 0.1);
}

.location-data-field textarea {
    resize: vertical;
    min-height: 80px;
}

.location-data-modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
}

.location-data-modal-save,
.location-data-modal-cancel {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.location-data-modal-save {
    background: #00b487;
    color: white;
}

.location-data-modal-save:hover {
    background: #009973;
}

.location-data-modal-cancel {
    background: #f3f4f6;
    color: #374151;
}

.location-data-modal-cancel:hover {
    background: #e5e7eb;
}

.geolocate-btn-map:hover {
    background: #00b487;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 180, 135, 0.3);
    transform: translateY(-1px);
}

.geolocate-btn-map:active {
    transform: translateY(0);
}

.geolocate-btn-map:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: white;
    color: #00b487;
}

.geolocate-btn-map i {
    font-size: 16px;
}

.geolocate-btn-map span {
    font-size: 14px;
    font-weight: 600;
}

.location-search-bar input {
    width: 100%;
    padding: 12px 50px 12px 44px;
    border: 1px solid #e2e4e9;
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
    background: white;
}

.location-search-bar input:focus {
    outline: none;
    border-color: #00b487;
    box-shadow: 0 0 0 3px rgba(0, 180, 135, 0.1);
}

.clear-search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    z-index: 11;
    transition: all 0.2s ease;
}

.clear-search-btn:hover {
    color: #6b7280;
    background-color: #f3f4f6;
}

/* Slider de distancia */
.location-distance-slider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

.location-distance-slider span {
    font-size: 14px;
    color: #6b7280;
    min-width: 60px;
    font-weight: 500;
}

.location-distance-slider input[type="range"] {
    flex: 1;
    height: 4px;
    background: #e2e4e9;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.location-distance-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #00b487;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.location-distance-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.location-distance-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #00b487;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: transform 0.2s;
}

.location-distance-slider input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

/* Botón aplicar */
.apply-location-filter-btn {
    width: 100%;
    padding: 16px 20px;
    background: #00b487;
    border: none;
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 24px;
    margin-bottom: 0;
    transition: all 0.2s;
    position: sticky;
    bottom: 0;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.apply-location-filter-btn:hover {
    background: #00a077;
}

.apply-location-filter-btn:active {
    background: #008f68;
}

/* Botón aplicar naranja (CTA principal) */
.apply-location-filter-btn-orange {
    background: #FF6600 !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1), 0 4px 15px rgba(255, 102, 0, 0.4) !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 100 !important;
    margin-top: auto !important; /* Empujar al final del contenedor */
}

.apply-location-filter-btn-orange:hover {
    background: #E55A00 !important;
    box-shadow: 0 6px 20px rgba(255, 102, 0, 0.4);
    transform: translateY(-2px);
}

.apply-location-filter-btn-orange:active {
    background: #CC4A00 !important;
    transform: translateY(0);
}

/* Lista de sugerencias */
.location-suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e4e9;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 0;
}

.location-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s;
}

.location-suggestion-item:last-child {
    border-bottom: none;
}

.location-suggestion-item:hover {
    background: #f9fafb;
}

.location-suggestion-item i {
    color: #9ca3af;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.location-suggestion-text {
    flex: 1;
    font-size: 16px;
    color: #1f2937;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.location-suggestion-type {
    font-size: 12px;
    color: #6b7280;
    font-weight: 400;
}

/* Responsive */
@media (max-width: 768px) {
    .location-modal {
        padding: 8px;
    }
    
    .location-modal-content {
        max-height: 95vh;
        border-radius: 12px;
    }
    
    .location-modal-header {
        padding: 12px 16px;
    }
    
    .location-modal-title {
        font-size: 16px;
    }
    
    .location-modal-tabs {
        padding: 0 16px;
    }
    
    .location-tab {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .location-modal-body {
        padding: 16px;
    }
    
    #locationMapContainer {
        height: 300px !important;
        min-height: 300px !important;
        max-height: 300px !important;
    }
    
    #locationMapContainer .leaflet-container {
        min-height: 300px !important;
    }
    
    .location-distance-slider {
        margin: 16px 0;
    }
    
    .apply-location-filter-btn {
        padding: 12px 16px;
        font-size: 15px;
        margin-top: 16px;
        width: calc(100% - 32px); /* Ajustar al padding del body en móvil */
        max-width: calc(100% - 32px);
        position: sticky;
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    .location-modal {
        padding: 0;
    }
    
    .location-modal-content {
        max-height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    
    #locationMapContainer {
        height: 250px !important;
        min-height: 250px !important;
        max-height: 250px !important;
    }
    
    #locationMapContainer .leaflet-container {
        min-height: 250px !important;
    }
}

/* Toast informativo de datos de localización */
.location-data-info {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 280px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 100000;
    display: none;
    border: 1px solid #e0e0e0;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.location-data-info.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.location-data-info.toast-hide {
    opacity: 0;
    transform: translateX(100%);
}

.location-data-info-header {
    padding: 10px 14px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px 8px 0 0;
}

.location-data-info-header h4 {
    margin: 0;
    color: white;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.location-data-info-header h4 i {
    font-size: 14px;
}

.location-data-info-body {
    padding: 10px 14px;
    max-height: 300px;
    overflow-y: auto;
}

.location-data-info-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    gap: 8px;
}

.location-data-info-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.location-data-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 80px;
}

.location-data-value {
    font-size: 12px;
    color: #333;
    word-break: break-word;
    line-height: 1.3;
    text-align: right;
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .location-data-info {
        width: calc(100vw - 40px);
        max-width: 300px;
        top: 10px;
        right: 10px;
    }
    
    .location-data-info-header {
        padding: 8px 12px;
    }
    
    .location-data-info-header h4 {
        font-size: 12px;
    }
    
    .location-data-info-body {
        padding: 8px 12px;
    }
    
    .location-data-label {
        font-size: 10px;
        min-width: 70px;
    }
    
    .location-data-value {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .location-data-info {
        width: calc(100vw - 20px);
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

