/* Chatbot IA - Estilos Frontend */

:root {
    --chatbot-primary-color: #4285f4;
    --chatbot-text-color: #333;
    --chatbot-bg-color: #fff;
    --chatbot-border-color: #e0e0e0;
    --chatbot-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Widget flotante */
.chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.chatbot-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.chatbot-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Prevenir overflow horizontal */
.chatbot-widget * {
    box-sizing: border-box;
}

body.chatbot-open {
    overflow: hidden;
}

/* Botón flotante */
.chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-primary-color);
    border: none;
    cursor: pointer;
    box-shadow: var(--chatbot-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle-btn .chatbot-icon {
    width: 28px;
    height: 28px;
    color: white;
    transition: all 0.3s ease;
}

.chatbot-icon-close {
    display: none;
    position: absolute;
}

.chatbot-widget.chatbot-open .chatbot-icon-chat {
    display: none;
}

.chatbot-widget.chatbot-open .chatbot-icon-close {
    display: block;
}

/* Ventana del chat */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    height: 600px;
    background: var(--chatbot-bg-color);
    border-radius: 16px;
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Posicionamiento según configuración */
.chatbot-position-bottom-right .chatbot-window {
    right: 0;
    left: auto;
}

.chatbot-position-bottom-left .chatbot-window {
    left: 0;
    right: auto;
}

.chatbot-widget.chatbot-open .chatbot-window {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.chatbot-header {
    background: var(--chatbot-primary-color);
    color: white;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chatbot-header-text {
    display: flex;
    flex-direction: column;
}

.chatbot-bot-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-minimize-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.chatbot-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chatbot-minimize-btn svg {
    width: 20px;
    height: 20px;
}

/* Área de mensajes */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
}

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

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

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

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

/* Mensajes */
.chatbot-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

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

.chatbot-message-user {
    flex-direction: row-reverse;
}

.chatbot-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.chatbot-message-bot .chatbot-message-bubble {
    background: white;
    color: var(--chatbot-text-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Formato del contenido HTML en mensajes del bot */
.chatbot-message-bot .chatbot-message-bubble p {
    margin: 0 0 10px 0;
}

.chatbot-message-bot .chatbot-message-bubble p:last-child {
    margin-bottom: 0;
}

.chatbot-message-bot .chatbot-message-bubble strong {
    font-weight: 600;
    color: var(--chatbot-primary-color);
}

.chatbot-message-bot .chatbot-message-bubble em {
    font-style: normal;
    font-weight: 500;
}

.chatbot-message-bot .chatbot-message-bubble ul,
.chatbot-message-bot .chatbot-message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chatbot-message-bot .chatbot-message-bubble li {
    margin: 4px 0;
    line-height: 1.6;
}

.chatbot-message-bot .chatbot-message-bubble ul li {
    list-style-type: disc;
}

.chatbot-message-bot .chatbot-message-bubble ol li {
    list-style-type: decimal;
}

.chatbot-message-bot .chatbot-message-bubble code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.chatbot-message-bot .chatbot-message-bubble a {
    color: var(--chatbot-primary-color);
    text-decoration: underline;
}

.chatbot-message-bot .chatbot-message-bubble a:hover {
    opacity: 0.8;
}

.chatbot-message-user .chatbot-message-bubble {
    background: var(--chatbot-primary-color);
    color: white;
    margin-left: auto;
}

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

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

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

.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 */
.chatbot-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--chatbot-border-color);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border-color);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary-color);
}

.chatbot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chatbot-primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
    background: #3367d6;
    transform: scale(1.05);
}

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

.chatbot-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Footer */
.chatbot-footer {
    padding: 8px 20px;
    text-align: center;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
    border-top: 1px solid var(--chatbot-border-color);
}

.chatbot-footer small {
    color: #999;
    font-size: 11px;
}

/* Mensaje de error */
.chatbot-error-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-hide-mobile {
        display: none !important;
    }

    .chatbot-window {
        width: calc(100vw - 20px);
        max-width: 380px;
        height: calc(100vh - 100px);
        max-height: 600px;
        bottom: 10px;
        left: 10px !important;
        right: 10px !important;
        margin: 0 auto;
    }

    .chatbot-widget.chatbot-open .chatbot-window {
        transform: scale(1) translateY(0);
    }

    .chatbot-position-bottom-right,
    .chatbot-position-bottom-left {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .chatbot-toggle-btn {
        bottom: 10px;
    }
}

/* Tablets */
@media (max-width: 768px) and (min-width: 481px) {
    .chatbot-window {
        width: 360px;
        height: 550px;
    }
}

/* Asegurar que nunca se salga del viewport */
@media (max-width: 400px) {
    .chatbot-window {
        width: calc(100vw - 10px);
        left: 5px !important;
        right: 5px !important;
    }
}

/* Shortcode inline */
.chatbot-shortcode-container {
    margin: 20px 0;
}

.chatbot-inline-window {
    position: relative !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: all !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Animaciones suaves */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
