/*
 * RECYBERSEG - Hoja de Estilos Optimizada
 * Versión: 2.4 OPTIMIZADA MÓVIL - ESQUEMA AZUL CORPORATIVO
 * Fecha: 31 de Julio de 2025
 * Descripción: Optimizaciones de rendimiento para una experiencia más fluida en celulares.
*/

/* ==========================================================================
   0. OPTIMIZACIONES CRÍTICAS - CARGA Y RENDIMIENTO
   ========================================================================== */


:root {
    --primary-color: #3182ce;
    --primary-hover: #4299e1;
    --secondary-color: #63b3ed;
    --bg-dark: #f7fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --border-color: rgba(49, 130, 206, 0.3);
    --text-white: #1a202c;
    --text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    --chatbot-primary: #0d47a1;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.2s ease;
    --blur-effect: blur(10px);
    --shadow-glow: 0 0 15px rgba(49, 130, 206, 0.4);
}

.container,
.iot-section,
.mission-vision { /* Eliminado .main-services y .contact-section de aquí para controlarlos individualmente */
    contain: layout style paint;
}

/* ==========================================================================
   1. Estilos Globales y Reset
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', Arial, sans-serif;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-overflow-scrolling: touch;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    line-height: 1.6;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    contain: layout;
}

/* ==========================================================================
   2. Header y Navegación
   ========================================================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: var(--blur-effect);
    -webkit-backdrop-filter: var(--blur-effect);
    z-index: 1000;
    transition: var(--transition-smooth);
    will-change: transform, opacity;
    transform: translateZ(0);
    contain: layout style paint;
    border-bottom: 1px solid rgba(49, 130, 206, 0.1);
}

.navbar {
    padding: 20px 0;
    contain: layout;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    transform: translateZ(0);
}

.nav-logo h2 {
    color: var(--primary-color);
    font-size: 30px;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(49, 130, 206, 0.3);
    transform: translateZ(0);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
    contain: layout;
}

.nav-link {
    color: var(--text-white);
    text-decoration: none;
    font-size: 18px;
    font-weight: 400;
    transition: var(--transition-smooth);
    position: relative;
    transform: translateZ(0);
    will-change: transform, color;
}

.nav-link:hover {
    color: var(--primary-color);
    transform: translateY(-2px) translateZ(0);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
    transform: translateZ(0);
}

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

.search-container {
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateZ(0);
}

.search-input {
    padding: 10px 15px;
    border: none;
    border-radius: 25px;
    background-color: var(--bg-card);
    color: var(--text-white);
    width: 200px;
    transition: var(--transition-smooth);
    transform: translateZ(0);
    will-change: transform, background-color;
    border: 1px solid var(--border-color);
}

.search-input:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.05) translateZ(0);
    border-color: var(--primary-color);
}

.search-input::placeholder {
    color: rgba(26, 32, 44, 0.7);
}

.search-btn {
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition-smooth);
    color: var(--text-white);
    background-color: var(--primary-color);
    transform: translateZ(0);
    will-change: transform, background-color;
}

.search-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.1) translateZ(0);
}

.nav-toggle {
    display: none;
}

/* ==========================================================================
   3. Secciones Principales
   ========================================================================== */
