/* public/css/chatbot.css */
@import 'index/variables.css';

:root {
    --chat-bg: rgba(255, 255, 255, 0.85);
    --chat-blur: 20px;
    --bot-bubble: #f1f5f9;
    --user-bubble: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --chat-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}

/* Contenedor principal */
#chatbot-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 2000;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Botón flotante para abrir */
#chatbot-opener {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 20px; /* Squircle style */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 25px rgba(26, 54, 93, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2001;
}

#chatbot-opener:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 30px rgba(26, 54, 93, 0.4);
}

#chatbot-opener img {
    width: 35px;
    height: 35px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Ventana del Chat */
#chatbot-window {
    width: 380px;
    height: 600px;
    max-height: 80vh;
    border-radius: 24px;
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--chat-bg);
    backdrop-filter: blur(var(--chat-blur));
    -webkit-backdrop-filter: blur(var(--chat-blur));
    border: 1px solid rgba(255, 255, 255, 0.6);
    z-index: 2002;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    position: absolute;
    /* JS will handle top/bottom/left/right */
}

/* Animations for open/close */
#chatbot-window.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    display: flex !important;
}


/* Cabecera */
#chatbot-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2003;
    user-select: none;
    -webkit-user-select: none;
}

#chatbot-header span {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.chatbot-header-controls {
    display: flex;
    gap: 8px;
}

#chatbot-restart-btn,
#chatbot-minimize-btn,
#chatbot-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s;
}

#chatbot-restart-btn:hover,
#chatbot-minimize-btn:hover,
#chatbot-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Cuerpo del Chat */
#chatbot-body {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    scroll-behavior: smooth;
}

#chatbot-body::-webkit-scrollbar {
    width: 4px;
}
#chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* Mensajes */
.message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 85%;
    font-size: 14.5px;
    line-height: 1.5;
    position: relative;
    animation: slideUp 0.3s ease-out;
}

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

/* Mensaje Usuario */
.user-message {
    background: var(--user-bubble);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Mensaje Bot */
.bot-message {
    background: var(--bot-bubble);
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

/* Opciones (Botones) */
.chatbot-options {
    align-self: center;
    width: 90%;
    margin: 10px 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.option-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    color: var(--primary-color);
    padding: 14px;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(5px);
}

.option-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(26, 54, 93, 0.2);
}

/* Footer (Input) */
#chatbot-footer {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

#chatbot-input {
    flex-grow: 1;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    padding: 12px 18px;
    outline: none;
    font-size: 15px;
    background: white;
    transition: all 0.3s;
}

#chatbot-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

#chatbot-send-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#chatbot-send-btn:hover {
    transform: rotate(15deg) scale(1.1);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

/* Indicador de Escritura / Asesor */
.typing-indicator {
    padding: 10px 15px;
    background: var(--bot-bubble);
    border-radius: 15px;
    align-self: flex-start;
    font-style: italic;
    font-size: 12px;
    color: #7f8c8d;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

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

/* Diálogos */
.chatbot-dialog {
    background: rgba(var(--primary-rgb), 0.1);
    backdrop-filter: blur(8px);
}

.dialog-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
}