/* Importar fuente moderna */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    --chat-primary: #0f0fab;
    --chat-primary-hover: #0a0a80;
    --chat-bg: #ffffff;
    --chat-text: #1f2937;
    --chat-text-muted: #6b7280;
    --chat-border: #e5e7eb;
    --chat-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --chat-bot-bubble: #f3f4f6;
    --chat-user-bubble: #0f0fab;
    --chat-user-text: #ffffff;
    --chat-font: 'Inter', sans-serif;
    --chat-z-index: 9999;
}

#premium-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--chat-z-index);
    font-family: var(--chat-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

/* Botón Flotante para abrir/cerrar */
.chat-launcher {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chat-primary), #2b50f6);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(15, 15, 171, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    border: none;
    outline: none;
    animation: launcherZoomIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
    pointer-events: auto;
}

.chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 15px 20px -3px rgba(15, 15, 171, 0.5);
}

.chat-launcher svg {
    width: 30px;
    height: 30px;
    fill: white;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.chat-launcher .close-icon {
    display: none;
    width: 24px;
    height: 24px;
}

#premium-chatbot-container.is-open .chat-launcher {
    transform: scale(0.9);
}

#premium-chatbot-container.is-open .chat-launcher .chat-icon {
    display: none;
}

#premium-chatbot-container.is-open .chat-launcher .close-icon {
    display: block;
}

/* Ventana del Chat */
.chat-window {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 100px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(40px) scale(0);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#premium-chatbot-container.is-open .chat-window {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header del Chat */
.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), #2b50f6);
    padding: 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.chat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-title-container {
    display: flex;
    flex-direction: column;
}

.chat-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.chat-status {
    font-size: 0.72rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Área de Mensajes */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fdfdfd;
    scroll-behavior: smooth;
}

/* Estilos de Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 0.85rem;
    line-height: 1.4;
    animation: fadeIn 0.3s ease forwards;
    word-wrap: break-word;
}

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

.message.bot {
    align-self: flex-start;
    background-color: var(--chat-bot-bubble);
    color: var(--chat-text);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message.user {
    align-self: flex-end;
    background-color: var(--chat-user-bubble);
    color: var(--chat-user-text);
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 4px rgba(15, 15, 171, 0.2);
}

.message a {
    color: inherit;
    text-decoration: underline;
}

/* Indicador de escribiendo */
.typing-indicator {
    display: none;
    align-self: flex-start;
    background-color: var(--chat-bot-bubble);
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    gap: 4px;
    align-items: center;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Área de Input */
.chat-input-area {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}

.chat-input:focus {
    border-color: var(--chat-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(15, 15, 171, 0.1);
}

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

.chat-send-btn:hover {
    background: var(--chat-primary-hover);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    margin-left: 2px; /* Centro óptico del icono de enviar */
}

.chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Botón de Handoff Humano */
.human-handoff-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 16px;
    background: white;
    color: var(--chat-primary);
    border: 2px solid var(--chat-primary);
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
}

.human-handoff-btn:hover {
    background: var(--chat-primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(15, 15, 171, 0.2);
}

.human-handoff-btn svg {
    transition: transform 0.2s ease;
}

.human-handoff-btn:hover svg {
    transform: translateX(3px);
}

/* Responsividad para móviles */
@media (max-width: 480px) {
    #premium-chatbot-container {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
    }
}

/* Animación de entrada para el lanzador */
@keyframes launcherZoomIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
