/* ===================================================
   MASTROMEC - OPTIMIZACIÓN ELEMENTOS INTERACTIVOS
   TAREA 7: Optimizar Elementos Interactivos
   =================================================== */

/* ===== VARIABLES PARA INTERACTIVIDAD ===== */
:root {
    /* Duraciones de transición */
    --transition-fast: 0.15s;
    --transition-normal: 0.3s;
    --transition-slow: 0.5s;

    /* Curvas de easing */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Estados de interacción */
    --hover-scale: 1.02;
    --active-scale: 0.98;
    --focus-outline: 3px solid var(--mastromec-blue-primary);
    --focus-outline-offset: 2px;

    /* Sombras interactivas */
    --shadow-hover: 0 4px 20px rgba(13, 125, 197, 0.15);
    --shadow-active: 0 2px 8px rgba(13, 125, 197, 0.2);
    --shadow-focus: 0 0 0 4px rgba(13, 125, 197, 0.2);
}

/* ===== BOTONES OPTIMIZADOS ===== */

/* Base para todos los botones */
.btn,
button,
[role="button"] {
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px; /* Touch target mínimo */
    padding: 0.75rem 1.5rem;
    border: 2px solid transparent;
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
}

/* Estados interactivos para botones */
.btn:hover,
button:hover,
[role="button"]:hover {
    transform: translateY(-2px) scale(var(--hover-scale));
    box-shadow: var(--shadow-hover);
}

.btn:active,
button:active,
[role="button"]:active {
    transform: translateY(0) scale(var(--active-scale));
    box-shadow: var(--shadow-active);
    transition-duration: var(--transition-fast);
}

.btn:focus,
button:focus,
[role="button"]:focus {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
    box-shadow: var(--shadow-focus);
}

/* Efecto de ondas para botones */
.btn::before,
button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width var(--transition-normal) var(--ease-out),
                height var(--transition-normal) var(--ease-out);
    pointer-events: none;
}

.btn:active::before,
button:active::before {
    width: 300px;
    height: 300px;
    transition-duration: var(--transition-fast);
}

/* ===== BOTONES ESPECÍFICOS ===== */

/* Botón primario */
.btn-primary {
    background: var(--mastromec-blue-primary);
    color: white;
    border-color: var(--mastromec-blue-primary);
}

.btn-primary:hover {
    background: var(--mastromec-blue-dark);
    border-color: var(--mastromec-blue-dark);
    color: white;
}

.btn-primary:focus {
    box-shadow: var(--shadow-focus), 0 0 0 2px white;
}

/* Botón secundario */
.btn-secondary {
    background: transparent;
    color: var(--mastromec-blue-primary);
    border-color: var(--mastromec-blue-primary);
}

.btn-secondary:hover {
    background: var(--mastromec-blue-primary);
    color: white;
    border-color: var(--mastromec-blue-primary);
}

/* Botón WhatsApp optimizado */
.btn-whatsapp {
    background: #25D366;
    color: white;
    border-color: #25D366;
    position: relative;
}

.btn-whatsapp:hover {
    background: #128C7E;
    border-color: #128C7E;
    color: white;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #25D366, #128C7E);
    border-radius: 10px;
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.btn-whatsapp:hover::after {
    opacity: 1;
}

/* ===== ENLACES OPTIMIZADOS ===== */

/* Enlaces base */
a {
    color: var(--mastromec-blue-primary);
    text-decoration: none;
    transition: all var(--transition-normal) var(--ease-out);
    position: relative;
    cursor: pointer;
}

a:hover {
    color: var(--mastromec-blue-dark);
    text-decoration: underline;
}

a:focus {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
    border-radius: 3px;
}

/* Enlaces con efecto de subrayado animado */
.link-animated {
    position: relative;
    text-decoration: none;
}

.link-animated::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--mastromec-blue-primary);
    transition: width var(--transition-normal) var(--ease-out);
}

.link-animated:hover::after {
    width: 100%;
}

/* ===== NAVEGACIÓN OPTIMIZADA ===== */

/* Enlaces de navegación */
.nav-link {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all var(--transition-normal) var(--ease-out);
    position: relative;
}

.nav-link:hover {
    background: rgba(13, 125, 197, 0.1);
    color: var(--mastromec-blue-primary);
    transform: translateY(-1px);
}

.nav-link:focus {
    background: rgba(13, 125, 197, 0.15);
    outline: var(--focus-outline);
    outline-offset: 2px;
}

/* Indicador activo en navegación */
.nav-link.active::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    width: 6px;
    height: 6px;
    background: var(--mastromec-blue-primary);
    border-radius: 50%;
    transform: translateX(-50%);
}

/* ===== FORMULARIOS INTERACTIVOS ===== */