.hero {
    padding: 140px 20px 80px;
    text-align: center;
    background: linear-gradient(rgba(247, 250, 252, 0.9), rgba(226, 232, 240, 0.9)), url('fotos/fondo.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateZ(0);
    contain: layout style paint;
    will-change: transform;
}

.hero-content {
    max-width: 100%;
    transform: translateZ(0);
    contain: layout;
}

.hero-title {
    font-size: 48px;
    background: linear-gradient(45deg, var(--primary-color), var(--primary-hover), var(--secondary-color));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(49, 130, 206, 0.3);
    animation: fadeInUp 1s ease-out, subtleBlueShine 4s ease-in-out infinite;
    transform: translateZ(0);
    will-change: background-position, text-shadow;
}

.hero-description {
    font-size: 30px;
    font-weight: 200;
    padding: 0 100px;
    text-align: justify;
    line-height: 1.8;
    animation: fadeInUp 1s ease-out 0.3s both;
    transform: translateZ(0);
    color: var(--text-white);
}

.main-services {
    padding: 80px 20px;
    background-color: #F7FAFC; /* COLOR ACTUALIZADO */
    text-align: center;
    transform: translateZ(0);
    contain: layout style paint;
}

.main-services h2 {
    font-size: 36px;
    margin-bottom: 20px;
    font-weight: 600;
    transform: translateZ(0);
    color: var(--text-white);
}

.main-services > .container > p {
    font-size: 20px;
    margin-bottom: 50px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    text-align: justify;
    transform: translateZ(0);
    color: var(--text-white);
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 50px;
    transform: translateZ(0);
    contain: layout;
}

.service-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    padding: 40px 30px;
    border-radius: 15px;
    text-align: center;
    transition: var(--transition-smooth);
    backdrop-filter: var(--blur-effect);
    will-change: transform, border-color, box-shadow;
    transform: translateZ(0);
    contain: layout style;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.service-card:hover {
    transform: translateY(-10px) translateZ(0);
    border-color: var(--primary-color);
    box-shadow: 0 20px 40px rgba(49, 130, 206, 0.2);
}

.service-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 250px;
    margin-bottom: 20px;
    transform: translateZ(0);
    contain: layout;
}

.service-icon img {
    width: 240px;
    height: 240px;
    object-fit: contain;
    transform: translateZ(0);
    will-change: transform;
}

.service-icon .consultoria-img {
    width: 280px !important;
    height: 280px !important;
}

.service-card h3 {
    font-size: 22px;
    margin-bottom: 15px;
    font-weight: 600;
    transform: translateZ(0);
    color: var(--text-white);
}

.service-card p {
    font-size: 12px;
    color: rgba(26, 32, 44, 0.8);
    margin-bottom: 20px;
    text-align: justify;
    transform: translateZ(0);
}

.service-price {
    display: inline-block;
    background-color: #2b6cb0;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    transform: translateZ(0);
    will-change: transform, background-color;
}

.iot-section {
    padding: 80px 20px;
    background-color: #2b6cb0;
    color: var(--text-white);
    text-align: center;
    transform: translateZ(0);
    contain: layout style paint;
}

.iot-section h2 {
    font-size: 36px;
    margin-bottom: 30px;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.3);
    transform: translateZ(0);
    color: white;
}

.iot-description {
    font-size: 26px;
    margin: 0 auto 10px;
    text-align: justify;
    line-height: 1.5;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.3);
    transform: translateZ(0);
    color: white;
}

.iot-services {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 50px;
    justify-items: center;
    transform: translateZ(0);
    contain: layout;
}

.iot-card {
    background-color: var(--bg-secondary);
    color: var(--text-white);
    padding: 25px 20px;
    border-radius: 15px;
    text-align: center;
    transition: var(--transition-smooth);
    border: 3px solid var(--border-color);
    max-width: 320px;
    width: 100%;
    will-change: transform, border-color, box-shadow;
    transform: translateZ(0);
    contain: layout style;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.iot-card:hover {
    transform: translateY(-5px) translateZ(0);
    border-color: var(--primary-color);
    box-shadow: 0 15px 30px rgba(49, 130, 206, 0.3);
}

.iot-image {
    height: 70px;
    background-color: rgba(49, 130, 206, 0.1);
    border: 2px dashed rgba(49, 130, 206, 0.3);
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transform: translateZ(0);
    contain: layout;
}

.iot-image::after {
    content: "Espacio para imagen";
    position: absolute;
    font-size: 12px;
    color: rgba(49, 130, 206, 0.5);
}

.iot-card h3 {
    font-size: 16px;
    margin-bottom: 15px;
    font-weight: 600;
    line-height: 1.3;
    transform: translateZ(0);
    color: var(--text-white);
}

.iot-details {
    margin-bottom: 20px;
    transform: translateZ(0);
}

.iot-details p {
    text-align: justify;
    margin-bottom: 15px;
    line-height: 1.5;
    transform: translateZ(0);
    color: var(--text-white);
}

.iot-details ul {
    list-style: none;
    text-align: left;
    transform: translateZ(0);
}

.iot-details li {
    padding: 4px 0 4px 15px;
    position: relative;
    font-size: 12px;
    line-height: 1.3;
    transform: translateZ(0);
    color: var(--text-white);
}

.iot-details li::before {
    content: '✓';
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.cta-button {
    background-color: #2b6cb0;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 20px;
    transition: var(--transition-smooth);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    will-change: transform, background-color;
    transform: translateZ(0);
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cta-button:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05) translateZ(0);
}

.mission-vision {
    padding: 80px 20px;
    background-color: var(--bg-dark);
    transform: translateZ(0);
    contain: layout style paint;
}

.mission-vision h2 {
    text-align: center;
    font-size: 36px;
    color: var(--primary-color);
    margin-bottom: 50px;
    font-weight: 700;
    transform: translateZ(0);
}

.mv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 40px;
    transform: translateZ(0);
    contain: layout;
}

