/* styles.css - XmartVision AI */
/* Estilos base y reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

body {
    background: #f4f7fa;
    line-height: 1.6;
    overscroll-behavior: none; /* Prevent pull-to-refresh interfering with taps */
}

/* Estilos del Chatbot Widget */
#chatbot-toggler {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #005b96;
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 10010; /* Above all else */
    touch-action: manipulation;
}

#chatbot-toggler:hover {
    background: #003f6b;
    transform: scale(1.05);
}

#chatbot-toggler:active {
    transform: scale(0.95);
}

body.show-chatbot #chatbot-toggler {
    transform: rotate(45deg);
}

/* Contenedor principal del chatbot */
.chatbot {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 350px;
    max-height: 500px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 10000; /* Below toggler */
    transition: all 0.3s ease;
}

body.show-chatbot .chatbot {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

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

/* Header del chatbot */
.chatbot header {
    background: #005b96;
    color: #fff;
    padding: 15px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-container {
    position: relative;
    width: 55px;
    height: 55px;
    margin-right: 10px;
}

.avatar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    transition: opacity 0.3s ease-in-out;
}

.avatar.static { opacity: 1; }
.avatar.animated { opacity: 0; }
.avatar.static.hidden { opacity: 0; }
.avatar.animated.visible { opacity: 1; }

.chatbot header h2 {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

/* Área de mensajes del chat */
.chatbox {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9fbfc;
    max-height: 300px;
    scrollbar-width: thin;
    scrollbar-color: #005b96 #f9fbfc;
}

.chatbox::-webkit-scrollbar {
    width: 6px;
}

.chatbox::-webkit-scrollbar-track {
    background: #f9fbfc;
}

.chatbox::-webkit-scrollbar-thumb {
    background: #005b96;
    border-radius: 3px;
}

.chat {
    display: flex;
    margin-bottom: 10px;
    animation: fadeIn 0.3s ease-in;
}

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

.chat.incoming { justify-content: flex-start; }
.chat.outgoing { justify-content: flex-end; }

.chat p {
    max-width: 70%;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
    word-wrap: break-word;
}

.chat.incoming p {
    background: #e6f0fa;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat.outgoing p {
    background: #005b96;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Formulario de contacto inicial */
.chat-form {
    background: #fff;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
}

.chat-form input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    touch-action: manipulation;
}

.chat-form input:focus {
    outline: none;
    border-color: #005b96;
    box-shadow: 0 0 0 2px rgba(0, 91, 150, 0.1);
}

.chat-form input:last-of-type {
    margin-bottom: 15px;
}

.chat-form button {
    width: 100%;
    padding: 12px;
    background: #005b96;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease;
    touch-action: manipulation;
    min-height: 48px;
}

.chat-form button:hover {
    background: #003f6b;
}

.chat-form button:active {
    transform: translateY(1px);
}

/* Área de input para mensajes */
.chat-input {
    display: flex;
    background: #fff;
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

.chat-input textarea {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    min-height: 36px;
    max-height: 100px;
    transition: border-color 0.3s ease;
    touch-action: manipulation;
}

.chat-input textarea:focus {
    outline: none;
    border-color: #005b96;
    box-shadow: 0 0 0 2px rgba(0, 91, 150, 0.1);
}

.chat-input button {
    padding: 8px 15px;
    background: #005b96;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease;
    touch-action: manipulation;
    min-height: 48px;
}

.chat-input button:hover {
    background: #003f6b;
}

.chat-input button:active {
    transform: translateY(1px);
}

/* Sección de interacción por voz */
.voice-section {
    background: #fff;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.voice-section p {
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}

.voice-section button {
    padding: 10px;
    background: #005b96;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    transition: all 0.3s ease;
    touch-action: manipulation;
    min-height: 48px;
}

.voice-section button:hover {
    background: #003f6b;
    transform: scale(1.05);
}

.voice-section button:active {
    transform: scale(0.95);
}

.voice-section button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.voice-section button svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.voice-section button.recording {
    background: #e74c3c;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive design para móviles */
@media (max-width: 400px) {
    .chatbot {
        width: 90%;
        right: 5%;
        bottom: 80px;
        left: 5%;
    }

    #chatbot-toggler {
        bottom: 10px;
        right: 10px;
        width: 50px;
        height: 50px;
    }

    .chat p {
        max-width: 85%;
    }
}

@media (max-height: 600px) {
    .chatbot {
        max-height: 400px;
        bottom: 70px;
    }
    
    .chatbox {
        max-height: 200px;
    }
}

/* Overlay para móviles cuando el chatbot está abierto */
@media (max-width: 768px) {
    body.show-chatbot::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 9999; /* Below chatbot and toggler */
        backdrop-filter: blur(2px);
        pointer-events: none; /* Allow touches to pass through */
    }
}

/* Indicadores de estado */
.chatbot .typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px;
    color: #666;
    font-style: italic;
    font-size: 12px;
}

.chatbot .typing-indicator::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #005b96;
    margin-left: 8px;
    animation: typing 1.4s infinite;
}

