﻿/* AI Chat Widget - Floating Widget for PlastAlex Login Page */
:root {
    --chat-primary: #4AB0FF;
    --chat-primary-dark: #2563eb;
    --chat-bg: rgba(255, 255, 255, 0.95);
    --chat-glass: rgba(255, 255, 255, 0.85);
    --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    --chat-radius: 16px;
    --chat-user-bg: #4AB0FF;
    --chat-user-color: #fff;
    --chat-ai-bg: rgba(245, 247, 250, 0.9);
}

/* Floating Button */
.ai-chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74, 176, 255, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-button:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 24px rgba(74, 176, 255, 0.6);
    background: var(--chat-primary-dark);
}

.ai-chat-button:active {
    transform: scale(0.95);
}

/* Widget Container */
.ai-chat-widget {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 540px;
    max-height: calc(100vh - 140px);
    background: var(--chat-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transform-origin: bottom right;
}

.ai-chat-widget.open {
    display: flex;
    animation: chatSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatSlideIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Header */
.ai-chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}

.ai-chat-header-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ai-chat-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255,255,255,0.35);
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}

/* Message Bubbles */
.ai-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgFadeIn 0.3s ease;
}

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

.ai-chat-msg.user {
    align-self: flex-end;
    background: var(--chat-user-bg);
    color: var(--chat-user-color);
    border-bottom-right-radius: 4px;
}

.ai-chat-msg.ai {
    align-self: flex-start;
    background: var(--chat-ai-bg);
    color: #212529;
    border: 1px solid rgba(0,0,0,0.06);
    border-bottom-left-radius: 4px;
}

.ai-chat-msg.ai.streaming {
    border-right: 3px solid var(--chat-primary);
}

/* Typing Indicator */
.ai-chat-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: var(--chat-ai-bg);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0,0,0,0.06);
}

.ai-chat-typing span {
    width: 7px;
    height: 7px;
    background: var(--chat-primary);
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.ai-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Welcome Message */
.ai-chat-welcome {
    text-align: center;
    padding: 24px 16px;
    color: #6c757d;
}

.ai-chat-welcome-icon {
    font-size: 48px;
    color: var(--chat-primary);
    margin-bottom: 12px;
    display: block;
}

.ai-chat-welcome h3 {
    font-size: 16px;
    color: #212529;
    margin: 0 0 6px 0;
    font-weight: 600;
}

.ai-chat-welcome p {
    font-size: 13px;
    margin: 0;
    line-height: 1.5;
}

/* Input Area */
.ai-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.5);
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    background: white;
    resize: none;
    font-family: inherit;
    max-height: 100px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(74, 176, 255, 0.15);
}

.ai-chat-input::placeholder {
    color: #adb5bd;
}

.ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-send:hover {
    background: var(--chat-primary-dark);
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Error Message */
.ai-chat-msg.error {
    align-self: center;
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
    font-size: 13px;
    text-align: center;
    max-width: 90%;
}

/* Responsive */
@media (max-width: 480px) {
    .ai-chat-widget {
        right: 12px;
        left: 12px;
        bottom: 88px;
        width: auto;
        height: calc(100vh - 120px);
        max-height: none;
    }

    .ai-chat-button {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
}