.mv-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 15px;
    border: 2px solid var(--border-color);
    transition: var(--transition-smooth);
    will-change: transform, border-color;
    transform: translateZ(0);
    contain: layout style;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.mv-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px) translateZ(0);
    box-shadow: 0 15px 35px rgba(49, 130, 206, 0.2);
}

.mv-card h3 {
    color: var(--primary-color);
    font-size: 28px;
    margin-bottom: 20px;
    font-weight: 600;
    transform: translateZ(0);
}

.mv-card p {
    font-size: 20px;
    line-height: 1.7;
    text-align: justify;
    transform: translateZ(0);
    color: var(--text-white);
}

.contact-section {
    padding: 80px 20px;
    background-color: #F7FAFC; /* COLOR ACTUALIZADO */
    transform: translateZ(0);
    contain: layout style paint;
}

.contact-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: stretch;
    max-width: 1000px;
    margin: 0 auto;
    transform: translateZ(0);
    contain: layout;
}

.contact-info-wrapper,
.contact-form-wrapper {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 40px 30px;
    backdrop-filter: var(--blur-effect);
    transition: var(--transition-smooth);
    height: 500px;
    display: flex;
    flex-direction: column;
    will-change: transform, border-color, box-shadow;
    transform: translateZ(0);
    contain: layout style;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.contact-info-wrapper:hover,
.contact-form-wrapper:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px) translateZ(0);
    box-shadow: 0 10px 30px rgba(49, 130, 206, 0.2);
}

.contact-info-wrapper {
    justify-content: flex-start;
}

.contact-info-wrapper h3,
.contact-form-wrapper h2 {
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 25px;
    font-weight: 600;
    text-align: center;
    flex-shrink: 0;
    transform: translateZ(0);
}

.contact-info-items {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    transform: translateZ(0);
}

.contact-item {
    display: flex;
    align-items: center;
    font-size: 16px;
    transform: translateZ(0);
    will-change: transform;
    color: var(--text-white);
}

.contact-item i {
    color: var(--primary-color);
    margin-right: 15px;
    font-size: 20px;
    width: 25px;
}

.contact-item a {
    color: var(--text-white);
    text-decoration: none;
    transition: var(--transition-fast);
    transform: translateZ(0);
    will-change: color, transform;
}

.contact-item a:hover {
    color: var(--primary-color);
}

.whatsapp-item a:hover {
    background-color: rgba(49, 130, 206, 0.1);
    transform: translateX(5px) translateZ(0);
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
    transform: translateZ(0);
}

.newsletter-form input,
.newsletter-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-card);
    color: var(--text-white);
    font-size: 16px;
    transition: var(--transition-smooth);
    transform: translateZ(0);
    will-change: border-color, background-color, box-shadow;
}

.newsletter-form textarea {
    resize: none;
    height: 80px;
}

.newsletter-form input:focus,
.newsletter-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 1);
    box-shadow: var(--shadow-glow);
}

.newsletter-form input::placeholder,
.newsletter-form textarea::placeholder {
    color: rgba(26, 32, 44, 0.7);
}

