/* WooCommerce Direcciones Múltiples - Estilos */

/* Wrapper del mapa en checkout */
.wdm-checkout-map-wrapper {
    animation: fadeIn 0.4s ease-in;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sección del mapa */
.wdm-map-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 30px;
}

.wdm-map-section h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buscador de direcciones */
.wdm-address-search {
    position: relative;
}

.wdm-address-search-input {
    border: 2px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    transition: all 0.3s !important;
}

.wdm-address-search-input:focus {
    border-color: #27ae60 !important;
    outline: none !important;
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.3) !important;
}

#wdm-address-search {
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

#wdm-address-search:focus {
    border-color: #27ae60;
    outline: none;
    box-shadow: 0 0 5px rgba(39, 174, 96, 0.3);
}

/* Resultados de búsqueda */
.wdm-search-results {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    margin-top: 5px;
    max-height: 250px;
}

.wdm-search-results > div {
    transition: background-color 0.2s;
}

.wdm-search-results > div:last-child {
    border-bottom: none;
}

.wdm-search-results > div:hover {
    background-color: #e8f5e9 !important;
    border-left: 3px solid #27ae60;
    padding-left: 9px;
}

#wdm-search-results {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    margin-top: 5px;
}

#wdm-search-results > div {
    transition: background-color 0.2s;
}

#wdm-search-results > div:last-child {
    border-bottom: none;
}

/* Contenedor del mapa */
#wdm-map,
[id^="wdm-checkout-map-"] {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s;
    border-radius: 5px;
    overflow: hidden;
}

/* Tabla de direcciones */
.my-account-addresses {
    border: 1px solid #e0e0e0;
}

.my-account-addresses thead {
    background: #f8f9fa;
}

.my-account-addresses th {
    font-weight: 600;
    color: #333;
    padding: 12px !important;
}

.my-account-addresses td {
    padding: 15px !important;
    vertical-align: middle;
}

.my-account-addresses .default-address {
    background-color: #f8f9fa;
    border-left: 4px solid #27ae60;
}

.my-account-addresses .button {
    margin-right: 5px;
    margin-bottom: 5px;
}

/* Selector en checkout para usuarios registrados */
.wdm-address-selector-wrapper {
    margin-bottom: 20px;
    padding-bottom: 15px;
    animation: fadeIn 0.3s;
}

.wdm-address-selector {
    font-size: 14px;
}

.wdm-address-selector + .select2-container {
    margin-bottom: 10px;
}

.select2-container--default .select2-selection--single {
    border: 1px solid #ddd;
    border-radius: 4px;
    height: 40px;
    padding-top: 5px;
}

.select2-container--default .select2-selection--single:focus {
    border-color: #27ae60;
    outline: none;
}

.wdm-show-map-btn {
    margin-top: 10px;
    background: #27ae60;
    color: white;
    border: none;
    transition: background 0.3s;
}

.wdm-show-map-btn:hover {
    background: #229954;
    color: white;
}

/* Formulario de dirección */
#wdm-address-form .form-row {
    margin-bottom: 15px;
}

#wdm-address-form label {
    font-weight: 600;
    color: #333;
}

#wdm-address-form .input-text,
#wdm-address-form select,
#wdm-address-form textarea {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    font-size: 14px;
    transition: border-color 0.3s;
}

#wdm-address-form .input-text:focus,
#wdm-address-form select:focus,
#wdm-address-form textarea:focus {
    border-color: #27ae60;
    outline: none;
    box-shadow: 0 0 5px rgba(39, 174, 96, 0.2);
}

/* Botones */
#wdm-address-form button[type="submit"] {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

#wdm-address-form button[type="submit"]:hover {
    background: #229954;
}

/* Botón de geolocalización */
.wdm-geolocation-btn {
    transition: all 0.3s;
    font-size: 14px;
    padding: 10px 20px;
}

.wdm-geolocation-btn:hover {
    background: #2980b9 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.wdm-geolocation-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #95a5a6 !important;
    transform: none !important;
}

/* Leaflet popup personalizado */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    font-size: 14px;
    line-height: 1.5;
}

/* Marcador personalizado */
.leaflet-marker-icon {
    transition: transform 0.2s;
}

.leaflet-marker-icon:hover {
    transform: scale(1.1);
}

/* Controles del mapa */
.leaflet-control-zoom {
    border-radius: 4px;
    overflow: hidden;
}

.leaflet-control-zoom a {
    transition: background-color 0.2s;
}

/* Mensaje de tip */
.wdm-map-section > p:last-child {
    background: #e8f5e9;
    padding: 10px;
    border-radius: 4px;
    border-left: 3px solid #27ae60;
}

.wdm-map-section > p {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Divider entre selector y mapa */
.wdm-checkout-map-wrapper > div[style*="border-top"] {
    margin: 15px 0;
}

/* Badge para coordenadas guardadas */
.my-account-addresses td span[style*="color: #27ae60"] {
    font-size: 18px;
    vertical-align: middle;
}

.my-account-addresses td span[style*="color: #27ae60"]::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    margin-right: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Loading spinner para búsqueda */
.wdm-address-search-input.loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 50 50'%3E%3Cpath fill='%2327ae60' d='M25,5A20.14,20.14,0,0,1,45,22.88a2.51,2.51,0,0,0,2.49,2.26h0A2.52,2.52,0,0,0,50,22.33a25.14,25.14,0,0,0-50,0,2.52,2.52,0,0,0,2.5,2.81h0A2.51,2.51,0,0,0,5,22.88,20.14,20.14,0,0,1,25,5Z'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.6s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Tooltip personalizado */
.wdm-tooltip {
    position: relative;
    display: inline-block;
}

.wdm-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: #333;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

/* Indicador de carga */
.woocommerce-checkout.processing {
    opacity: 0.6;
}

/* Mejora de accesibilidad */
.wdm-address-selector:focus,
.wdm-address-search-input:focus,
#wdm-address-search:focus,
.wdm-show-map-btn:focus,
.wdm-geolocation-btn:focus {
    outline: 2px solid #27ae60;
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    .wdm-checkout-map,
    #wdm-map,
    [id^="wdm-checkout-map-"] {
        height: 300px !important;
    }
    
    .my-account-addresses {
        font-size: 13px;
    }
    
    .my-account-addresses .button {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .wdm-map-section {
        padding: 15px;
    }
    
    .wdm-checkout-map-wrapper {
        padding: 15px !important;
    }
    
    .wdm-address-search-input {
        font-size: 13px !important;
    }
    
    .wdm-geolocation-btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .wdm-checkout-map,
    #wdm-map,
    [id^="wdm-checkout-map-"] {
        height: 250px !important;
    }
    
    .wdm-map-section h4 {
        font-size: 16px;
    }
}