/* Campos de entrada */
.form-input,
.form-textarea,
.form-select {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all var(--transition-normal) var(--ease-out);
    background: white;
    font-size: 1rem;
    width: 100%;
    min-height: 44px;
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
    border-color: var(--mastromec-blue-light);
    box-shadow: 0 2px 8px rgba(13, 125, 197, 0.08);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--mastromec-blue-primary);
    box-shadow: var(--shadow-focus);
    outline: none;
    transform: translateY(-1px);
}

/* Labels animadas */
.form-field {
    position: relative;
}

.form-label-floating {
    position: absolute;
    top: 0.75rem;
    left: 1rem;
    background: white;
    padding: 0 0.25rem;
    color: #64748b;
    transition: all var(--transition-normal) var(--ease-out);
    pointer-events: none;
}

.form-input:focus + .form-label-floating,
.form-input:not(:placeholder-shown) + .form-label-floating {
    top: -0.5rem;
    font-size: 0.875rem;
    color: var(--mastromec-blue-primary);
    font-weight: 600;
}

/* ===== CARDS INTERACTIVAS ===== */

/* Cards base */
.card,
.service-card,
.testimonial-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all var(--transition-normal) var(--ease-out);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(13, 125, 197, 0.1);
}

.card:hover,
.service-card:hover,
.testimonial-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(13, 125, 197, 0.15);
    border-color: rgba(13, 125, 197, 0.2);
}

.card:active,
.service-card:active,
.testimonial-card:active {
    transform: translateY(-2px);
    transition-duration: var(--transition-fast);
}

/* Efecto de brillo en hover */
.card::before,
.service-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    transform: rotate(45deg) translate(-100%, -100%);
    transition: transform var(--transition-slow) var(--ease-out);
    pointer-events: none;
}

.card:hover::before,
.service-card:hover::before {
    transform: rotate(45deg) translate(100%, 100%);
}

/* ===== ELEMENTOS DE NAVEGACIÓN MÓVIL ===== */

/* Botón hamburguesa optimizado */
.mobile-menu-button {
    width: 44px;
    height: 44px;
    border: 2px solid var(--mastromec-blue-primary);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-normal) var(--ease-bounce);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.mobile-menu-button:hover {
    background: var(--mastromec-blue-primary);
    color: white;
    transform: scale(1.1);
    box-shadow: var(--shadow-hover);
}

.mobile-menu-button:active {
    transform: scale(0.95);
    transition-duration: var(--transition-fast);
}

.mobile-menu-button:focus {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
}

/* Animación del icono hamburguesa */
.mobile-menu-button i {
    transition: all var(--transition-normal) var(--ease-out);
}

.mobile-menu-button.active {
    background: var(--mastromec-blue-primary);
    color: white;
    transform: rotate(90deg);
}

/* ===== EFECTOS DE SCROLL INTERACTIVOS ===== */

/* Elementos que aparecen al hacer scroll */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all var(--transition-slow) var(--ease-out);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Botón scroll to top */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--mastromec-blue-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-normal) var(--ease-out);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background: var(--mastromec-blue-dark);
    transform: translateY(-4px) scale(1.1);
    box-shadow: var(--shadow-hover);
}

/* ===== EFECTOS DE CARGA ===== */

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid var(--mastromec-blue-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: loading-spin 1s linear infinite;
}

@keyframes loading-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== INTERACCIONES TÁCTILES ===== */

/* Optimización para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    /* Incrementar áreas de toque */
    .btn,
    button,
    .nav-link,
    .mobile-menu-button {
        min-height: 48px;
        min-width: 48px;
    }

    /* Reducir animaciones en hover para táctil */
    .btn:hover,
    .card:hover,
    .nav-link:hover {
        transform: none;
    }

    /* Mantener solo animaciones de tap */
    .btn:active,
    .card:active,
    .nav-link:active {
        transform: scale(0.98);
    }
}

/* ===== ESTADOS DE ERROR Y ÉXITO ===== */

/* Estados de validación */
.form-input.error,
.form-textarea.error,
.form-select.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    animation: shake 0.5s ease-in-out;
}

.form-input.success,
.form-textarea.success,
.form-select.success {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ===== ACCESIBILIDAD MEJORADA ===== */

/* Estados de focus mejorados */
*:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-outline-offset);
    border-radius: 4px;
}

/* Indicadores para lectores de pantalla */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== ANIMACIONES DE CARGA DE PÁGINA ===== */

/* Fade in para elementos */
.fade-in {
    animation: fadeIn var(--transition-slow) var(--ease-out);
}

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

/* ===== RESPONSIVE ADJUSTMENTS ===== */

/* Ajustes para móvil */
@media (max-width: 767px) {
    .btn {
        width: 100%;
        justify-content: center;
    }

    .card:hover,
    .service-card:hover {
        transform: translateY(-2px);
    }
}

/* Ajustes para tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .btn:hover {
        transform: translateY(-1px) scale(1.01);
    }
}

/* ===== REDUCCIÓN DE MOVIMIENTO ===== */

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}