/* ===== BRAINSTORMERS CHATBOT WIDGET ===== */

/* Floating Button */
.chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b3dff 0%, #6d28d9 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(139, 61, 255, 0.35);
    transition: transform 0.25s cubic-bezier(.4,0,.2,1), box-shadow 0.25s ease;
}
.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 32px rgba(139, 61, 255, 0.5);
}
.chat-fab svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    transition: transform 0.3s ease;
}
.chat-fab.open svg {
    transform: rotate(90deg);
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9998;
    width: 380px;
    max-height: 520px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(.4,0,.2,1), transform 0.3s cubic-bezier(.4,0,.2,1);

    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}
.chat-window.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Dark mode */
.dark .chat-window {
    background: rgba(24, 24, 27, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
}

/* Header */
.chat-header {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.dark .chat-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b3dff 0%, #6d28d9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-header-avatar svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}
.chat-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #18181b;
    letter-spacing: -0.01em;
}
.dark .chat-header-info h4 {
    color: #fafafa;
}
.chat-header-info p {
    margin: 2px 0 0;
    font-size: 11px;
    color: #a1a1aa;
    font-weight: 500;
}
.chat-header-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #a1a1aa;
    transition: color 0.2s;
}
.chat-header-close:hover {
    color: #18181b;
}
.dark .chat-header-close:hover {
    color: #fafafa;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 280px;
    max-height: 340px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

.chat-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgIn 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot {
    align-self: flex-start;
    background: #f4f4f5;
    color: #27272a;
    border-bottom-left-radius: 4px;
}
.dark .chat-msg.bot {
    background: rgba(255, 255, 255, 0.08);
    color: #e4e4e7;
}

.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #8b3dff 0%, #6d28d9 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}
.chat-typing span {
    width: 7px;
    height: 7px;
    background: #a1a1aa;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input */
.chat-input-wrap {
    padding: 12px 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 8px;
    align-items: center;
}
.dark .chat-input-wrap {
    border-top-color: rgba(255, 255, 255, 0.06);
}
.chat-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    background: transparent;
    color: #18181b;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    resize: none;
}
.chat-input::placeholder {
    color: #a1a1aa;
}
.chat-input:focus {
    border-color: #8b3dff;
}
.dark .chat-input {
    color: #fafafa;
    border-color: rgba(255, 255, 255, 0.12);
}
.dark .chat-input:focus {
    border-color: #8b3dff;
}
.chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #8b3dff 0%, #6d28d9 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
}
.chat-send:hover {
    transform: scale(1.06);
}
.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}
.chat-send svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 88px;
        max-height: 70vh;
    }
    .chat-fab {
        bottom: 20px;
        right: 16px;
    }
}
