/* ============================================
   RealVision AI Chat Widget — V4
   Cyber Dark Theme
   ============================================ */

.chat-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #a855f7, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 30px rgba(168, 85, 247, 0.5);
    transition: all 0.3s ease;
    animation: togglePulse 3s ease-in-out infinite;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 50px rgba(168, 85, 247, 0.7), 0 0 80px rgba(59, 130, 246, 0.2);
}

.chat-toggle--hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
}

@keyframes togglePulse {

    0%,
    100% {
        box-shadow: 0 4px 30px rgba(168, 85, 247, 0.5);
    }

    50% {
        box-shadow: 0 8px 60px rgba(168, 85, 247, 0.8), 0 0 100px rgba(59, 130, 246, 0.3);
    }
}

/* Widget */
.chat-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 10000;
    width: 420px;
    height: 560px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: rgba(11, 11, 15, 0.97);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(168, 85, 247, 0.25);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.7),
        0 0 60px rgba(168, 85, 247, 0.12);
    transform: scale(0) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-widget--open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.chat-widget__header {
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(59, 130, 246, 0.05));
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.chat-widget__avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #a855f7, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

.chat-widget__info {
    flex: 1;
}

.chat-widget__name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #f1f1f8;
}

.chat-widget__status {
    font-size: 0.75rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-widget__status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #22c55e;
    display: inline-block;
    animation: statusBlink 2s ease-in-out infinite;
}

@keyframes statusBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.chat-widget__close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-widget__close:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(168, 85, 247, 0.3);
}

.chat-widget__close svg {
    width: 16px;
    height: 16px;
    stroke: #888;
}

/* Messages */
.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.25) transparent;
}

.chat-widget__messages::-webkit-scrollbar {
    width: 3px;
}

.chat-widget__messages::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.3);
}

.chat-msg {
    display: flex;
    animation: msgIn 0.35s ease;
}

.chat-msg--user {
    justify-content: flex-end;
}

.chat-msg--assistant {
    justify-content: flex-start;
}

.chat-msg__bubble {
    max-width: 85%;
    padding: 14px 18px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-wrap: break-word;
}

.chat-msg--user .chat-msg__bubble {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: white;
}

.chat-msg--assistant .chat-msg__bubble {
    background: rgba(255, 255, 255, 0.03);
    color: #ddd;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing */
.chat-msg__typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 16px 20px;
}

.chat-msg__typing span {
    width: 6px;
    height: 6px;
    background: rgba(168, 85, 247, 0.5);
    animation: typing 1.2s ease-in-out infinite;
}

.chat-msg__typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-msg__typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.3;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Input */
.chat-widget__input {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    background: rgba(11, 11, 15, 0.7);
}

.chat-widget__input input {
    flex: 1;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #f1f1f8;
    font-size: 0.88rem;
    outline: none;
    transition: all 0.2s ease;
}

.chat-widget__input input::placeholder {
    color: #4a4a55;
}

.chat-widget__input input:focus {
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.03);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.08);
}

.chat-widget__send {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-widget__send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 24px rgba(168, 85, 247, 0.5);
}

.chat-widget__send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Mobile */
@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 8px;
        right: 8px;
    }

    .chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}