/* ─── SpinZone AI Chatbot Widget ───────────────────────────────────── */

/* Floating Button */
.sz-chat-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    color: #fff;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(139, 92, 246, 0.4), 0 0 0 0 rgba(139, 92, 246, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: sz-fab-pulse 3s ease-in-out infinite;
}
.sz-chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 32px rgba(139, 92, 246, 0.6);
}
.sz-chat-fab.active {
    transform: rotate(45deg) scale(1);
    background: linear-gradient(135deg, #ef4444, #f97316);
    animation: none;
}
@keyframes sz-fab-pulse {
    0%, 100% { box-shadow: 0 4px 24px rgba(139, 92, 246, 0.4), 0 0 0 0 rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 4px 24px rgba(139, 92, 246, 0.4), 0 0 0 12px rgba(139, 92, 246, 0); }
}

/* Chat Panel */
.sz-chat-panel {
    position: fixed;
    bottom: 5.5rem;
    right: 1.5rem;
    z-index: 9999;
    width: 380px;
    max-height: 520px;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(139, 92, 246, 0.1);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.sz-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.sz-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(6, 182, 212, 0.08));
    border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}
.sz-chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.sz-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.sz-chat-header-info h4 {
    font-size: 0.88rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
    line-height: 1.2;
}
.sz-chat-header-info span {
    font-size: 0.68rem;
    color: #10b981;
    font-weight: 600;
}
.sz-chat-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: all 0.2s;
}
.sz-chat-close:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.08);
}

/* Messages Area */
.sz-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 280px;
    max-height: 340px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}
.sz-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.sz-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 4px;
}

/* Message Bubbles */
.sz-chat-msg {
    max-width: 85%;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    font-size: 0.84rem;
    line-height: 1.55;
    animation: sz-msg-in 0.3s ease-out;
}
.sz-chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sz-chat-msg.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}
.sz-chat-msg.ai .msg-source {
    display: inline-block;
    font-size: 0.6rem;
    color: #06b6d4;
    margin-top: 0.3rem;
    opacity: 0.7;
}
@keyframes sz-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Welcome Message */
.sz-chat-welcome {
    text-align: center;
    padding: 1.5rem 0.5rem;
}
.sz-chat-welcome-icon {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}
.sz-chat-welcome h5 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0 0 0.3rem;
}
.sz-chat-welcome p {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0 0 0.8rem;
    line-height: 1.5;
}
.sz-chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.sz-chat-suggestion {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #a78bfa;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}
.sz-chat-suggestion:hover {
    background: rgba(139, 92, 246, 0.18);
    border-color: rgba(139, 92, 246, 0.4);
    color: #c4b5fd;
}

/* Typing Indicator */
.sz-chat-typing {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 0.9rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 80px;
}
.sz-chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8b5cf6;
    animation: sz-typing 1.4s ease-in-out infinite;
}
.sz-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sz-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes sz-typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Input Area */
.sz-chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}
.sz-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.55rem 0.8rem;
    font-size: 0.84rem;
    color: #f1f5f9;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.sz-chat-input::placeholder {
    color: #475569;
}
.sz-chat-input:focus {
    border-color: rgba(139, 92, 246, 0.5);
}
.sz-chat-send {
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.sz-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.4);
}
.sz-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Rate Limit Banner */
.sz-chat-limit {
    padding: 0.65rem 0.9rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(139, 92, 246, 0.08));
    border-top: 1px solid rgba(245, 158, 11, 0.2);
    text-align: center;
}
.sz-chat-limit p {
    font-size: 0.72rem;
    color: #f59e0b;
    margin: 0 0 0.35rem;
    font-weight: 600;
}
.sz-chat-limit a {
    font-size: 0.72rem;
    color: #8b5cf6;
    font-weight: 700;
    text-decoration: none;
}
.sz-chat-limit a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
    .sz-chat-panel {
        width: calc(100vw - 1.5rem);
        right: 0.75rem;
        bottom: 5rem;
        max-height: 70vh;
        border-radius: 16px;
    }
    .sz-chat-fab {
        width: 52px;
        height: 52px;
        bottom: 1rem;
        right: 1rem;
        font-size: 1.3rem;
    }
}

/* Lucide bot SVG sizing inside chatbot UI */
.sz-chat-fab svg.lucide-bot { width: 28px; height: 28px; stroke-width: 2; }
.sz-chat-avatar svg.lucide-bot { width: 22px; height: 22px; stroke-width: 2; color: #fff; }
.sz-chat-welcome-icon svg.lucide-bot { width: 40px; height: 40px; stroke-width: 1.75; color: var(--primary, #8b5cf6); }
