/* AI Chat Widget */
.ai-chat {
    position: fixed;
    bottom: 120px;
    right: 2rem;
    width: 420px;
    height: 520px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(25px);
    border-radius: 24px;
    display: none;
    flex-direction: column;
    z-index: 2000;
    border: 1px solid rgba(74, 144, 226, 0.2);
    box-shadow: 0 30px 80px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: slideInUp 0.4s ease;
}

.ai-chat.active {
    display: flex;
}

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

.chat-header {
    background: var(--gradient);
    color: white;
    padding: 1.5rem 1.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.chat-icon {
    font-size: 1.5rem;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

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

.close-chat:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(248,251,255,1) 100%);
}

.message {
    margin-bottom: 1.2rem;
    padding: 1rem 1.4rem;
    border-radius: 20px;
    max-width: 85%;
    word-wrap: break-word;
    animation: messageSlide 0.4s ease;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

.message.user {
    background: linear-gradient(135deg, var(--primary-blue), #357ABD);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 6px;
}

.message.ai {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    color: var(--text-dark);
    border: 1px solid rgba(74, 144, 226, 0.2);
    margin-right: auto;
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.message.loading {
    animation: bubblePulse 1.5s infinite ease-in-out;
}

@keyframes bubblePulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

.welcome-message {
    background: rgba(74, 144, 226, 0.08);
    border-left: 4px solid var(--primary-blue);
    text-align: left;
}

.chat-input-container {
    padding: 1.5rem;
    border-top: 1px solid rgba(74, 144, 226, 0.2);
    display: flex;
    gap: 1rem;
    background: white;
}

#chatInput {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid rgba(74, 144, 226, 0.2);
    border-radius: 25px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

#chatInput:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

#sendBtn {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

#sendBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    text-align: center;
    color: white;
}

.logo-spin {
    font-size: 4rem;
    display: block;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Chat */
@media (max-width: 768px) {
    .ai-chat {
        width: calc(100% - 2rem);
        right: 1rem;
        left: 1rem;
        bottom: 20px;
        height: calc(100vh - 40px);
        border-radius: 20px;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .chat-input-container {
        padding: 1rem;
    }
}
