/* NexGen Chatbot Styles - Versión Bidireccional */
.nexgen-chatbot {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nexgen-chatbot.nexgen-bottom-right {
    bottom: 20px;
    right: 20px;
}

.nexgen-chatbot.nexgen-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Botón del chatbot */
.nexgen-chatbot-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(51deg, var(--primary-color, #007cba) 0%, var(--secondary-color, #00ba7c) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    color: white;
    position: relative;
}

.nexgen-chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.nexgen-chatbot-toggle svg { transition: all 0.3s ease; }
.nexgen-chatbot-toggle .close-icon { font-size: 24px; font-weight: bold; }

/* Badge de notificación */
.nexgen-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Ventana del chatbot */
.nexgen-chatbot-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--background-color, #ffffff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.nexgen-bottom-left .nexgen-chatbot-window { right: auto; left: 0; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header del chatbot */
.nexgen-chatbot-header {
    background: linear-gradient(51deg, var(--primary-color, #007cba) 0%, var(--secondary-color, #00ba7c) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nexgen-chatbot-header h3 { margin: 0; font-size: 16px; font-weight: 600; }

/* Indicador de estado */
.nexgen-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
.nexgen-status-dot {
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    animation: blink 2s infinite;
}
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.nexgen-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}
.nexgen-chatbot-close:hover { background-color: rgba(255, 255, 255, 0.1); }

/* Área de mensajes */
.nexgen-chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
}
.nexgen-chatbot-messages::-webkit-scrollbar { width: 6px; }
.nexgen-chatbot-messages::-webkit-scrollbar-track { background: #f1f1f1; }
.nexgen-chatbot-messages::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
.nexgen-chatbot-messages::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* Mensajes */
.nexgen-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.3s ease-out;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.nexgen-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}
.nexgen-user-message { align-self: flex-end; }
.nexgen-user-message .nexgen-message-content {
    background: linear-gradient(51deg, var(--primary-color, #007cba) 0%, var(--secondary-color, #00ba7c) 100%);
    color: white;
    border-bottom-right-radius: 6px;
}
.nexgen-bot-message .nexgen-message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 6px;
    align-self: flex-start;
}

.nexgen-message-time {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    align-self: flex-end;
}
.nexgen-bot-message .nexgen-message-time { align-self: flex-start; }

/* Mensajes del sistema */
.nexgen-system-message { text-align: center; margin: 10px 0; }
.nexgen-system-message .nexgen-message-content {
    background: #e3f2fd;
    color: #1976d2;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 12px;
    align-self: center;
    max-width: 90%;
}

/* Área de input */
.nexgen-chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 8px;
    align-items: center;
}
.nexgen-chatbot-input-area input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.nexgen-chatbot-input-area input:focus { border-color: var(--primary-color, #007cba); }

.nexgen-chatbot-input-area button {
    width: 40px;
    height: 40px;
    background: linear-gradient(51deg, var(--primary-color, #007cba) 0%, var(--secondary-color, #00ba7c) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.nexgen-chatbot-input-area button:hover {
    background: linear-gradient(51deg, 
        color-mix(in srgb, var(--primary-color, #007cba) 85%, black), 
        color-mix(in srgb, var(--secondary-color, #00ba7c) 85%, black));
    transform: scale(1.05);
}
.nexgen-chatbot-input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Indicador de escritura */
.nexgen-chatbot-typing {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 13px;
}
.nexgen-typing-indicator { display: flex; gap: 3px; }
.nexgen-typing-indicator span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}
.nexgen-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.nexgen-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Overlay para capturar nombre */
.nexgen-name-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 5;
}
.nexgen-name-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.nexgen-name-title { font-weight: 600; margin-bottom: 6px; font-size: 16px; }
.nexgen-name-label { font-size: 13px; color: #555; display: block; margin-bottom: 8px; }
.nexgen-name-input {
    width: 100%;
    margin: 8px 0 12px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
}
.nexgen-name-input:focus { border-color: var(--primary-color, #007cba); }
.nexgen-name-button {
    background: linear-gradient(51deg, var(--primary-color, #007cba) 0%, var(--secondary-color, #00ba7c) 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    width: 100%;
}
.nexgen-input-error { border-color: #dc2626 !important; }

/* Responsive */
@media (max-width: 768px) {
    .nexgen-chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        max-width: 350px;
        max-height: 600px;
    }
    .nexgen-chatbot.nexgen-bottom-right { right: 10px; bottom: 10px; }
    .nexgen-chatbot.nexgen-bottom-left { left: 10px; bottom: 10px; }
}

@media (max-width: 480px) {
    .nexgen-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        position: fixed;
        bottom: 80px;
        left: 10px;
        right: 10px;
    }
    .nexgen-bottom-left .nexgen-chatbot-window { left: 10px; right: 10px; }
}

/* Enlaces dentro de mensajes */
.nexgen-message-content a { color: var(--primary-color, #007cba); text-decoration: none; }
.nexgen-message-content a:hover { text-decoration: underline; }