/* ============================================================
   ROVI CHATBOT — ROVICK Technologies
   ============================================================ */

/* ── CSS Variables ── */
:root {
    --chat-primary:      #4F6EF7;
    --chat-gradient:     linear-gradient(135deg, #4F6EF7 0%, #7C3AED 100%);
    --chat-bg:           #0D1117;
    --chat-surface:      #161B26;
    --chat-surface2:     #1E2536;
    --chat-border:       rgba(255,255,255,0.07);
    --chat-text:         #E2E8F0;
    --chat-text-muted:   #64748B;
    --chat-bubble-user:  linear-gradient(135deg, #4F6EF7 0%, #6D28D9 100%);
    --chat-bubble-bot:   #1E2536;
    --chat-radius:       18px;
    --chat-width:        380px;
    --chat-height:       540px;
    --chat-z:            9999;
}

/* ── Floating Trigger Button ── */
.rovi-trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--chat-gradient);
    border: none;
    cursor: pointer;
    z-index: var(--chat-z);
    box-shadow: 0 8px 32px rgba(79,110,247,0.45),
                0 2px 8px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.3s ease;
    outline: none;
}

.rovi-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(79,110,247,0.55),
                0 4px 12px rgba(0,0,0,0.3);
}

.rovi-trigger:active { transform: scale(0.95); }

/* Pulse ring animation */
.rovi-trigger::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(79,110,247,0.4);
    animation: roviPulse 2.5s ease-out infinite;
}

@keyframes roviPulse {
    0%   { transform: scale(1);   opacity: 0.8; }
    70%  { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* Icon swap — chat icon → X icon */
.rovi-trigger .rovi-icon-chat,
.rovi-trigger .rovi-icon-close {
    position: absolute;
    font-size: 1.3rem;
    color: #fff;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.rovi-trigger .rovi-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

.rovi-trigger.open .rovi-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.rovi-trigger.open .rovi-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Notification dot */
.rovi-notif {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #EF4444;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: roviNotifBounce 1s ease infinite alternate;
    transition: opacity 0.3s ease;
}

@keyframes roviNotifBounce {
    from { transform: scale(1); }
    to   { transform: scale(1.2); }
}

.rovi-notif.hidden { opacity: 0; pointer-events: none; }

/* ── Chat Panel ── */
.rovi-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    border: 1px solid var(--chat-border);
    box-shadow: 0 24px 80px rgba(0,0,0,0.5),
                0 8px 24px rgba(79,110,247,0.15);
    z-index: calc(var(--chat-z) - 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s cubic-bezier(0.4,0,0.2,1),
                visibility 0.3s cubic-bezier(0.4,0,0.2,1),
                transform 0.3s cubic-bezier(0.34,1.2,0.64,1);
}

.rovi-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ── Panel Header ── */
.rovi-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: var(--chat-surface);
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.rovi-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    position: relative;
}

/* Online indicator */
.rovi-header-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #22C55E;
    border-radius: 50%;
    border: 2px solid var(--chat-surface);
}

.rovi-header-info { flex: 1; min-width: 0; }

.rovi-header-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--chat-text);
    letter-spacing: -0.01em;
    display: block;
}

.rovi-header-status {
    font-size: 0.72rem;
    color: #22C55E;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.rovi-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #22C55E;
    border-radius: 50%;
    display: inline-block;
    animation: roviStatusPulse 2s ease infinite;
}

@keyframes roviStatusPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.rovi-header-actions { display: flex; gap: 6px; }

.rovi-header-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--chat-border);
    color: var(--chat-text-muted);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rovi-header-btn:hover {
    background: rgba(255,255,255,0.06);
    color: var(--chat-text);
    border-color: rgba(255,255,255,0.15);
}

/* ── Messages Area ── */
.rovi-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.rovi-messages::-webkit-scrollbar { width: 4px; }
.rovi-messages::-webkit-scrollbar-track { background: transparent; }
.rovi-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Message Bubbles ── */
.rovi-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: roviFadeUp 0.3s cubic-bezier(0.4,0,0.2,1) both;
}

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

/* Bot message — left aligned */
.rovi-msg.bot { align-self: flex-start; max-width: 88%; }

.rovi-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--chat-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #fff;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.rovi-msg.bot .rovi-bubble {
    background: var(--chat-bubble-bot);
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
    border-radius: 18px 18px 18px 4px;
    padding: 11px 14px;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* User message — right aligned */
.rovi-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 82%;
}

.rovi-msg.user .rovi-bubble {
    background: var(--chat-bubble-user);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    padding: 11px 14px;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Links inside bot messages */
.rovi-bubble a {
    color: #a5b4fc;
    text-decoration: underline;
}

/* ── Typing Indicator ── */
.rovi-typing {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
    animation: roviFadeUp 0.3s ease both;
}

.rovi-typing-dots {
    background: var(--chat-bubble-bot);
    border: 1px solid var(--chat-border);
    border-radius: 18px 18px 18px 4px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.rovi-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748B;
    display: block;
    animation: roviTypingBounce 1.2s ease infinite;
}

.rovi-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.rovi-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes roviTypingBounce {
    0%, 60%, 100% { transform: translateY(0);    background: #64748B; }
    30%            { transform: translateY(-6px); background: #a5b4fc; }
}

/* ── Quick Suggestions ── */
.rovi-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 14px;
    flex-shrink: 0;
}

.rovi-suggestion {
    background: var(--chat-surface2);
    border: 1px solid var(--chat-border);
    border-radius: 100px;
    color: #a5b4fc;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rovi-suggestion:hover {
    background: rgba(79,110,247,0.2);
    border-color: rgba(79,110,247,0.4);
    color: #c7d2fe;
    transform: translateY(-1px);
}

/* ── Input Area ── */
.rovi-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px 16px;
    background: var(--chat-surface);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.rovi-input {
    flex: 1;
    background: var(--chat-surface2);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--chat-text);
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.5;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rovi-input::placeholder { color: var(--chat-text-muted); }

.rovi-input:focus {
    border-color: rgba(79,110,247,0.5);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.1);
}

.rovi-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--chat-gradient);
    border: none;
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 14px rgba(79,110,247,0.4);
}

.rovi-send:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 20px rgba(79,110,247,0.5);
}

.rovi-send:active  { transform: scale(0.95); }
.rovi-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Footer branding ── */
.rovi-footer {
    text-align: center;
    font-size: 0.65rem;
    color: #334155;
    padding: 0 14px 10px;
    flex-shrink: 0;
}

.rovi-footer span { color: #475569; font-weight: 600; }

/* ── Welcome card (first message) ── */
.rovi-welcome {
    background: linear-gradient(135deg, rgba(79,110,247,0.12), rgba(124,58,237,0.08));
    border: 1px solid rgba(79,110,247,0.2);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
}

.rovi-welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--chat-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.3rem;
    color: #fff;
}

.rovi-welcome h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--chat-text);
    margin-bottom: 6px;
}

.rovi-welcome p {
    font-size: 0.78rem;
    color: #94A3B8;
    line-height: 1.5;
    margin: 0;
}

/* ── Error message ── */
.rovi-error {
    font-size: 0.78rem;
    color: #FCA5A5;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 10px;
    padding: 8px 12px;
    text-align: center;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
    :root {
        --chat-width:  calc(100vw - 24px);
        --chat-height: 72vh;
    }

    .rovi-panel {
        bottom: 90px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    .rovi-trigger {
        bottom: 20px;
        right: 20px;
    }
}