.newsletter-form button[type="submit"] {
    background-color: #2b6cb0;
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-smooth);
    text-transform: uppercase;
    letter-spacing: 1px;
    align-self: center;
    margin-top: auto;
    touch-action: manipulation;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    transform: translateZ(0);
    will-change: transform, background-color, box-shadow;
}

.newsletter-form button[type="submit"]:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px) translateZ(0);
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.4);
}

#form-messages {
    display: none;
    margin-top: 20px;
}

/* ==========================================================================
   4. Footer
   ========================================================================== */
.footer {
    background-color: #2b6cb0;
    color: #ffffff;
    padding: 60px 20px 20px;
    transform: translateZ(0);
    contain: layout style paint;
    border-top: 1px solid rgba(255, 255, 255, 0.1); /* Ajuste de borde para que contraste con el nuevo fondo */
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    max-width: 600px;
    margin: 0 auto 40px;
    transform: translateZ(0);
}

.footer-section h3 {
    color: #ffffff; /* COLOR ACTUALIZADO */
    margin-bottom: 15px;
    font-weight: 600;
    transform: translateZ(0);
}

.footer-section p {
    font-size: 14px;
    color: #ffffff; /* COLOR ACTUALIZADO */
    margin-bottom: 20px;
    transform: translateZ(0);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    transform: translateZ(0);
}

.social-links a {
    color: #ffffff; /* COLOR ACTUALIZADO */
    font-size: 24px;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    will-change: transform, background-color;
}

.social-links a:hover {
    transform: scale(1.1) rotate(10deg) translateZ(0);
    background-color: rgba(255, 255, 255, 0.2);
}

.footer-bottom { /* Renombrado de .copyright para mayor claridad y reorganización */
    text-align: center;
    padding-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.1); /* Ajuste de borde */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 15px;
    transform: translateZ(0);
}

.footer-bottom p {
    color: #ffffff; /* COLOR ACTUALIZADO */
    font-size: 14px;
    transform: translateZ(0);
}

.signature p {
    margin: 2px 0;
    font-size: 14px;
    color: #ffffff; /* COLOR ACTUALIZADO */
    transform: translateZ(0);
}

.signature p:first-child {
    font-weight: 600;
    font-size: 15px;
}

.signature p:last-child {
    font-size: 12px;
    color: #ffffff; /* COLOR ACTUALIZADO */
    font-style: italic;
}

/* ==========================================================================
   5. Componentes (Chatbot, Botón Flotante, Contador)
   ========================================================================== */
.visitor-counter-container {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 600;
    background-color: var(--bg-card);
    padding: 8px 15px;
    border-radius: 25px;
    text-shadow: 0 2px 10px rgba(49, 130, 206, 0.3);
    transition: var(--transition-smooth);
    transform: translateZ(0);
    will-change: transform, background-color;
    contain: layout style;
    border: 1px solid var(--border-color);
}

.visitor-counter-container:hover {
    background-color: rgba(49, 130, 206, 0.2);
    transform: scale(1.05) translateZ(0);
}

.visitor-counter-container .fa-eye {
    font-size: 18px;
}

#real-floating-back-btn {
    display: none;
}

#real-floating-back-btn.floating-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* OPTIMIZACIÓN MÓVIL: Animación de pulso más eficiente */
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.chat-toggle-button {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 80px;
    height: 80px;
    background: var(--bg-secondary);
    border-radius: 50%;
    border: 2px solid #22c55e;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(34, 197, 94, 0.4);
    z-index: 1600;
    transition: all 0.3s ease;
    padding: 0;
    overflow: hidden;
    animation: pulse 2.5s infinite;
    /* OPTIMIZACIÓN MÓVIL: Mejorar respuesta táctil y avisar al navegador de cambios */
    touch-action: manipulation;
    will-change: transform, box-shadow;
}

.chat-toggle-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.6);
    animation-play-state: paused;
}

.chat-toggle-button video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    transform: scale(1.0); 
    object-position: 45% 100%; 
}

