/* ==========================================================================
   Vori — Widget d'assistent digital flotant (copiat de voradata.cat)
   ========================================================================== */

.vori-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

.vori-widget * {
    pointer-events: auto;
}

/* FAB */
.vori-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-main);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(244, 142, 36, 0.4), 0 0 16px rgba(244, 142, 36, 0.2);
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, background-color 0.3s ease;
}

.vori-fab:hover {
    transform: scale(1.1) rotate(5deg);
    background: var(--accent-studio);
    box-shadow: 0 12px 40px rgba(244, 142, 36, 0.5), 0 0 24px rgba(244, 142, 36, 0.3);
}

.vori-fab:active {
    transform: scale(0.95);
}

.vori-fab-icon {
    width: 32px;
    height: 32px;
    color: #ffffff;
}

/* Indicador en línia */
.vori-online-status {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #27c93f;
    border: 2px solid var(--accent-main);
    border-radius: 50%;
    animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
    0% { box-shadow: 0 0 0 0 rgba(39, 201, 63, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(39, 201, 63, 0); }
    100% { box-shadow: 0 0 0 0 rgba(39, 201, 63, 0); }
}

/* Bombolla de benvinguda */
.vori-welcome-bubble {
    position: absolute;
    bottom: 75px;
    right: 5px;
    background: var(--bg-main);
    color: var(--text-main);
    border: 1.5px solid var(--accent-main);
    padding: 0.6rem 1.2rem;
    border-radius: 16px 16px 2px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
    animation: float-bubble 4s ease-in-out infinite;
    z-index: 1000;
}

.vori-welcome-bubble.fade-out {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

@keyframes float-bubble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Finestra de xat */
.vori-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 480px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1.5px solid rgba(244, 142, 36, 0.25);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(244, 142, 36, 0.1);

    opacity: 0;
    transform: scale(0.85) translateY(20px);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.vori-chat-window.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Capçalera */
.vori-chat-header {
    background: rgba(244, 142, 36, 0.08);
    border-bottom: 1.5px solid rgba(244, 142, 36, 0.15);
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vori-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vori-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(244, 142, 36, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.vori-chat-avatar svg {
    width: 24px;
    height: 24px;
}

.vori-chat-titles h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}

.vori-chat-titles span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.vori-chat-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.vori-chat-close-btn:hover {
    color: var(--accent-main);
}

/* Missatges */
.vori-chat-messages {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.vori-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.vori-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.vori-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(244, 142, 36, 0.2);
    border-radius: 10px;
}

.vori-message {
    display: flex;
    max-width: 85%;
    animation: message-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: left bottom;
}

.vori-message.vori-bot {
    align-self: flex-start;
}

.vori-message.vori-user {
    align-self: flex-end;
    transform-origin: right bottom;
}

.vori-message-content {
    padding: 0.8rem 1rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.vori-bot .vori-message-content {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.vori-user .vori-message-content {
    background: var(--accent-main);
    color: #ffffff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 4px 12px rgba(244, 142, 36, 0.25);
}

.vori-message-content strong {
    font-weight: 700;
}

/* Xips de suggeriments */
.vori-chat-suggestions {
    padding: 0 1.2rem 0.8rem 1.2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vori-suggestion-chip {
    background: rgba(244, 142, 36, 0.05);
    border: 1px solid rgba(244, 142, 36, 0.25);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-body);
}

.vori-suggestion-chip:hover {
    background: var(--accent-main);
    color: #ffffff;
    border-color: var(--accent-main);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(244, 142, 36, 0.15);
}

/* Entrada */
.vori-chat-input-area {
    padding: 1rem 1.2rem;
    border-top: 1.5px solid rgba(244, 142, 36, 0.15);
    background: rgba(10, 15, 30, 0.95);
    display: flex;
    align-items: center;
    gap: 10px;
}

.vori-chat-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: 25px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    font-family: var(--font-body);
}

.vori-chat-input-area input:focus {
    border-color: var(--accent-main);
    background: rgba(255, 255, 255, 0.05);
}

.vori-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-main);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.3s ease;
    flex-shrink: 0;
}

.vori-chat-send-btn:hover {
    background: var(--accent-studio);
    transform: scale(1.05);
}

/* Indicador d'escriptura (reutilitza .typing-indicator d'app.css) */

@media (max-width: 480px) {
    .vori-widget {
        bottom: 1rem;
        right: 1rem;
    }

    .vori-chat-window {
        width: calc(100vw - 2rem);
        height: 420px;
        right: 0;
        bottom: 70px;
    }
}