/* Contenedor principal del widget */
#innova-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    display: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

    #innova-chat-widget.widget-visible {
        opacity: 1;
        transform: translateY(0);
    }

/* Botón flotante */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1000;
}

    .chat-toggle-btn:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    }

    .chat-toggle-btn .chat-icon {
        transition: transform 0.3s ease;
    }

    .chat-toggle-btn:hover .chat-icon {
        transform: scale(1.1);
    }

/* Badge de notificación */
.notification-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;
}

/* Ventana de chat */
.chat-window {
    width: 350px;
    height: 500px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header del chat */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bot-name {
    font-weight: 600;
    font-size: 16px;
}

.bot-status {
    font-size: 12px;
    opacity: 0.8;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.minimize-btn,
.close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.2s ease;
}

    .minimize-btn:hover,
    .close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

/* Área de mensajes */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f8f9fa;
}

    .chat-messages::-webkit-scrollbar {
        width: 4px;
    }

    .chat-messages::-webkit-scrollbar-track {
        background: transparent;
    }

    .chat-messages::-webkit-scrollbar-thumb {
        background: #ddd;
        border-radius: 2px;
    }

/* Mensajes */
.chat-message {
    display: flex;
    flex-direction: column;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.bot {
    align-items: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.bot .message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    padding: 0 8px;
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 70px;
    align-self: flex-start;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

    .typing-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #667eea;
        animation: typingDot 1.4s infinite;
    }

        .typing-dots span:nth-child(1) {
            animation-delay: 0s;
        }

        .typing-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Área de input */
.chat-input-area {
    border-top: 1px solid #e1e5e9;
    padding: 15px 20px;
    background: white;
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 20px;
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    transition: border-color 0.2s ease;
}

    .chat-input-container:focus-within {
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    min-height: 20px;
    max-height: 80px;
    padding: 6px 0;
    font-family: inherit;
}

    .chat-input::placeholder {
        color: #888;
    }

.chat-send-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

    .chat-send-btn:hover {
        background: #5a67d8;
        transform: scale(1.05);
    }

    .chat-send-btn:disabled {
        background: #ddd;
        cursor: not-allowed;
        transform: none;
    }

/* Branding */
.chat-branding {
    text-align: center;
    margin-top: 8px;
    font-size: 11px;
    color: #888;
}

    .chat-branding a {
        color: #667eea;
        text-decoration: none;
    }

        .chat-branding a:hover {
            text-decoration: underline;
        }

/* Archivos adjuntos */
.file-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    max-width: 100%;
}

.file-icon {
    font-size: 24px;
    opacity: 0.7;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

.file-download-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}

    .file-download-btn:hover {
        background: #5a67d8;
    }

/* Gráficos */
.chart-container {
    margin-top: 8px;
    background: white;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e1e5e9;
}

    .chart-container canvas {
        max-width: 100%;
        height: auto;
    }

/* Widgets interactivos */
.widget-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.widget-btn {
    background: white;
    border: 1px solid #667eea;
    color: #667eea;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    text-align: center;
}

    .widget-btn:hover {
        background: #667eea;
        color: white;
    }

    .widget-btn.primary {
        background: #667eea;
        color: white;
    }

        .widget-btn.primary:hover {
            background: #5a67d8;
        }

/* Posicionamiento */
.innova-chat-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.innova-chat-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

.innova-chat-widget.top-right {
    top: 20px;
    right: 20px;
}

.innova-chat-widget.top-left {
    top: 20px;
    left: 20px;
}

/* Tema claro/oscuro */
.innova-chat-widget.dark .chat-window {
    background: #2d3748;
    color: white;
}

.innova-chat-widget.dark .chat-messages {
    background: #4a5568;
}

.innova-chat-widget.dark .chat-message.bot .message-content {
    background: #2d3748;
    color: white;
    border-color: #4a5568;
}

.innova-chat-widget.dark .chat-input-area {
    background: #2d3748;
    border-color: #4a5568;
}

.innova-chat-widget.dark .chat-input-container {
    background: #4a5568;
    border-color: #718096;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        max-height: none;
        border-radius: 0;
        position: fixed;
        top: 20px;
        left: 20px;
        right: 20px;
        bottom: 20px;
    }

    .chat-toggle-btn {
        width: 50px;
        height: 50px;
    }

    .innova-chat-widget {
        bottom: 15px !important;
        right: 15px !important;
    }
}

/* Estados de error */
.message-content.error {
    background: #fed7d7 !important;
    color: #c53030 !important;
    border-color: #feb2b2 !important;
}

/* Animaciones adicionales */
.chat-window.minimizing {
    animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

/* Loading spinner */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}
