/* Chatbot Styles - Moderno, sobrio pero llamativo, amigable para todas las edades */

/* Contenedor fijo: esquina inferior derecha, siempre visible, máximo z-index */
#chatbot-fab-wrapper {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
    z-index: 2147483647 !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 24px;
    pointer-events: none;
    box-sizing: border-box;
}
#chatbot-fab-wrapper .chatbot-toggle,
#chatbot-fab-wrapper #chatbot-toggle {
    pointer-events: auto;
}

/* Botón flotante del chatbot: usa tema del portal (--theme-*) */
.chatbot-toggle,
#chatbot-toggle {
    position: relative !important;
    bottom: auto !important;
    right: auto !important;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--theme-gradient, linear-gradient(135deg, #0066cc 0%, #004499 100%));
    border: none;
    box-shadow: 0 8px 25px rgba(var(--theme-focus-rgba, 0, 102, 204), 0.4);
    cursor: pointer;
    z-index: 99999 !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    overflow: hidden;
    padding: 8px;
    box-sizing: border-box;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(var(--theme-focus-rgba, 0, 102, 204), 0.6);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle img,
.chatbot-toggle .chatbot-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    border: 3px solid rgba(255, 255, 255, 0.5);
    display: block;
    /*background: rgba(255, 255, 255, 0.1);*/
}

.chatbot-toggle .chat-icon {
    font-size: 32px;
    color: white;
}

/* Animación de pulso (color por tema) */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(var(--theme-focus-rgba, 0, 102, 204), 0.4);
    }
    50% {
        box-shadow: 0 8px 35px rgba(var(--theme-focus-rgba, 0, 102, 204), 0.7);
    }
}

/* Badge de notificación */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Contenedor del chatbot: sobre el botón, por encima de todo */
.chatbot-container {
    position: fixed;
    bottom: 110px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 60px);
    height: 600px;
    max-height: calc(100vh - 150px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 99998 !important;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-container.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header del chatbot (tema del portal) */
.chatbot-header {
    background: var(--theme-gradient, linear-gradient(135deg, #0066cc 0%, #004499 100%));
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-radius: 20px 20px 0 0;
}

.chatbot-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    animation: bounce 2s infinite;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    display: block;
    background: rgba(255, 255, 255, 0.1);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chatbot-header-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-close {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Área de mensajes */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--theme-primary, #03b31b);
    border-radius: 10px;
}

/* Mensajes */
.chatbot-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message.user {
    flex-direction: row-reverse;
}

.chatbot-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    overflow: hidden;
    position: relative;
}

.chatbot-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    display: block;
    background: rgba(255, 255, 255, 0.1);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.chatbot-message.bot .chatbot-message-avatar {
    background: var(--theme-gradient, linear-gradient(135deg, #0066cc 0%, #004499 100%));
    color: white;
}

.chatbot-message.user .chatbot-message-avatar {
    background: #e9ecef;
    color: #495057;
}

.chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.chatbot-message.bot .chatbot-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-message.user .chatbot-message-content {
    background: var(--theme-gradient, linear-gradient(135deg, #0066cc 0%, #004499 100%));
    color: white;
    border-bottom-right-radius: 4px;
}

/* Indicador de escritura */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: var(--theme-primary, #0066cc);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input area */
.chatbot-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.chatbot-input:focus {
    border-color: var(--theme-primary, #0066cc);
    box-shadow: 0 0 0 3px rgba(var(--theme-focus-rgba, 0, 102, 204), 0.1);
}

.chatbot-send {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--theme-gradient, linear-gradient(135deg, #0066cc 0%, #004499 100%));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(var(--theme-focus-rgba, 0, 102, 204), 0.4);
}

.chatbot-send:active {
    transform: scale(0.95);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Sugerencias rápidas */
.chatbot-suggestions {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 100px;
    overflow-y: auto;
}

.chatbot-suggestion {
    padding: 6px 12px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
}

.chatbot-suggestion:hover {
    background: var(--theme-primary, #0066cc);
    color: white;
    border-color: var(--theme-primary, #0066cc);
    transform: translateY(-2px);
}

/* Mejoras adicionales para la imagen */
.chatbot-toggle img,
.chatbot-toggle .chatbot-avatar-img,
.chatbot-avatar img,
.chatbot-message-avatar img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Asegurar que la imagen se vea bien en el botón flotante (sin cambiar position del botón) */
.chatbot-toggle .chatbot-avatar-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Escritorio: contenedor siempre visible esquina inferior derecha */
@media (min-width: 769px) {
    #chatbot-fab-wrapper {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        padding: 24px;
    }
}

/* Responsive móvil */
@media (max-width: 768px) {
    .chatbot-container {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 100px;
        height: calc(100vh - 120px);
    }
    
    #chatbot-fab-wrapper {
        padding: 20px;
    }
    
    .chatbot-toggle,
    #chatbot-toggle {
        display: flex !important;
        visibility: visible !important;
        width: 60px;
        height: 60px;
    }
    
    .chatbot-toggle img,
    .chatbot-toggle .chatbot-avatar-img {
        width: 100%;
        height: 100%;
    }
    
    .chatbot-toggle .chat-icon {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }
}

/* Mensaje de bienvenida */
.chatbot-welcome {
    text-align: center;
    padding: 20px;
    color: #6c757d;
}

.chatbot-welcome h4 {
    color: var(--theme-primary, #0066cc);
    margin-bottom: 10px;
}

.chatbot-welcome p {
    font-size: 13px;
    line-height: 1.6;
}