.chatbot-container {
    position: fixed;
    bottom: 120px;
    right: 25px;
    width: 350px;
    max-width: 90%;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25), 0 0 20px rgba(49, 130, 206, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1600;
    border: 2px solid var(--primary-color);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    visibility: hidden;
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s, bottom 0.3s ease;
    /* OPTIMIZACIÓN MÓVIL: Avisar al navegador que este elemento cambiará */
    will-change: transform, opacity, bottom;
}

.chatbot-container.keyboard-active {
    bottom: 10px;
    transform: translateY(0) scale(1);
}

.chatbot-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

.chatbot-header {
    background-color: #0d47a1; /* Azul oscuro */
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

#close-chat-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.chatbot-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    height: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-card);
}

.message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 20px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message p {
    margin: 0;
    font-size: 14px;
}

.bot-message {
    background-color: rgba(49, 130, 206, 0.1);
    color: var(--text-white);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    border: 1px solid var(--border-color);
}

.user-message {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.chatbot-form {
    display: flex;
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    align-items: center;
    gap: 8px;
}

#chatbot-input {
    flex-grow: 1;
    border: none;
    padding: 12px 16px;
    border-radius: 25px;
    background-color: rgba(255, 255, 255, 0.95);
    color: var(--text-white);
    font-size: 14px;
    border: 2px solid var(--border-color);
    width: calc(100% - 50px);
    text-align: center;
}

#chatbot-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.3);
    border-color: var(--primary-color);
}

.chatbot-form button {
    background: var(--primary-color);
    border: 2px solid var(--primary-color);
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.chatbot-form button:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.loading-indicator {
    display: flex;
    justify-content: flex-start;
    padding: 10px 15px;
}

.loading-indicator span {
    height: 10px;
    width: 10px;
    margin: 0 2px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-indicator span:nth-child(1) { animation-delay: -0.32s; }
.loading-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* ==========================================================================
   6. Animaciones
   ========================================================================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px) translateZ(0); }
    to { opacity: 1; transform: translateY(0) translateZ(0); }
}

@keyframes subtleBlueShine {
    0%, 100% {
        background-position: 0% 50%;
        text-shadow: 0 0 8px rgba(49, 130, 206, 0.2);
    }
    50% {
        background-position: 100% 50%;
        text-shadow: 0 0 15px rgba(49, 130, 206, 0.4);
    }
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0) translateZ(0); }
    40% { transform: scale(1.0) translateZ(0); }
}

/* ==========================================================================
   7. Media Queries (Diseño Responsivo y Optimización Móvil)
   ========================================================================== */
@media screen and (max-width: 1024px) {
    .hero-description {
        font-size: 28px;
    }
    .services-grid, .iot-services, .mv-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    .hero {
        /* OPTIMIZACIÓN: Parallax es costoso en tablets, se desactiva */
        background-attachment: scroll;
    }
}

