/**
 * LinkedIn-Style Professional Floating Chat Interface
 * Enhanced UX for strategic AI consultant interactions
 */

/* Enhanced Chat Container */
#ai-mentor-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1060; /* High enough to be visible but not block other interactions */
    display: flex !important;
    flex-direction: column;
    align-items: flex-end;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; /* Container itself doesn't block interactions */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Professional Chat Bubble */
#ai-mentor-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0073b1 0%, #005885 100%);
    box-shadow: 0 4px 20px rgba(0, 115, 177, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1061; /* High enough to be visible */
    color: white;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 115, 177, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    visibility: visible !important;
    opacity: 1 !important;
}

#ai-mentor-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 115, 177, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, #0084cc 0%, #006699 100%);
}

#ai-mentor-icon i {
    font-size: 26px;
    transition: all 0.2s ease;
}

/* Professional Status Indicator */
.chat-status-indicator {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2ecc71;
    border: 3px solid white;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Enhanced Chat Window */
.strategic-chat-interface {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1062; /* Ensure chat window appears above everything when open */
}

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

/* Professional Header */
.chat-header {
    background: linear-gradient(135deg, #0073b1 0%, #005885 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header .status-text {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    padding: 4px;
    border-radius: 4px;
}

.chat-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

/* Enhanced Chat Body */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

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

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

.chat-body::-webkit-scrollbar-thumb {
    background: #d1d3d7;
    border-radius: 3px;
}

/* Professional Message Styling */
.chat-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.assistant {
    align-items: flex-start;
}

.message-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.chat-message.user .message-bubble {
    background: #0073b1;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Message Timestamps */
.message-time {
    font-size: 11px;
    color: #8b9dc3;
    margin-top: 4px;
    padding: 0 4px;
}

/* Enhanced Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 85%;
    border: 1px solid #e1e5e9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #0073b1;
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Professional Input Area */
.chat-input {
    padding: 16px 20px;
    border-top: 1px solid #e1e5e9;
    background: white;
    border-radius: 0 0 16px 16px;
}

.chat-input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input textarea {
    flex: 1;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 12px 16px;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    background: #f8f9fa;
    transition: all 0.2s ease;
    font-family: inherit;
    max-height: 100px;
}

.chat-input textarea:focus {
    outline: none;
    border-color: #0073b1;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 115, 177, 0.1);
}

.chat-send-btn {
    background: #0073b1;
    border: none;
    border-radius: 50%;
    color: white;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    background: #005885;
    transform: scale(1.05);
}

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

.chat-send-btn i {
    font-size: 16px;
}

/* Enhanced Welcome Popup */
.chat-welcome-popup {
    position: absolute;
    bottom: 85px;
    right: -10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    max-width: 320px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 115, 177, 0.2);
    pointer-events: auto;
}

.chat-welcome-popup.show {
    opacity: 1;
    transform: translateY(0);
}

.chat-welcome-popup::before {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

.welcome-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.welcome-text {
    flex: 1;
}

.welcome-text h6 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: #0073b1;
}

.welcome-text p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.welcome-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    font-size: 16px;
    transition: color 0.2s ease;
}

.welcome-close:hover {
    color: #666;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    #ai-mentor-container {
        bottom: 20px !important;
        right: 20px !important;
        position: fixed !important;
        z-index: 1060 !important;
    }
    
    #ai-mentor-icon {
        width: 60px !important;
        height: 60px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 1061 !important;
    }
    
    #ai-mentor-icon i {
        font-size: 24px !important;
    }
    
    .strategic-chat-interface {
        width: 90vw !important;
        right: -15vw !important;
        height: 70vh !important;
        max-height: 500px !important;
        bottom: 85px !important;
    }
    
    .chat-welcome-popup {
        width: 280px !important;
        right: -50px !important;
        bottom: 85px !important;
    }
    
    .message-bubble {
        max-width: 90% !important;
    }
}

/* Professional Enhancement Classes */
.consultant-badge {
    background: linear-gradient(45deg, #ff6b35, #f7931e);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
}

.expertise-tag {
    background: rgba(0, 115, 177, 0.1);
    color: #0073b1;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
    margin: 2px;
    display: inline-block;
}

/* Animation for new messages */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message {
    animation: messageSlideIn 0.3s ease-out;
}

/* Quick Action Buttons */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 0 4px;
}

.quick-action-btn {
    background: rgba(0, 115, 177, 0.1);
    color: #0073b1;
    border: 1px solid rgba(0, 115, 177, 0.2);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.quick-action-btn:hover {
    background: #0073b1;
    color: white;
    transform: translateY(-1px);
}