/* AI Assistant - Fully Responsive with Better Message Design */
.ai-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: all 0.3s ease;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
}

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

.assistant-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    backdrop-filter: blur(10px);
}

.assistant-avatar i {
    animation: robotPulse 2s infinite;
}

@keyframes robotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.assistant-details h4 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.status {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 400;
}

.status.online::before {
    content: "●";
    color: #4ade80;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.minimize-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    scroll-behavior: smooth;
    scroll-padding-bottom: 20px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

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

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.assistant-message .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
}

.message-content {
    background: white;
    padding: 14px 18px;
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #f1f5f9;
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-height: 300px;
    overflow-y: auto;
}

.assistant-message .message-content {
    background: linear-gradient(135deg, #f8fafc, #ffffff);
    border-left: 3px solid #667eea;
}

.user-message .message-content {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    border: none;
}

.message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    font-weight: 400;
    letter-spacing: -0.1px;
}

.assistant-message .message-content p {
    color: #374151;
}

.user-message .message-content p {
    color: white;
}

/* Message formatting */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 12px 0;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { 
        transform: translateY(0);
        opacity: 0.4;
    }
    30% { 
        transform: translateY(-8px);
        opacity: 1;
    }
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #f1f5f9;
    border-radius: 0 0 20px 20px;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

#chatInput {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    background: #f8fafc;
}

#chatInput:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chatInput::placeholder {
    color: #9ca3af;
}

.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
    transform: scale(0.95);
}

.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-btn {
    padding: 8px 14px;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: #64748b;
}

.quick-btn:hover {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

.quick-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none;
    border-color: #d1d5db;
}

.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
    transition: all 0.3s;
    z-index: 999;
}

.chat-toggle-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
}

.chat-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-chat-widget {
        width: 300px;
        height: 400px;
        bottom: 90px;
        right: 10px;
        border-radius: 12px;
    }
    
    .chat-header {
        padding: 16px;
        border-radius: 16px 16px 0 0;
    }
    
    .assistant-avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .assistant-details h4 {
        font-size: 16px;
    }
    
    .chat-messages {
        padding: 16px;
        gap: 14px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .message-content {
        padding: 12px 16px;
        border-radius: 16px;
    }
    
    .message-content p {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .chat-input-container {
        padding: 16px;
        border-radius: 0 0 16px 16px;
    }
    
    #chatInput {
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .send-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .quick-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .chat-toggle-btn {
        width: 56px;
        height: 56px;
        font-size: 22px;
        bottom: 16px;
        right: 16px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .ai-chat-widget {
        width: calc(100vw - 20px);
        height: 350px;
        bottom: 90px;
        right: 10px;
        left: 10px;
        border-radius: 8px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .message-content p {
        font-size: 13px;
    }
    
    .quick-actions {
        gap: 6px;
    }
    
    .quick-btn {
        padding: 5px 10px;
        font-size: 10px;
    }
}

/* Animation for widget appearance */
.ai-chat-widget.show {
    display: flex;
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-chat-widget {
        background: #1f2937;
        border-color: #374151;
    }
    
    .chat-messages {
        background: linear-gradient(to bottom, #1f2937, #111827);
    }
    
    .assistant-message .message-content {
        background: linear-gradient(135deg, #374151, #4b5563);
        color: #f9fafb;
        border-left-color: #667eea;
    }
    
    .assistant-message .message-content p {
        color: #f9fafb;
    }
    
    #chatInput {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    #chatInput:focus {
        background: #4b5563;
    }
    
    .chat-input-container {
        background: #1f2937;
        border-top-color: #374151;
    }
}