/* --- INICIO DE OPTIMIZACIONES PARA MÓVIL --- */
@media screen and (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }
    
    .container {
        width: 98%;
        margin: 0 auto;
        padding: 0;
        contain: layout;
    }
    .main-services, .iot-section, .mission-vision, .contact-section {
        padding: 60px 0;
        scroll-margin-top: 80px;
        contain: layout style;
    }
    .main-services h2, .iot-section h2, .mission-vision h2, .contact-section h2 {
        font-size: 30px;
    }
    .header {
        min-height: 80px;
        position: fixed;
        will-change: transform;
        contain: layout style;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .navbar {
        padding: 15px 0;
        height: 80px;
    }
    .search-container, .nav-menu .nav-link::after {
        display: none;
    }
    .nav-container {
        padding: 0 20px;
    }
    .nav-logo {
        flex: 1;
        text-align: center;
    }
    .nav-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        padding: 8px;
        background-color: var(--bg-secondary);
        border: 2px solid var(--border-color);
        border-radius: 8px;
        transition: var(--transition-smooth);
        position: relative;
        z-index: 1502;
        min-height: 44px;
        min-width: 44px;
        transform: translateZ(0);
        will-change: transform;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    .bar {
        width: 24px;
        height: 3px;
        background-color: var(--text-white);
        margin: 3px 0;
        transition: all 0.4s ease;
        border-radius: 2px;
        transform: translateZ(0);
        will-change: transform, opacity;
    }
    .nav-toggle.active .bar:nth-child(1) { transform: translateY(6px) rotate(45deg) translateZ(0); }
    .nav-toggle.active .bar:nth-child(2) { opacity: 0; }
    .nav-toggle.active .bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg) translateZ(0); }
    .nav-menu {
        position: fixed;
        left: 0;
        top: 80px;
        width: 100%;
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        flex-direction: column;
        align-items: center;
        padding: 25px 20px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
        border-bottom-left-radius: 25px;
        border-bottom-right-radius: 25px;
        border: 2px solid rgba(49, 130, 206, 0.1);
        border-top: none;
        z-index: 1400;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-30px) translateZ(0);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: opacity, visibility, transform;
        contain: layout style paint;
    }
    .nav-menu.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) translateZ(0);
    }
    .nav-menu li {
        width: 100%;
        max-width: 350px;
    }
    .nav-link {
        display: block;
        padding: 20px 25px;
        font-size: 22px;
        font-weight: 600;
        text-align: center;
        border-bottom: 1px solid var(--border-color);
        transform: translateZ(0);
        will-change: transform, background-color, color;
    }
    .nav-menu li:last-child .nav-link {
        border-bottom: none;
    }
    .nav-link:hover {
        background: rgba(49, 130, 206, 0.1);
        color: var(--primary-color);
        transform: translateX(5px) translateZ(0);
    }
    body.menu-open {
        overflow: hidden;
    }
    .hero {
        padding: 120px 0 60px;
        min-height: 70vh;
        background-attachment: scroll;
        background-size: cover;
        background-position: center;
        transform: translateZ(0);
        will-change: transform;
    }
    .hero-title {
        font-size: 26px;
        line-height: 1.3;
    }
    .hero-description {
        font-size: 16px;
        padding: 0;
        line-height: 1.6;
        width: 96%;
        margin: 0 auto;
    }
    .services-grid, .iot-services, .mv-grid, .contact-content-wrapper, .footer-content {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    .contact-content-wrapper {
        display: flex;
        flex-direction: column;
    }
    .service-card, .iot-card, .mv-card {
        padding: 30px 20px;
        margin: 0 auto;
        width: 100%;
        max-width: 100%;
        transform: translateZ(0);
        will-change: transform;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .iot-description {
        font-size: 19px;
    }
    .mv-card p {
        font-size: 18px;
    }
    .contact-info-wrapper, .contact-form-wrapper {
        height: auto;
        min-height: auto;
        padding: 25px 20px;
        width: 100%;
        transform: translateZ(0);
        will-change: transform;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .contact-form-wrapper h2 {
        font-size: 22px;
        text-align: center;
    }
    .newsletter-form {
        gap: 20px;
    }
    .newsletter-form button[type="submit"] {
        align-self: center;
        margin-top: 10px;
    }
    .footer-content, .signature, .footer-section {
        text-align: center;
    }
    .social-links {
        justify-content: center;
    }
    .visitor-counter-container {
        position: absolute;
        top: 24px;
        left: 20px;
        z-index: 1001;
        font-size: 12px;
        padding: 6px 10px;
        background-color: var(--bg-card);
        text-shadow: none;
        border: 1px solid var(--border-color);
    }
    .chatbot-container {
        width: 95% !important;
        left: 2% !important;
        right: 2% !important;
        bottom: 100px;
        border: 3px solid var(--chatbot-border);
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3), 0 0 25px rgba(107, 114, 128, 0.5);
        max-width: none !important;
        margin: 0 auto;
        transform-origin: bottom center;
        transition: bottom 0.3s ease, transform 0.3s ease;
    }
    
    .chatbot-container.keyboard-active {
        bottom: 10px !important;
        position: fixed !important;
        z-index: 9999 !important;
    }
    
    .chatbot-header {
        padding: 12px 15px;
        background-color: var(--chatbot-primary);
        position: relative;
       
    }
    
    .chatbot-header h3 {
        font-size: 18px;
        color: white;
        text-align: center;
        padding-left: 45px;
        padding-right: 45px;
    }
    
    #close-chat-btn {
        right: 12px;
        font-size: 22px;
        color: white;
    }
    
    .chatbot-form {
        padding: 15px;
        gap: 10px;
    }
    
    #chatbot-input {
        width: calc(100% - 60px);
        padding: 14px 18px;
        text-align: left;
        font-size: 16px;
    }
    
    .chatbot-form button {
        min-width: 44px;
        min-height: 44px;
        font-size: 20px;
    }
    .chatbot-header { background-color: #0d47a1;}
    .user-message { background-color: var(--primary-color); }
    #chatbot-input:focus { box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.5); }
    .chatbot-form button { color: white; }
    .loading-indicator span { background-color: var(--primary-color); }

    #real-floating-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 110px;
        right: 25px;
        background: transparent;
        border: none;
        width: 50px;
        height: 50px;
        z-index: 1550;
        cursor: pointer;
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px);
        transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
        /* OPTIMIZACIÓN MÓVIL: Mejorar respuesta táctil y avisar al navegador de cambios */
        touch-action: manipulation;
        will-change: transform, opacity;
    }
    #real-floating-back-btn i {
        font-size: 40px;
        color: #22c55e;
        font-weight: bold;
        text-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
        transition: transform 0.3s ease;
    }
    #real-floating-back-btn:hover i {
        transform: scale(1.15);
    }
}

