/**
 * AI Chat Widget v1.0
 * Modern floating chat interface
 */

/* Variables - will be overridden by JS */
:root {
    --ai-primary: #4F46E5;
    --ai-secondary: #7C3AED;
    --ai-text: #ffffff;
    --ai-chat-bg: #1a1a2e;
    --ai-user-bubble: #4F46E5;
    --ai-bot-bubble: #374151;
    --ai-border-radius: 16px;
    --ai-button-size: 60px;
}

/* Chat Button */
.ai-chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: var(--ai-button-size);
    height: var(--ai-button-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary) 0%, var(--ai-secondary) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    z-index: 999998;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(79, 70, 229, 0.5);
}

.ai-chat-button.left {
    right: auto;
    left: 24px;
}

.ai-chat-button.active {
    transform: rotate(180deg);
}

.ai-chat-button .pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid var(--ai-primary);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Chat Container */
.ai-chat-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: var(--ai-chat-bg);
    border-radius: var(--ai-border-radius);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-container.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.ai-chat-container.left {
    right: auto;
    left: 24px;
}

/* Chat Header */
.ai-chat-header {
    background: linear-gradient(135deg, var(--ai-primary) 0%, var(--ai-secondary) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.ai-chat-header-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ai-chat-header-info {
    flex: 1;
}

.ai-chat-header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.ai-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.ai-chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
}

.ai-chat-header-status .dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.ai-chat-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.3s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Message Bubbles */
.ai-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: message-in 0.3s ease;
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ai-message.bot .ai-message-avatar {
    background: linear-gradient(135deg, var(--ai-primary) 0%, var(--ai-secondary) 100%);
    color: white;
}

.ai-message.user .ai-message-avatar {
    background: var(--ai-user-bubble);
    color: white;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: white;
}

.ai-message.bot .ai-message-content {
    background: var(--ai-bot-bubble);
    border-bottom-left-radius: 4px;
}

.ai-message.user .ai-message-content {
    background: var(--ai-user-bubble);
    border-bottom-right-radius: 4px;
}

.ai-message-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    display: block;
}

/* Typing Indicator */
.ai-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
}

.ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Quick Actions */
.ai-quick-actions {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-quick-action {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-quick-action:hover {
    background: var(--ai-primary);
    border-color: var(--ai-primary);
}

/* Input Area */
.ai-chat-input-area {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 10px;
    align-items: center;
}

.ai-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 12px 18px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

.ai-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.ai-chat-input:focus {
    border-color: var(--ai-primary);
    background: rgba(255, 255, 255, 0.15);
}

.ai-chat-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--ai-primary) 0%, var(--ai-secondary) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s;
}

.ai-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Powered By */
.ai-powered-by {
    text-align: center;
    padding: 8px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.2);
}

.ai-powered-by a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-chat-container {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
    }

    .ai-chat-button {
        bottom: 16px;
        right: 16px;
    }

    .ai-chat-button.left {
        left: 16px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-chat-container {
        background: #0f0f1a;
    }
}

/* Animations */
.ai-fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.ai-slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
