/* =========================================
   DBRECOVER AI Assistant - Chat Widget
   ========================================= */

/* Chat Toggle Button */
.chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(245, 158, 11, 0.5);
}

.chat-toggle svg {
    width: 28px;
    height: 28px;
    color: var(--color-bg-primary);
    transition: transform 0.3s ease;
}

.chat-toggle.active svg {
    transform: rotate(90deg);
}

/* Chat notification badge */
.chat-toggle::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: var(--color-success);
    border-radius: 50%;
    border: 2px solid var(--color-bg-primary);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

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

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--color-bg-tertiary);
    border-bottom: 1px solid var(--color-border);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar svg {
    width: 22px;
    height: 22px;
    color: var(--color-bg-primary);
}

.chat-title {
    flex: 1;
}

.chat-title h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 2px 0;
}

.chat-title span {
    font-size: 0.75rem;
    color: var(--color-success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-title span::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--color-success);
    border-radius: 50%;
}

.chat-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.chat-close:hover {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
}

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

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    scroll-behavior: smooth;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Message Bubbles */
.chat-message {
    display: flex;
    gap: var(--space-sm);
    max-width: 85%;
    animation: messageSlide 0.3s ease forwards;
}

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

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

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

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message.bot .message-avatar {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
}

.chat-message.user .message-avatar {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
}

.message-avatar svg {
    width: 14px;
    height: 14px;
}

.chat-message.bot .message-avatar svg {
    color: var(--color-bg-primary);
}

.chat-message.user .message-avatar svg {
    color: var(--color-text-muted);
}

.message-content {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    line-height: 1.6;
}

.chat-message.bot .message-content {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-message.user .message-content {
    background: var(--color-accent);
    color: var(--color-bg-primary);
    border-bottom-right-radius: var(--radius-sm);
}

/* Message content formatting */
.message-content a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-message.bot .message-content a {
    color: var(--color-accent);
}

.message-content code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 4px;
    border-radius: 3px;
}

.message-content strong {
    font-weight: 600;
    color: var(--color-text-primary);
}

.chat-message.user .message-content strong {
    color: inherit;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--color-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Quick Actions */
.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: 0 var(--space-lg) var(--space-md);
}

.quick-action {
    padding: 6px 12px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-action:hover {
    background: var(--color-bg-card);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Chat Input */
.chat-input-container {
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg-tertiary);
    border-top: 1px solid var(--color-border);
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: var(--color-accent);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text-primary);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    padding: var(--space-sm);
    resize: none;
    max-height: 100px;
}

.chat-input::placeholder {
    color: var(--color-text-muted);
}

.chat-send {
    width: 36px;
    height: 36px;
    background: var(--color-accent);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send:hover:not(:disabled) {
    background: var(--color-accent-light);
    transform: scale(1.05);
}

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

.chat-send svg {
    width: 18px;
    height: 18px;
}

/* Powered by notice */
.chat-powered {
    text-align: center;
    padding: var(--space-xs) var(--space-lg) var(--space-sm);
    font-size: 0.625rem;
    color: var(--color-text-muted);
    background: var(--color-bg-tertiary);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}

/* Language-specific styling */
.chat-lang-switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--color-bg-primary);
    border-radius: var(--radius-sm);
    margin-left: auto;
}

.chat-lang-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.chat-lang-btn.active {
    background: var(--color-accent);
    color: var(--color-bg-primary);
}

.chat-lang-btn:hover:not(.active) {
    color: var(--color-text-primary);
}