@keyframes typing {
    0%, 60%, 100% { opacity: 0; }
    30% { opacity: 1; }
}

/* Estados de error */
.chat-form .error {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.1) !important;
}

.error-message {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 5px;
    margin-bottom: 10px;
}

/* Mejoras de accesibilidad */
.chatbot button:focus,
.chatbot input:focus,
.chatbot textarea:focus {
    outline: 2px solid #005b96;
    outline-offset: 2px;
}

/* Estilos para el contenido principal de la página */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    margin-top: 80px; /* Adjust for fixed nav */
    z-index: 100; /* Below nav */
}

/* Utilidades generales */
.hidden { display: none !important; }
.visible { display: block !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }

/* Estilos para botones CTA en la página */
.cta-button {
    background: #005b96;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    touch-action: manipulation;
    min-height: 48px;
    z-index: 200; /* Above container */
}

.cta-button:hover {
    background: #003f6b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 91, 150, 0.3);
}

.cta-button:active {
    transform: translateY(0);
}

/* Efectos especiales para interacciones */
.chatbot-pulse {
    animation: chatbotPulse 2s infinite;
}

@keyframes chatbotPulse {
    0% { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 4px 20px rgba(0, 91, 150, 0.4); }
    100% { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
}

/* Navigation bar */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: #fff;
    z-index: 1000; /* Above container, below chatbot */
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

nav ul {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
}

nav ul li {
    margin-right: 20px;
}

nav ul li a {
    text-decoration: none;
    color: #333;
    font-size: 16px;
    padding: 12px;
    display: inline-block;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
    line-height: 1;
}

/* Language switcher dropdown */
.eyebrow__content {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.layout--xl {
    max-width: 1200px;
    margin: 0 auto;
}

.btn {
    cursor: pointer;
    text-decoration: none;
}

.btn--link {
    background: none;
    border: none;
    color: #333;
}

.btn--sm {
    font-size: 14px;
    padding: 6px 12px;
}

.dropdown-content--sm {
    min-width: 120px;
}

/* Mobile-specific adjustments */
@media only screen and (max-width: 767px) {
    nav {
        padding: 5px 10px;
    }

    nav ul {
        flex-direction: column;
        align-items: flex-start;
    }

    nav ul li {
        margin-right: 0;
        margin-bottom: 12px;
    }

    nav ul li a {
        padding: 10px;
        font-size: 14px;
        min-height: 48px;
    }

    .container {
        margin-top: 120px;
        padding: 0 10px;
    }

    .cta-button, a.cta-button {
        padding: 10px 20px;
        font-size: 14px;
        min-height: 48px;
    }

    a:not(.cta-button) {
        padding: 6px;
        font-size: 14px;
        min-height: 48px;
    }

    .eyebrow__content {
        justify-content: space-between;
    }
}

/* Ensure focus states for accessibility */
a:focus, button:focus, .cta-button:focus {
    outline: 2px solid #005b96;
    outline-offset: 2px;
}
