/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* FAB Button */
.chat-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gradient-1, #00ff88), var(--color-gradient-2, #00d4ff));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    outline: none;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 255, 136, 0.5);
}

.chat-fab:active {
    transform: scale(1.05);
}

.chat-fab-icon {
    width: 28px;
    height: 28px;
    color: #0a0a0a;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: absolute;
}

.chat-fab-icon--close {
    opacity: 0;
    transform: rotate(-90deg);
}

.chat-fab.active .chat-fab-icon--chat {
    opacity: 0;
    transform: rotate(90deg);
}

.chat-fab.active .chat-fab-icon--close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Pulse Animation */
.chat-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--color-accent, #00ff88);
    animation: pulse-ring 2s ease-out infinite;
    pointer-events: none;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.chat-fab.active .chat-fab-pulse {
    display: none;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: var(--color-surface, #111111);
    border: 1px solid var(--color-border, #222222);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--color-surface-elevated, #1a1a1a);
    border-bottom: 1px solid var(--color-border, #222222);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gradient-1, #00ff88), var(--color-gradient-2, #00d4ff));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar svg {
    width: 22px;
    height: 22px;
    color: #0a0a0a;
}

.chat-header-text h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--color-text, #ffffff);
}

.chat-header-text span {
    font-size: 0.8rem;
    color: var(--color-text-secondary, #a0a0a0);
}

.chat-close {
    background: none;
    border: none;
    color: var(--color-text-secondary, #a0a0a0);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close:hover {
    background: var(--color-surface, #111111);
    color: var(--color-text, #ffffff);
}

.chat-close svg {
    width: 20px;
    height: 20px;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-border, #222222);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary, #a0a0a0);
}

.chat-message {
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

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

.chat-message--user {
    align-self: flex-end;
}

.chat-message--assistant {
    align-self: flex-start;
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message--user .chat-message-content {
    background: linear-gradient(135deg, var(--color-gradient-1, #00ff88), var(--color-gradient-2, #00d4ff));
    color: #0a0a0a;
    border-bottom-right-radius: 4px;
}

.chat-message--assistant .chat-message-content {
    background: var(--color-surface-elevated, #1a1a1a);
    color: var(--color-text, #ffffff);
    border-bottom-left-radius: 4px;
}

.chat-message--error .chat-message-content {
    background: rgba(255, 80, 80, 0.15);
    border: 1px solid rgba(255, 80, 80, 0.3);
    color: #ff6b6b;
}

/* Typing Indicator */
.chat-typing .typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--color-text-secondary, #a0a0a0);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Input Container */
.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: var(--color-surface-elevated, #1a1a1a);
    border-top: 1px solid var(--color-border, #222222);
}

.chat-input-container input {
    flex: 1;
    background: var(--color-surface, #111111);
    border: 1px solid var(--color-border, #222222);
    border-radius: 24px;
    padding: 12px 20px;
    color: var(--color-text, #ffffff);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-container input:focus {
    border-color: var(--color-accent, #00ff88);
}

.chat-input-container input::placeholder {
    color: var(--color-text-muted, #666666);
}

.chat-input-container input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gradient-1, #00ff88), var(--color-gradient-2, #00d4ff));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.chat-send:hover:not(:disabled) {
    transform: scale(1.1);
}

.chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send svg {
    width: 20px;
    height: 20px;
    color: #0a0a0a;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100%;
    }

    .chat-fab {
        width: 56px;
        height: 56px;
    }

    .chat-fab-icon {
        width: 24px;
        height: 24px;
    }
}