@media screen and (max-width: 480px) {
   .chatbot-header {
        background-color: #0d47a1;
        color: white;
    }
    .nav-logo h2 { font-size: 22px; }
    .nav-logo { padding-left: 80px; }
    .hero-title { font-size: 24px; }
    .hero-description { font-size: 15px; }
    .main-services p { font-size: 16px; }
    .mv-card p { font-size: 16px; }
    .contact-item, .contact-item a { font-size: 14px; }
    .contact-form-wrapper h2 { font-size: 20px; }
    
    .chatbot-container {
        width: 98%;
        right: 1%;
        left: 1%;
        bottom: 100px;
        border: 3px solid var(--primary-color);
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3), 0 0 25px rgba(49, 130, 206, 0.5);
    }
    
    .chatbot-form {
        padding: 15px;
        gap: 10px;
    }
    
    #chatbot-input {
        width: calc(100% - 60px);
        padding: 14px 18px;
        text-align: left;
        font-size: 16px;
    }
    
    .chatbot-form button {
        min-width: 44px;
        min-height: 44px;
        font-size: 20px;
    }
    
    .chat-toggle-button {
        width: 70px;
        height: 70px;
        right: 15px;
        bottom: 15px;
    }
    #real-floating-back-btn {
        bottom: 100px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
    #real-floating-back-btn i {
        font-size: 32px;
    }
    

   
}

/* ==========================================================================
   8. OPTIMIZACIONES FINALES
   ========================================================================== */
@supports (content-visibility: auto) {
    .service-card,
    .iot-card,
    .mv-card {
        content-visibility: auto;
        contain-intrinsic-size: 0 400px;
    }
}

@supports (scroll-behavior: smooth) {
    html {
        scroll-behavior: smooth;
    }
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@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;
    }
    html {
        scroll-behavior: auto;
    }
}
#chat-mic-btn {
    background-color: #22c55e !important;
    border: none !important;
    color: white !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 8px rgba(34, 197, 94, 0.3) !important;
    flex-shrink: 0 !important;
}

#chat-mic-btn:hover {
    background-color: #16a34a !important;
    transform: scale(1.1) !important;
}

#chat-mic-btn i {
    font-size: 18px !important;
}


#chat-mic-btn.recording {
    background-color: #ef4444 !important; /* Rojo */
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

#voice-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#auto-read-btn {
    background: none;
    border: 2px solid white;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#auto-read-btn.active {
    background-color: white;
    color: var(--chatbot-primary);
}
.chatbot-container.keyboard-active {
    bottom: 10px !important;
    position: fixed !important;
    z-index: 9999 !important;
}
