/**
 * Estilos del Sistema de Selector de Ubicación
 * Similar a Mercado Libre
 * 
 * @version 1.0
 * @author Desarmaduria IPAR
 */

/* ========================================
   Selector de Ubicación en Header
   ======================================== */

.header-location-wrapper {
    position: relative;
    z-index: 1;
}

.location-selector {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    color: #333;
    white-space: nowrap;
    position: relative;
    z-index: 1;
    line-height: 1.2;
}

.location-selector:hover {
    border-color: #fed700;
    background: #fffef5;
}

.location-selector .fa-map-marker {
    color: #fed700;
    font-size: 12px;
}

.location-selector .location-text {
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}

.location-selector .fa-chevron-down {
    font-size: 9px;
    color: #666;
}

/* ========================================
   Modal de Selección de Ubicación
   ======================================== */

.location-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.location-modal.active {
    display: flex;
}

.location-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.location-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    z-index: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

.location-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.location-modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

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

.location-modal-description {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

/* ========================================
   Formulario de Ubicación
   ======================================== */

.location-form .form-group {
    margin-bottom: 16px;
}

.location-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.location-form .form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    height: auto;
    min-height: 42px;
    transition: border-color 0.2s ease;
    background: #fff;
}

.location-form .form-control:focus {
    outline: none;
    border-color: #fed700;
    box-shadow: 0 0 0 3px rgba(254, 215, 0, 0.1);
}

.location-form .form-control:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Estilos específicos para select */
.location-form select.form-control {
    padding: 10px 14px;
    height: 44px;
    line-height: 1.6;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
}

.location-form select.form-control option {
    padding: 8px;
    line-height: 1.6;
}

/* ========================================
   Información de Envío
   ======================================== */

.shipping-info {
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #fed700;
}

.shipping-info-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.shipping-info .fa-truck {
    font-size: 24px;
    color: #fed700;
    margin-top: 2px;
}

.shipping-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.shipping-details strong {
    font-size: 15px;
    color: #333;
}

.shipping-details .shipping-time {
    font-size: 13px;
    color: #666;
}

/* ========================================
   Botones
   ======================================== */

.location-form .btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.location-form .btn-primary {
    background: #fed700;
    color: #333;
}

.location-form .btn-primary:hover:not(:disabled) {
    background: #e5c200;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(254, 215, 0, 0.3);
}

.location-form .btn-primary:disabled {
    background: #ddd;
    color: #999;
    cursor: not-allowed;
    transform: none;
}

.location-form .btn-block {
    width: 100%;
    display: block;
}

/* ========================================
   Costos de Envío en Productos
   ======================================== */

.product-shipping-cost {
    display: none;
    margin: 16px 0;
    padding: 14px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    font-size: 14px;
    line-height: 1.6;
}

.product-shipping-cost .fa {
    margin-right: 8px;
    color: #fed700;
}

.product-shipping-cost strong {
    color: #333;
    font-weight: 600;
}

.product-shipping-cost .shipping-time {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: #666;
}

.product-shipping-cost a {
    color: #36c;
    text-decoration: none;
    font-weight: 500;
}

.product-shipping-cost a:hover {
    text-decoration: underline;
}

/* ========================================
   Notificaciones
   ======================================== */

.location-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #27ae60;
    color: #fff;
    padding: 14px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10001;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.location-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.location-notification .fa-check-circle {
    font-size: 18px;
}

.location-notification span {
    font-size: 14px;
    font-weight: 500;
}

/* ========================================
   Envío Gratis Badge
   ======================================== */

.free-shipping-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #27ae60;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 3px;
    margin-left: 8px;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablets */
@media (max-width: 768px) {
    .location-selector .location-text {
        max-width: 150px;
    }
    
    .location-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .location-modal-header {
        padding: 16px 20px;
    }
    
    .location-modal-header h3 {
        font-size: 18px;
    }
    
    .location-modal-body {
        padding: 20px;
    }
    
    .location-notification {
        bottom: 15px;
        right: 15px;
        left: 15px;
        max-width: none;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .location-selector {
        padding: 5px 10px;
        font-size: 12px;
        gap: 4px;
    }
    
    .location-selector .location-text {
        max-width: 100px;
    }
    
    .location-selector .fa-map-marker {
        font-size: 12px;
    }
    
    .location-modal-content {
        border-radius: 0;
        max-height: 100vh;
        height: 100%;
    }
    
    .location-modal-header {
        padding: 14px 16px;
    }
    
    .location-modal-header h3 {
        font-size: 16px;
    }
    
    .location-modal-body {
        padding: 16px;
    }
    
    .shipping-info {
        padding: 12px;
    }
    
    .shipping-info .fa-truck {
        font-size: 20px;
    }
    
    .location-notification {
        bottom: 10px;
        right: 10px;
        left: 10px;
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* ========================================
   Integración con Header Existente
   ======================================== */

.header-location-wrapper {
    display: inline-flex;
    align-items: center;
    margin-right: 15px;
    position: relative;
    z-index: 1;
    vertical-align: middle;
}

/* Ajustes para header responsive */
@media (max-width: 768px) {
    .header-location-wrapper {
        margin-right: 10px;
    }
    
    .location-selector {
        font-size: 12px;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .header-location-wrapper {
        margin-right: 5px;
    }
    
    /* Ocultar texto en móviles muy pequeños, solo mostrar icono */
    .location-selector .location-text {
        display: none;
    }
    
    .location-selector .fa-chevron-down {
        display: none;
    }
    
    .location-selector {
        padding: 6px 8px;
        min-width: 36px;
    }
}

/* ========================================
   Estados de Carga
   ======================================== */

.location-form .loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.location-form .loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #fed700;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Accesibilidad
   ======================================== */

.location-selector:focus,
.location-modal-close:focus,
.location-form .form-control:focus,
.location-form .btn:focus {
    outline: 2px solid #fed700;
    outline-offset: 2px;
}

/* Modo de alto contraste */
@media (prefers-contrast: high) {
    .location-selector {
        border-width: 2px;
    }
    
    .location-modal-content {
        border: 2px solid #000;
    }
}

/* Reducir movimiento para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
    .location-selector,
    .location-modal-overlay,
    .location-modal-content,
    .location-notification,
    .location-form .btn {
        animation: none;
        transition: none;
    }
}
