/* chat-widget/css/widget.css */

:root {
    --chat-primary: #2c3e50; 
    --chat-accent: #3498db;  
    --chat-bg: #f4f7f6;
    --chat-width: 360px;
    /* Ajuste de posición: 95px desde la derecha para esquivar el botón 'Top' */
    --chat-right-pos: 95px; 
}

/* --- Botón Flotante (Launcher) --- */
.chat-launcher {
    position: fixed;
    bottom: 20px;
    right: var(--chat-right-pos); /* Posición ajustada */
    width: 60px;
    height: 60px;
    background: var(--chat-accent);
    color: white;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s ease;
}

.chat-launcher:hover { transform: scale(1.1); }
.chat-launcher .fa-times { display: none; }
.chat-launcher.active { background: var(--chat-primary); }
.chat-launcher.active .fa-comments { display: none; }
.chat-launcher.active .fa-times { display: block; }

/* Badge de notificación */
.chat-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    opacity: 0;
    transition: opacity 0.3s;
}
.chat-badge.visible { opacity: 1; }

/* --- Ventana del Chat --- */
.chat-window {
    position: fixed;
    bottom: 90px;
    right: var(--chat-right-pos); /* Alineado con el botón */
    width: var(--chat-width);
    height: 500px;
    max-height: 75vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    overflow: hidden;
}

.chat-window.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.cw-header {
    background: var(--chat-primary);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.cw-header h4 { margin: 0; font-size: 16px; font-weight: 600; color: white; }
.cw-header small { color: #bdc3c7; font-size: 11px; display: block; }

/* Cuerpo */
.cw-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Footer (Input) */
.cw-footer {
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: center;
}
.cw-footer input {
    border-radius: 20px;
    font-size: 13px;
    padding-left: 15px;
    height: 40px;
}
.cw-footer button {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Burbujas */
.msg-row { display: flex; width: 100%; }
.msg-row.user { justify-content: flex-end; }
.msg-row.bot { justify-content: flex-start; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 13px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.msg-row.bot .msg-bubble { background: white; border-top-left-radius: 2px; color: #333; }
.msg-row.user .msg-bubble { background: #d1ecf1; color: #0c5460; border-top-right-radius: 2px; }

/* Tablas y Gráficas */
.chat-table-container {
    margin-top: 8px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    background: white;
}
.chat-table { margin-bottom: 0 !important; font-size: 10px; }
.chat-table th { background: #f8f9fa; color: #444; }

.chat-chart-container {
    margin-top: 8px;
    background: white;
    border-radius: 8px;
    padding: 5px;
    border: 1px solid #eee;
    height: 220px;
    width: 100%;
}
.chat-echart { width: 100%; height: 100%; }

/* Markdown */
.markdown-body p { margin-bottom: 5px; }
.markdown-body ul { padding-left: 20px; margin-bottom: 5px; }

/* Responsive Móvil */
@media (max-width: 450px) {
    .chat-window { 
        width: 90%; 
        right: 5%; /* En móvil centramos más la ventana */
        bottom: 90px; 
        height: 60vh;
    }
    /* El botón se mantiene a la izquierda del Top button incluso en móvil */
    .chat-launcher {
        right: 85px; 
    }
}