@media (max-width: 767px) {
    .service-card {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .service-content,
    .service-image {
        width: 100% !important;
        max-width: 100% !important;
        order: unset !important;
    }

    .service-image {
        margin-top: 18px !important;
        margin-bottom: 0 !important;
        height: auto !important;
        min-height: 180px;
    }

    .service-image img {
        height: auto !important;
        min-height: 180px;
        max-height: 260px;
        object-fit: cover;
    }
}

/* Forzar tamaño grande del logo en el navbar en móviles */
@media (max-width: 767px) {
    .nav-logo img {
        height: 70px !important;
        max-height: 90px !important;
        width: auto !important;
    }
}

/* ==================== MEJORAS RESPONSIVE AVANZADAS ==================== */

/* Optimización de touch targets para móviles */
@media (max-width: 767px) {

    /* Asegurar que todos los elementos táctiles tengan al menos 44x44px */
    .btn,
    .nav-link,
    .dropdown-toggle,
    button,
    a.button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    /* Mejorar espaciado en móviles */
    .section {
        padding: 50px 15px;
    }

    /* Hacer las cards más tocables */
    .service-box,
    .feature-item {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(26, 123, 179, 0.1);
    }

    /* Mejorar formularios en móviles */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important;
        /* Prevenir zoom en iOS */
        padding: 14px;
        border-radius: 8px;
    }

    /* Ocultar elementos no críticos en móviles */
    .desktop-only {
        display: none !important;
    }

    /* Optimizar imágenes */
    img {
        height: auto;
        max-width: 100%;
    }
}

/* Mejoras para landscape en móviles */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        padding: 80px 20px 50px;
    }

    .hero h1 {
        font-size: 1.8em;
    }

    .nav-container {
        height: 60px;
    }

    .nav-menu {
        top: 60px;
        height: calc(100vh - 60px);
    }

    .section {
        padding: 40px 20px;
    }
}

/* Optimización para tablets en landscape */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Modo oscuro (preparación futura) */
@media (prefers-color-scheme: dark) {
    /* Se puede activar más adelante si se desea */
    /* body {
        background: #1a1a1a;
        color: #ffffff;
    } */
}

/* Print styles */
@media print {

    .navbar,
    .whatsapp-float,
    .chatbot-container,
    .footer {
        display: none !important;
    }

    .hero {
        margin-top: 0;
        padding: 20px;
    }

    body {
        font-size: 12pt;
    }

    a[href]::after {
        content: " (" attr(href) ")";
    }
}

/* Mejoras para pantallas de alta densidad (Retina) */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    .nav-logo img,
    .service-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Soporte para notch en iPhone X y superiores */
@supports (padding: max(0px)) {
    .navbar {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .chatbot-container,
    .whatsapp-float {
        bottom: max(15px, env(safe-area-inset-bottom));
        right: max(15px, env(safe-area-inset-right));
    }
}

/* Mejoras de rendimiento en móviles */
@media (max-width: 767px) {

    /* Hardware acceleration */
    .chatbot-window,
    .nav-menu,
    .whatsapp-button,
    .chatbot-button {
        transform: translateZ(0);
        will-change: transform;
    }

    /* Simplificar sombras en móviles para mejor rendimiento */
    .service-box,
    .feature-item,
    .btn {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}

/* Grid de 12 columnas responsive */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

.col-11 {
    flex: 0 0 91.666%;
    max-width: 91.666%;
}

.col-10 {
    flex: 0 0 83.333%;
    max-width: 83.333%;
}

.col-9 {
    flex: 0 0 75%;
    max-width: 75%;
}

.col-8 {
    flex: 0 0 66.666%;
    max-width: 66.666%;
}

.col-7 {
    flex: 0 0 58.333%;
    max-width: 58.333%;
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
}

.col-5 {
    flex: 0 0 41.666%;
    max-width: 41.666%;
}

.col-4 {
    flex: 0 0 33.333%;
    max-width: 33.333%;
}

.col-3 {
    flex: 0 0 25%;
    max-width: 25%;
}

.col-2 {
    flex: 0 0 16.666%;
    max-width: 16.666%;
}

.col-1 {
    flex: 0 0 8.333%;
    max-width: 8.333%;
}

@media (min-width: 768px) {
    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-md-4 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

@media (min-width: 1024px) {
    .col-lg-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .col-lg-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-lg-4 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    .col-lg-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

/* Utilidades responsive */
.mobile-only {
    display: block;
}

.tablet-only,
.desktop-only {
    display: none;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .mobile-only {
        display: none;
    }

    .tablet-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }
}

@media (min-width: 1024px) {

    .mobile-only,
    .tablet-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }
}

/* Text alignment responsive */
@media (max-width: 767px) {
    .text-mobile-center {
        text-align: center !important;
    }

    .text-mobile-left {
        text-align: left !important;
    }

    .text-mobile-right {
        text-align: right !important;
    }
}

/* Spacing utilities responsive */
@media (max-width: 767px) {
    .mt-mobile-0 {
        margin-top: 0 !important;
    }

    .mt-mobile-1 {
        margin-top: 10px !important;
    }

    .mt-mobile-2 {
        margin-top: 20px !important;
    }

    .mt-mobile-3 {
        margin-top: 30px !important;
    }

    .mb-mobile-0 {
        margin-bottom: 0 !important;
    }

    .mb-mobile-1 {
        margin-bottom: 10px !important;
    }

    .mb-mobile-2 {
        margin-bottom: 20px !important;
    }

    .mb-mobile-3 {
        margin-bottom: 30px !important;
    }

    .p-mobile-0 {
        padding: 0 !important;
    }

    .p-mobile-1 {
        padding: 10px !important;
    }

    .p-mobile-2 {
        padding: 20px !important;
    }

    .p-mobile-3 {
        padding: 30px !important;
    }
}

/* Mejoras de performance para animaciones */
.smooth-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Prevenir zoom en inputs en iOS */
@supports (-webkit-touch-callout: none) {

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    textarea {
        font-size: 16px !important;
    }
}