/* ================================================
   VocalGenix AI Assistant Widget
   Shared Floating AI — Cross-page Memory System
   ================================================ */

/* ── Floating Orb ── */
.vg-ai-orb {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
    box-shadow:
        0 4px 20px rgba(0,0,0,0.4),
        0 0 0 0 rgba(255,255,255,0.1);
    overflow: visible;
}

.vg-ai-orb::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid;
    opacity: 0.4;
    animation: orbRing 2s linear infinite;
}

.vg-ai-orb::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    animation: orbRingOuter 2s linear infinite reverse;
}

@keyframes orbRing      { to { transform: rotate(360deg); } }
@keyframes orbRingOuter { to { transform: rotate(360deg); } }

.vg-ai-orb:hover {
    transform: scale(1.12);
}

.vg-ai-orb.open {
    transform: scale(0.9) rotate(10deg);
}

/* Pulse animation */
.orb-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    animation: orbPulse 2.5s ease-out infinite;
}
@keyframes orbPulse {
    0%  { transform: scale(1); opacity: 0.5; }
    100%{ transform: scale(1.7); opacity: 0; }
}

/* Notification badge */
.orb-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #ff4444;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #060810;
    animation: badgePop 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes badgePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Chat Panel ── */
.vg-ai-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-height: 600px;
    z-index: 8999;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(10,12,22,0.97);
    backdrop-filter: blur(24px);
    box-shadow:
        0 24px 64px rgba(0,0,0,0.5),
        0 0 0 1px rgba(255,255,255,0.05) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.16,1,0.3,1);
}

.vg-ai-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Panel Header */
.aiw-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 1.2rem 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.aiw-persona-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    position: relative;
}

.aiw-persona-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #00ff88;
    border: 2px solid #0a0c16;
    animation: statusPulse 2s ease-in-out infinite;
}
@keyframes statusPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(0,255,136,0.4); }
    50%     { box-shadow: 0 0 0 4px rgba(0,255,136,0); }
}

.aiw-persona-info { flex: 1; }
.aiw-persona-name { font-size: 0.95rem; font-weight: 800; }
.aiw-persona-role { font-size: 0.72rem; color: rgba(255,255,255,0.4); }

.aiw-header-actions { display: flex; gap: 0.4rem; }
.aiw-hbtn {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.aiw-hbtn:hover { background: rgba(255,255,255,0.12); color: white; }
.aiw-hbtn.active { background: rgba(108,99,255,0.2); color: #a78bfa; border-color: rgba(108,99,255,0.3); }

/* Tab Bar */
.aiw-tabs {
    display: flex;
    padding: 0.4rem 0.8rem;
    gap: 0.3rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.aiw-tab {
    flex: 1;
    padding: 0.35rem 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: rgba(255,255,255,0.4);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-body, 'Outfit', sans-serif);
    text-align: center;
}
.aiw-tab:hover { color: white; background: rgba(255,255,255,0.04); }
.aiw-tab.active {
    color: white;
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.1);
}

/* Panel content areas */
.aiw-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }

.aiw-pane { display: none; flex: 1; flex-direction: column; min-height: 0; }
.aiw-pane.active { display: flex; }

/* ── CHAT TAB ── */
.aiw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    scroll-behavior: smooth;
}
.aiw-messages::-webkit-scrollbar { width: 3px; }
.aiw-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.aiw-msg {
    display: flex;
    gap: 0.6rem;
    animation: msgSlide 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes msgSlide { from { opacity:0; transform:translateY(8px); } }

.aiw-msg.user { flex-direction: row-reverse; }

.aiw-msg-avatar {
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    align-self: flex-end;
}

.aiw-msg-bubble {
    max-width: 78%;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.5;
    position: relative;
}

.aiw-msg.ai .aiw-msg-bubble {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-bottom-left-radius: 4px;
    color: rgba(255,255,255,0.9);
}

.aiw-msg.user .aiw-msg-bubble {
    background: linear-gradient(135deg, rgba(108,99,255,0.3), rgba(108,99,255,0.2));
    border: 1px solid rgba(108,99,255,0.3);
    border-bottom-right-radius: 4px;
    color: white;
}

.aiw-msg-time {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.25);
    margin-top: 0.2rem;
}

