/* ===================================
   AI CHAT WIDGET
   =================================== */

/* Chat Widget Container */
.ai-chat-widget {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* Chat Button */
.ai-chat-button {
    position: relative;
    width: 70px;
    height: 70px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(150px);
    animation: slideInFromBottom 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) 3s both;
}

@keyframes slideInFromBottom {
    0% {
        transform: translateY(150px);
        opacity: 0;
        visibility: hidden;
    }
    1% {
        visibility: visible;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
}

/* Chat Icon */
.ai-chat-icon {
    position: relative;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 8px 32px rgba(139, 92, 246, 0.4),
        0 4px 16px rgba(139, 92, 246, 0.3);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
}

.ai-chat-icon i {
    font-size: 2rem;
    color: #ffffff;
    animation: robotBounce 2s ease-in-out infinite;
}

@keyframes robotBounce {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-5px) rotate(-5deg);
    }
    75% {
        transform: translateY(-3px) rotate(5deg);
    }
}

.ai-chat-icon:hover {
    transform: scale(1.1);
    box-shadow: 
        0 12px 40px rgba(139, 92, 246, 0.5),
        0 6px 20px rgba(139, 92, 246, 0.4);
}

/* AI Pulse Effect */
.ai-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.4);
    animation: pulse 2s ease-out infinite;
}

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

/* Chat Bubble */
.ai-chat-bubble {
    position: absolute;
    bottom: 80px;
    left: 0;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    padding: 12px 20px;
    border-radius: 20px 20px 20px 4px;
    box-shadow: 
        0 8px 24px rgba(139, 92, 246, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.2),
        0 0 40px rgba(139, 92, 246, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    animation: bubbleBounce 3s ease-in-out infinite, bubbleFadeIn 0.6s ease-out 10.6s both;
    white-space: nowrap;
}

@keyframes bubbleFadeIn {
    0% {
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
    }
    1% {
        visibility: visible;
    }
    100% {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

@keyframes bubbleBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.ai-chat-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 12px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #6366f1;
}

.bubble-text {
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Chat Interface */
.ai-chat-interface {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 400px;
    max-width: calc(100vw - 60px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(139, 92, 246, 0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}

.ai-chat-interface.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

/* AI Badge */
.ai-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    position: relative;
    backdrop-filter: blur(10px);
}

.ai-badge i {
    font-size: 1.5rem;
    color: #ffffff;
    animation: brainPulse 2s ease-in-out infinite;
}

.ai-badge span {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: linear-gradient(135deg, #10b981, #06b6d4);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@keyframes brainPulse {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.3);
    }
}

.chat-header-info i {
    font-size: 2rem;
    color: #ffffff;
    animation: robotWave 2s ease-in-out infinite;
}

@keyframes robotWave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-10deg);
    }
    75% {
        transform: rotate(10deg);
    }
}

.chat-header-info h4 {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.chat-status {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.chat-status i {
    font-size: 0.5rem;
    color: #10b981;
    animation: statusBlink 2s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: statusBlink 2s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-close i {
    color: #ffffff;
    font-size: 1.2rem;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-primary);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.1);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Chat Message */
.chat-message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.message-avatar i {
    color: #ffffff;
    font-size: 1.2rem;
}

.message-content {
    flex: 1;
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 12px 12px 12px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-content p {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.user-message .message-content {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border-radius: 12px 12px 4px 12px;
}

.user-message .message-content p {
    color: #ffffff;
}

/* Chat Input */
.chat-input-container {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid rgba(139, 92, 246, 0.1);
    display: flex;
    gap: 12px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.chat-input {
    flex: 1;
    background: var(--bg-primary);
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

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

.chat-send {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.chat-send i {
    color: #ffffff;
    font-size: 1.1rem;
}

.chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.chat-send:active {
    transform: translateY(0);
}

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

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: rgba(139, 92, 246, 0.6);
    border-radius: 50%;
    animation: typingDot 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 typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Quick Suggestions */
.quick-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.suggestion-btn {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.15));
    border: 1.5px solid rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    white-space: nowrap;
}

.suggestion-btn:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(99, 102, 241, 0.3));
    border-color: rgba(139, 92, 246, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.suggestion-btn:active {
    transform: translateY(0);
}

/* Welcome Message Styling */
.welcome-message .message-content {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.1));
    border: 1.5px solid rgba(139, 92, 246, 0.2);
}

.welcome-message .message-avatar {
    background: linear-gradient(135deg, #10b981, #06b6d4);
}

.welcome-message .message-avatar i {
    animation: brainPulse 2s ease-in-out infinite;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-chat-widget {
        bottom: 20px;
        left: 20px;
    }

    .ai-chat-button {
        width: 60px;
        height: 60px;
    }

    .ai-chat-icon {
        width: 60px;
        height: 60px;
    }

    .ai-chat-icon i {
        font-size: 1.75rem;
    }

    .ai-chat-bubble {
        bottom: 70px;
        font-size: 0.85rem;
        padding: 10px 16px;
    }

    .ai-chat-interface {
        bottom: 20px;
        left: 20px;
        right: 20px;
        width: auto;
        max-width: none;
        height: 500px;
    }

    .chat-header {
        padding: 1.25rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .chat-input-container {
        padding: 1rem;
    }
}

/* Hide bubble when chat is open */
.ai-chat-interface.active ~ .ai-chat-button .ai-chat-bubble {
    opacity: 0;
    pointer-events: none;
}

/* Quick Actions (after welcome message) */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 1.5rem 1rem;
    animation: fadeInUp 0.5s ease-out 0.5s both;
}

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

.quick-action-btn {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    white-space: nowrap;
}

.quick-action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.quick-action-btn:active {
    transform: translateY(-1px);
}

/* Message Content Formatting */
.message-content strong {
    color: #8b5cf6;
    font-weight: 600;
}

.message-content ul {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.message-content li {
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
}

.message-content li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: #8b5cf6;
    font-weight: bold;
}

/* AI Mode Toggle */
.ai-mode-toggle {
    padding: 0 1.5rem 1rem;
    text-align: center;
    animation: fadeInUp 0.5s ease-out 0.8s both;
}

.ai-toggle-btn {
    background: linear-gradient(135deg, #10b981, #06b6d4);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ai-toggle-btn i {
    font-size: 1.1rem;
    animation: brainPulse 2s ease-in-out infinite;
}

.ai-toggle-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.6);
}

.ai-toggle-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.ai-toggle-desc {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}
