/* Widget de chat flotante (ayuda dentro de la app y apoyo en la venta).
   Usa las variables de color del tema activo (--accent, --surface, etc.)
   para verse igual en todas las páginas, con o sin sidebar. */

.rcc-chat { position: fixed; right: 20px; bottom: 20px; z-index: 9999; font-family: 'DM Sans', sans-serif; }

.rcc-chat-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent, #00d4ff);
    color: #000;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
    position: relative;
}

.rcc-chat-bubble:hover { transform: scale(1.06); }

.rcc-chat-bubble .rcc-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--danger, #ff4444);
    border: 2px solid var(--bg, #0a0e17);
    display: none;
}

.rcc-chat-bubble.has-unread .rcc-chat-badge { display: block; }

.rcc-chat-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: calc(100vh - 110px);
    background: var(--surface, #111827);
    border: 1px solid var(--border, #1e2d45);
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rcc-chat-panel[hidden] { display: none; }

.rcc-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    background: var(--surface2, #1a2235);
    border-bottom: 1px solid var(--border, #1e2d45);
    flex-shrink: 0;
}

.rcc-chat-title {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--text, #e2e8f0);
}

.rcc-chat-subtitle {
    font-size: 0.7rem;
    color: var(--muted, #64748b);
    margin-top: 3px;
}

.rcc-chat-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.rcc-chat-icon-btn {
    background: none;
    border: none;
    color: var(--muted, #64748b);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.rcc-chat-icon-btn:hover { color: var(--text, #e2e8f0); background: rgba(255, 255, 255, 0.06); }

.rcc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border, #1e2d45) transparent;
}

.rcc-chat-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: normal;
}

.rcc-chat-msg.user {
    align-self: flex-end;
    background: var(--accent, #00d4ff);
    color: #000;
    border-bottom-right-radius: 3px;
}

.rcc-chat-msg.model {
    align-self: flex-start;
    background: var(--surface2, #1a2235);
    color: var(--text, #e2e8f0);
    border: 1px solid var(--border, #1e2d45);
    border-bottom-left-radius: 3px;
}

.rcc-chat-msg.error {
    border-color: var(--danger, #ff4444);
    color: var(--danger, #ff4444);
}

.rcc-chat-msg strong { color: inherit; }

.rcc-chat-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    margin: 0 14px 6px;
}

.rcc-chat-typing[hidden] { display: none; }

.rcc-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted, #64748b);
    animation: rcc-typing-bounce 1.1s infinite ease-in-out;
}

.rcc-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.rcc-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

.rcc-chat-typing-texto {
    margin-left: 6px;
    font-size: 0.78rem;
    font-style: italic;
    color: var(--muted, #64748b);
}

@keyframes rcc-typing-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

.rcc-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border, #1e2d45);
    flex-shrink: 0;
}

.rcc-chat-input-row textarea {
    flex: 1;
    resize: none;
    background: var(--bg, #0a0e17);
    border: 1px solid var(--border, #1e2d45);
    color: var(--text, #e2e8f0);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 0.82rem;
    max-height: 90px;
    outline: none;
}

.rcc-chat-input-row textarea:focus { border-color: var(--accent, #00d4ff); }

.rcc-chat-send {
    background: var(--accent, #00d4ff);
    color: #000;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rcc-chat-send:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 480px) {
    .rcc-chat { right: 12px; bottom: 12px; }
    .rcc-chat-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        right: -8px;
    }
}

/* Derivar a una persona (13-10-2026): botón fijo bajo la conversación del chat de ayuda */
.rcc-chat-humano { padding: 6px 12px 0; text-align: center; }
.rcc-chat-humano button {
    background: transparent; border: 1px solid currentColor; border-radius: 14px; padding: 4px 12px;
    font: inherit; font-size: 0.8rem; color: inherit; opacity: 0.85; cursor: pointer;
}
.rcc-chat-humano button:hover { opacity: 1; }

/* Registro de conversaciones (14-10-2026): aviso de 180 días y 👍 / 👎 bajo cada respuesta */
.rcc-chat-aviso { font-size: 0.7rem; opacity: 0.7; padding: 4px 12px; text-align: center; }
.rcc-chat-valorar { display: flex; align-items: center; gap: 4px; margin: -4px 0 6px 6px; font-size: 0.72rem; opacity: 0.8; }
.rcc-chat-valorar button { background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: 0.85rem; padding: 0 5px; }
.rcc-chat-valorar button:hover:not(:disabled) { border-color: currentColor; }
.rcc-chat-valorar button:disabled { cursor: default; opacity: 0.4; }
.rcc-chat-valorar button.elegido { opacity: 1; border-color: currentColor; }

