/**
 * CDMX Axolotl Chatbot - Estilos
 * Tema: Día de Muertos
 */

/* ================================
   Contenedor Principal
   ================================ */
#cdmx-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ================================
   Botón del Personaje (Axolotl)
   ================================ */
.cdmx-chatbot-button {
    width: 180px;
    height: 270px;
    border-radius: 0;
    background: none;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
    animation: floatAnimation 3s ease-in-out infinite;
}

.cdmx-chatbot-button:hover {
    transform: scale(1.05);
}

.cdmx-chatbot-button:active {
    transform: scale(0.95);
}

.cdmx-chatbot-character {
    width: 180px;
    height: 270px;
    object-fit: contain;
    filter: none;
}

/* Animación de flotación */
@keyframes floatAnimation {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Efecto de pulso */
.cdmx-chatbot-pulse {
    display: none; /* Círculo dorado desactivado */
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(251, 183, 121, 0.4);
    animation: pulseAnimation 2s infinite;
    pointer-events: none;
}

@keyframes pulseAnimation {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ================================
   Ventana de Chat
   ================================ */
.cdmx-chatbot-window {
    position: fixed;
    bottom: 110px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 650px; /* Aumentado de 550px a 650px (+100px más alto) */
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

/* ================================
   Header del Chat
   ================================ */
.cdmx-chatbot-header {
    background: linear-gradient(135deg, #974fb9 0%, #7a3d96 100%);
    color: #ffffff;
    padding: 12px 16px; /* Reducido de 20px a 12px vertical, 16px horizontal */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.cdmx-chatbot-header-content {
    display: flex;
    align-items: center;
    flex: 1;
}

.cdmx-chatbot-header-avatar {
    width: 45px; /* Reducido de 60px a 45px */
    height: 45px; /* Reducido de 60px a 45px */
    border-radius: 50%;
    background: #ffffff;
    padding: 4px; /* Reducido de 5px a 4px */
    margin-right: 10px; /* Reducido de 12px a 10px */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cdmx-chatbot-header-info h3 {
    margin: 0;
    font-size: 15px; /* Reducido de 16px a 15px */
    font-weight: 600;
}

.cdmx-chatbot-status {
    font-size: 11px; /* Reducido de 12px a 11px */
    opacity: 0.9;
    display: flex;
    align-items: center;
    margin-top: 2px; /* Agregado para separación */
}

.cdmx-chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

.cdmx-chatbot-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.cdmx-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ================================
   Área de Mensajes
   ================================ */
.cdmx-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px; /* Reducido de 20px a 12px vertical, 16px horizontal */
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px; /* Reducido de 12px a 10px para más mensajes visibles */
}

.cdmx-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.cdmx-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cdmx-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.cdmx-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ================================
   Mensajes
   ================================ */
.cdmx-chatbot-message {
    display: flex;
    margin-bottom: 12px;
    animation: messageSlide 0.3s ease-out;
}

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

.cdmx-chatbot-message.user {
    justify-content: flex-end;
}

.cdmx-chatbot-message.bot {
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
}

.cdmx-chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Links dentro de mensajes */
.cdmx-chatbot-message-content a {
    color: #974fb9;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.2s ease;
}

.cdmx-chatbot-message-content a:hover {
    color: #7a3d96;
    text-decoration: underline;
}

/* Links en mensajes del usuario (color más claro) */
.cdmx-chatbot-message.user .cdmx-chatbot-message-content a {
    color: #ffd700;
    font-weight: 600;
}

.cdmx-chatbot-message.user .cdmx-chatbot-message-content a:hover {
    color: #ffed4e;
}

.cdmx-chatbot-message.user .cdmx-chatbot-message-content {
    background: linear-gradient(135deg, #974fb9 0%, #7a3d96 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.cdmx-chatbot-message.bot .cdmx-chatbot-message-content {
    background: #ffffff;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Indicador de escritura */
.cdmx-chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.cdmx-chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

.cdmx-chatbot-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.cdmx-chatbot-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* ================================
   Área de Input
   ================================ */
.cdmx-chatbot-input-area {
    display: flex;
    align-items: flex-end; /* Alinear elementos al fondo (mejora centrado visual) */
    padding: 12px 16px; /* Reducido de 16px a 12px vertical para más espacio arriba */
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    gap: 8px;
}

.cdmx-chatbot-input {
    flex: 1;
    padding: 8px 14px; /* Reducido padding vertical de 10px a 8px */
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: none; /* Prevenir resize manual */
    overflow-y: auto; /* Scroll si el texto es muy largo */
    max-height: 80px; /* Altura máxima del textarea */
    min-height: 38px; /* Altura mínima (misma que el botón) */
    line-height: 1.4; /* Mejor legibilidad */
}

.cdmx-chatbot-input:focus {
    border-color: #974fb9;
}

.cdmx-chatbot-send {
    width: 38px; /* Ajustado para igualar altura del input */
    height: 38px; /* Ajustado para igualar altura del input */
    min-width: 38px; /* Evitar colapso */
    min-height: 38px; /* Evitar colapso */
    border-radius: 50%;
    background: linear-gradient(135deg, #974fb9 0%, #7a3d96 100%);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center; /* Centrado vertical del ícono */
    justify-content: center; /* Centrado horizontal del ícono */
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(151, 79, 185, 0.3);
    flex-shrink: 0; /* No permitir que se reduzca */
    padding: 0; /* Sin padding interno para mejor centrado */
    line-height: 1; /* Asegurar centrado del ícono */
}

.cdmx-chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(151, 79, 185, 0.4);
}

.cdmx-chatbot-send:active {
    transform: scale(0.95);
}

.cdmx-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* SVG dentro del botón de enviar - asegurar centrado perfecto */
.cdmx-chatbot-send svg {
    display: block; /* Eliminar espacio extra de inline */
    width: 18px; /* Tamaño ajustado del ícono */
    height: 18px; /* Tamaño ajustado del ícono */
    margin: auto; /* Centrado automático */
    vertical-align: middle; /* Alineación vertical */
}

/* ================================
   Responsive
   ================================ */
@media (max-width: 480px) {
    .cdmx-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        bottom: 10px;
        right: 10px;
    }

    #cdmx-chatbot-widget {
        bottom: 10px;
        right: 10px;
    }

    .cdmx-chatbot-button {
        width: 120px;
        height: 180px;
    }

    .cdmx-chatbot-character {
        width: 120px;
        height: 180px;
    }
}

/* ================================
   Ventana de Teléfono
   ================================ */
#cdmx-chatbot-phone-prompt {
    height: auto;
}

.cdmx-chatbot-phone-input-area {
    padding: 20px;
    background: #f8f9fa;
}

#cdmx-chatbot-phone-prompt .cdmx-chatbot-header-info span {
    font-size: 13px;
    opacity: 0.9;
}

#cdmx-chatbot-phone-prompt .cdmx-chatbot-input-area {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
}

/* ================================
   Banner Flotante Informativo
   ================================ */
.cdmx-chatbot-banner {
    position: fixed;
    bottom: 300px;
    right: 30px;
    z-index: 9998;
    max-width: 90vw;
    animation: slideInRight 0.5s ease-out;
}

.cdmx-chatbot-banner-image {
    width: 100%;
    max-width: 780px;
    height: auto;
    display: block;
    cursor: pointer;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.cdmx-chatbot-banner-image:hover {
    transform: scale(1.02);
}

.cdmx-chatbot-banner-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}

.cdmx-chatbot-banner-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive para el banner */
@media (max-width: 1024px) {
    .cdmx-chatbot-banner {
        right: 20px;
        bottom: 280px;
    }

    .cdmx-chatbot-banner-image {
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .cdmx-chatbot-banner {
        right: 10px;
        bottom: 240px;
        max-width: 95vw;
    }

    .cdmx-chatbot-banner-image {
        max-width: 450px;
        border-radius: 12px;
    }

    .cdmx-chatbot-banner-close {
        width: 32px;
        height: 32px;
        font-size: 20px;
        top: 8px;
        right: 8px;
    }
}

@media (max-width: 480px) {
    .cdmx-chatbot-banner {
        right: 5px;
        bottom: 220px;
        left: 5px;
        max-width: calc(100vw - 10px);
    }

    .cdmx-chatbot-banner-image {
        max-width: 100%;
        width: 100%;
        border-radius: 8px;
    }

    .cdmx-chatbot-banner-close {
        width: 28px;
        height: 28px;
        font-size: 18px;
        top: 5px;
        right: 5px;
    }
}

/* ================================
   Botones de Opciones de Menú
   ================================ */
.cdmx-chatbot-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.cdmx-chatbot-option-button {
    background: linear-gradient(135deg, #974fb9 0%, #b76ecf 100%);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    box-shadow: 0 2px 8px rgba(151, 79, 185, 0.3);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.cdmx-chatbot-option-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #b76ecf 0%, #974fb9 100%);
    box-shadow: 0 4px 12px rgba(151, 79, 185, 0.5);
    transform: translateY(-2px);
}

.cdmx-chatbot-option-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(151, 79, 185, 0.4);
}

.cdmx-chatbot-option-button:disabled,
.cdmx-chatbot-option-button.disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

/* Responsive para botones */
@media (max-width: 480px) {
    .cdmx-chatbot-option-button {
        font-size: 13px;
        padding: 10px 16px;
    }
}

/* ================================
   MODO DUAL: Indicadores RapidPro/Ollama
   ================================ */

/*
 * NOTA: Indicador de modo OCULTO para usuarios finales
 * El sistema dual sigue funcionando, solo se muestra en console.log para debugging
 */

/* Indicador de modo en el header - OCULTO */
.cdmx-chatbot-mode-indicator {
    display: none !important; /* Oculto para usuarios */
    /*
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    opacity: 0.95;
    animation: fadeInMode 0.4s ease-in-out;
    */
}

.cdmx-chatbot-mode-indicator .mode-icon {
    display: none; /* Oculto */
}

/* Modo RapidPro (Menú) - OCULTO */
.cdmx-chatbot-mode-indicator.mode-rapidpro {
    display: none; /* Oculto */
}

/* Modo Ollama (Conversación) - OCULTO */
.cdmx-chatbot-mode-indicator.mode-ollama {
    display: none; /* Oculto */
}

/* Animación deshabilitada */
@keyframes fadeInMode {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 0;
        transform: translateY(0);
    }
}

/* Botón "Volver al Menú" */
.cdmx-chatbot-menu-button {
    width: 100%;
    padding: 10px 16px; /* Reducido de 12px/20px a 10px/16px */
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 13px; /* Reducido de 14px a 13px */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px; /* Reducido de 8px a 6px */
    margin: 10px 16px; /* Reducido de 12px a 10px vertical */
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.cdmx-chatbot-menu-button:hover {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
    transform: translateY(-2px);
}

.cdmx-chatbot-menu-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
}

/* Animación de entrada del botón */
@keyframes slideInButton {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para el botón de menú */
@media (max-width: 480px) {
    .cdmx-chatbot-menu-button {
        font-size: 13px;
        padding: 10px 16px;
        margin: 10px 12px;
    }

    /* Indicador de modo oculto también en móvil */
    .cdmx-chatbot-mode-indicator {
        display: none !important; /* Oculto */
    }
}

/* ================================
   Google Maps Embed - Estilos
   ================================ */
.cdmx-chatbot-map-container {
    margin: 15px 0;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 12px;
    display: block !important;
    width: 100% !important;
    clear: both;
    box-sizing: border-box;
    float: none !important;
}

/* Asegurar que los mapas dentro de mensajes estén en cascada */
.cdmx-chatbot-message.bot .cdmx-chatbot-map-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 10px;
}

.cdmx-chatbot-map-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 0;
}

.cdmx-chatbot-map-header span:first-child {
    font-size: 1.1em;
}

.cdmx-chatbot-map-header span:last-child {
    margin-left: 6px;
    font-weight: 600;
    color: #333;
    font-size: 0.85em;
    line-height: 1.3;
    word-break: break-word;
}

.cdmx-chatbot-map-iframe-wrapper {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    background: #e8e8e8;
}

.cdmx-chatbot-map-iframe-wrapper iframe {
    border: 0;
    display: block;
    width: 100%;
    height: 160px;
}

.cdmx-chatbot-map-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    padding: 8px 14px;
    background: #4285f4;
    color: white !important;
    text-decoration: none !important;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
    transition: background 0.2s, transform 0.2s;
    box-shadow: 0 2px 4px rgba(66, 133, 244, 0.3);
    width: 100%;
    text-align: center;
}

.cdmx-chatbot-map-button:hover {
    background: #3367d6;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(66, 133, 244, 0.4);
}

.cdmx-chatbot-map-button:active {
    transform: translateY(0);
}

.cdmx-chatbot-map-button span {
    margin-right: 6px;
}

/* Responsive para mapas en móvil */
@media (max-width: 480px) {
    .cdmx-chatbot-map-container {
        padding: 10px;
        margin: 12px 0;
    }

    .cdmx-chatbot-map-iframe-wrapper iframe {
        height: 140px;
    }

    .cdmx-chatbot-map-button {
        font-size: 0.8em;
        padding: 7px 14px;
    }

    .cdmx-chatbot-map-header span:last-child {
        font-size: 0.85em;
    }
}