/* static/css/rebeca.css */

/* Variables de Paleta Futurista */
:root {
    --rebeca-bg-main: #0a0a1a;
    --rebeca-bg-header: #0d0d2b;
    --rebeca-accent-primary: #00d4ff; /* Cian eléctrico */
    --rebeca-accent-secondary: #7b2ff7; /* Púrpura */
    --rebeca-text-primary: #e0e0ff;
    --rebeca-text-secondary: #8888aa;
    --rebeca-bg-input: #13132a;
    --rebeca-bubble-rebeca: #13132a;
}

/* ------------------------------------- */
/* Botón Flotante (Toggle) */
/* ------------------------------------- */
#rebeca-toggle {
    position: fixed;
    bottom: 30px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at top left, var(--rebeca-accent-secondary), var(--rebeca-accent-primary));
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4); /* Glow cian suave */
    cursor: pointer;
    z-index: 9998;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease;
    animation: rebeca-pulse 2s infinite;
}

#rebeca-toggle:hover {
    transform: scale(1.1);
}

#rebeca-toggle img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
}

@keyframes rebeca-pulse {
    0% { transform: scale(1); box-shadow: 0 0 15px rgba(0, 212, 255, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 25px rgba(0, 212, 255, 0.7); }
    100% { transform: scale(1); box-shadow: 0 0 15px rgba(0, 212, 255, 0.4); }
}

/* ------------------------------------- */
/* Panel Principal de Chat */
/* ------------------------------------- */
#rebeca-panel {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 520px;
    max-width: calc(100vw - 40px); /* Responsive en móviles */
    max-height: calc(100vh - 120px);
    background-color: var(--rebeca-bg-main);
    border-radius: 16px;
    border: 1px solid rgba(0, 212, 255, 0.2);
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.13), 0 20px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Outfit', sans-serif;
}

/* Animación de apertura */
#rebeca-panel:not(.hidden) {
    animation: rebeca-slideUp 0.3s ease forwards;
}

#rebeca-panel.hidden {
    display: none !important;
}

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

/* ------------------------------------- */
/* Header del Panel */
/* ------------------------------------- */
#rebeca-header {
    height: 70px;
    background-color: var(--rebeca-bg-header);
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: relative;
    flex-shrink: 0;
}

.rebeca-avatar-small {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 12px;
}

.rebeca-header-info {
    display: flex;
    flex-direction: column;
}

.rebeca-name {
    color: var(--rebeca-accent-primary);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.rebeca-subtitle {
    color: var(--rebeca-text-secondary);
    font-size: 11px;
}

.rebeca-status-dot {
    width: 8px;
    height: 8px;
    background-color: #00ff66;
    border-radius: 50%;
    margin-left: 8px;
    margin-top: -15px; /* Alineado cerca del nombre */
    box-shadow: 0 0 8px #00ff66;
    animation: rebeca-statusPulse 2s infinite;
}

@keyframes rebeca-statusPulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

#rebeca-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--rebeca-text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
    padding: 5px;
}

#rebeca-close:hover {
    color: var(--rebeca-text-primary);
}

/* ------------------------------------- */
/* Área de Mensajes */
/* ------------------------------------- */
#rebeca-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.2) transparent;
}

#rebeca-messages::-webkit-scrollbar {
    width: 6px;
}
#rebeca-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 212, 255, 0.2);
    border-radius: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    animation: rebeca-fadeInUp 0.2s ease forwards;
    word-wrap: break-word;
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--rebeca-accent-secondary), var(--rebeca-accent-primary));
    color: #ffffff !important;
    border-bottom-right-radius: 4px;
}

.rebeca-message {
    align-self: flex-start;
    background-color: var(--rebeca-bubble-rebeca);
    color: var(--rebeca-text-primary);
    border: 1px solid rgba(0, 212, 255, 0.13);
    border-bottom-left-radius: 4px;
}

/* Interpretar hipervínculos de Rebeca */
.rebeca-message a {
    color: var(--rebeca-accent-primary);
    text-decoration: none;
    font-weight: 600;
}
.rebeca-message a:hover {
    text-decoration: underline;
}

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

/* ------------------------------------- */
/* Indicador de Escribiendo */
/* ------------------------------------- */
#rebeca-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    margin-bottom: 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--rebeca-accent-primary);
    border-radius: 50%;
    animation: rebeca-bounce 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; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

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

/* ------------------------------------- */
/* Área de Input */
/* ------------------------------------- */
#rebeca-input-area {
    padding: 12px;
    border-top: 1px solid rgba(0, 212, 255, 0.13);
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--rebeca-bg-main);
    flex-shrink: 0;
}

#rebeca-input {
    flex-grow: 1;
    background-color: var(--rebeca-bg-input);
    border: 1px solid rgba(0, 212, 255, 0.2);
    color: #ffffff !important;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
}

#rebeca-input::placeholder {
    color: var(--rebeca-text-secondary);
}

#rebeca-input:focus {
    border-color: var(--rebeca-accent-primary);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

#rebeca-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--rebeca-accent-secondary), var(--rebeca-accent-primary));
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

#rebeca-send:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.4);
}

/* Icono flecha de envio simplificada en CSS si no usamos SVG inline aquí pero un caracter o icono
   En JS usaremos un content: "→" o SVG, de momento pondremos color text. */
#rebeca-send::before {
    content: "\2192"; /* Right arrow → */
    font-size: 18px;
    font-weight: bold;
}

/* ------------------------------------- */
/* Burbuja de Atención (Greeting) */
/* ------------------------------------- */
.rebeca-attention-bubble {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background-color: var(--rebeca-bg-main);
    border: 1px solid rgba(0, 212, 255, 0.4);
    color: var(--rebeca-text-primary);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    z-index: 2147483647;
}

.rebeca-attention-bubble.visible {
    opacity: 1;
}

/* Flecha apuntando abajo */
.rebeca-attention-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    width: 10px;
    height: 10px;
    background-color: var(--rebeca-bg-main);
    border-right: 1px solid rgba(0, 212, 255, 0.4);
    border-bottom: 1px solid rgba(0, 212, 255, 0.4);
    transform: rotate(45deg);
}