/* Handoff chip inside message */
.aiw-handoff-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: rgba(0,255,136,0.1);
    border: 1px solid rgba(0,255,136,0.25);
    border-radius: 20px;
    font-size: 0.7rem;
    color: #00ff88;
    cursor: pointer;
    margin-top: 0.4rem;
    transition: all 0.2s;
    font-weight: 600;
}
.aiw-handoff-chip:hover { background: rgba(0,255,136,0.2); }

/* Typing indicator */
.aiw-typing {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    width: fit-content;
    align-items: center;
}
.aiw-typing-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    animation: typingBounce 1.2s ease-in-out infinite;
}
.aiw-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.aiw-typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes typingBounce {
    0%,60%,100% { transform: translateY(0); }
    30%         { transform: translateY(-5px); background: rgba(255,255,255,0.8); }
}

/* Quick Prompts */
.aiw-quick-prompts {
    padding: 0.5rem 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}
.aiw-quick-chip {
    padding: 0.3rem 0.6rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.aiw-quick-chip:hover {
    background: rgba(255,255,255,0.09);
    color: white;
    border-color: rgba(255,255,255,0.18);
}

/* Input Area */
.aiw-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    align-items: flex-end;
}
.aiw-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 12px;
    color: white;
    font-size: 0.82rem;
    padding: 0.55rem 0.8rem;
    outline: none;
    resize: none;
    font-family: var(--font-body, 'Outfit', sans-serif);
    max-height: 80px;
    min-height: 36px;
    transition: border-color 0.2s;
    line-height: 1.4;
}
.aiw-input:focus { border-color: rgba(255,255,255,0.2); }
.aiw-input::placeholder { color: rgba(255,255,255,0.25); }

.aiw-send-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.aiw-send-btn:not([disabled]):hover { transform: scale(1.05); }
.aiw-send-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ── MEMORY TAB ── */
.aiw-memory-pane {
    overflow-y: auto;
    padding: 0.8rem 1rem;
}
.aiw-memory-pane::-webkit-scrollbar { width: 3px; }
.aiw-memory-pane::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.mem-section { margin-bottom: 1rem; }
.mem-section-title {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.3);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.mem-project-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 0.8rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}
.mem-field {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.mem-key {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}
.mem-val {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.85);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mem-val.empty { color: rgba(255,255,255,0.2); font-style: italic; font-weight: 400; }
.mem-val.full  { grid-column: 1/-1; white-space: normal; font-size: 0.73rem; max-height: 60px; overflow-y: auto; }

.mem-clear-btn {
    width: 100%;
    margin-top: 0.8rem;
    padding: 0.4rem;
    background: rgba(255,68,68,0.08);
    border: 1px solid rgba(255,68,68,0.15);
    border-radius: 8px;
    color: rgba(255,100,100,0.7);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
}
.mem-clear-btn:hover { background: rgba(255,68,68,0.15); color: #ff8888; }

/* Journey timeline */
.mem-journey { display: flex; flex-direction: column; gap: 0.4rem; }
.mem-journey-item {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    font-size: 0.75rem;
}
.mjl-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.15rem;
}
.mjl-text { color: rgba(255,255,255,0.6); line-height: 1.4; }
.mjl-page { font-weight: 700; }
.mjl-time { font-size: 0.62rem; color: rgba(255,255,255,0.25); margin-top: 0.1rem; }

/* ── HANDOFF TAB ── */
.aiw-handoff-pane { overflow-y: auto; padding: 0.8rem 1rem; }

.handoff-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.handoff-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 0.8rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}
.handoff-card:hover { transform: translateY(-2px); }
.handoff-card.current { opacity: 0.35; cursor: default; }

.hc-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.hc-name  { font-size: 0.78rem; font-weight: 700; }
.hc-persona { font-size: 0.65rem; color: rgba(255,255,255,0.4); }
.hc-send { font-size: 0.68rem; margin-top: 0.1rem; }

.handoff-recent { margin-top: 1rem; }
.ho-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    font-size: 0.72rem;
    margin-bottom: 0.3rem;
    color: rgba(255,255,255,0.6);
}
.ho-arrow { color: rgba(255,255,255,0.25); }
.ho-time  { font-size: 0.6rem; color: rgba(255,255,255,0.2); margin-left: auto; }

/* Editor-specific adjustment (panel above AI bar) */
.editor-body .vg-ai-orb  { bottom: 68px; }
.editor-body .vg-ai-panel { bottom: 136px; }

/* Responsive */
@media (max-width: 460px) {
    .vg-ai-panel { width: calc(100vw - 32px); right: 16px; bottom: 88px; }
    .vg-ai-orb   { right: 16px; }
}
