/**
 * Premium Chat UI Enhancements
 * Modern message bubbles, animations, and interactions
 */

/* Enhanced Message Bubbles */
.message-container {
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left center;
}

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

/* AI Message Enhancements */
.ai-message {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-left: 3px solid #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
    position: relative;
    overflow: visible;
}

.ai-message::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, #3b82f6 0%, #60a5fa 100%);
    border-radius: 2px;
}

/* User Message Enhancements */
.user-message {
    background: linear-gradient(135deg, #C41E3A 0%, #a01830 100%);
    box-shadow: 0 2px 12px rgba(196, 30, 58, 0.2);
    position: relative;
}

.user-message::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid #a01830;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

/* Message Actions (Hover) */
.message-actions {
    position: absolute;
    top: -8px;
    right: 12px;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    gap: 4px;
    background: white;
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message-container:hover .message-actions {
    opacity: 1;
    transform: translateY(0);
}

.message-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 16px;
    transition: all 0.2s;
}

.message-action-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
    transform: scale(1.1);
}

/* Copy Button */
.copy-btn {
    position: relative;
}

.copy-btn.copied::after {
    content: 'Copied!';
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    animation: copyFeedback 1.5s ease-out;
}

@keyframes copyFeedback {
    0%, 100% {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    20%, 80% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin: 8px 0;
    animation: typingSlideIn 0.3s ease-out;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        background: #94a3b8;
    }
    30% {
        transform: translateY(-10px);
        background: #64748b;
    }
}

/* Message Reactions */
.message-reactions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.reaction:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: scale(1.05);
}

.reaction.active {
    background: #eff6ff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.reaction-emoji {
    font-size: 16px;
}

.reaction-count {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}

.reaction.active .reaction-count {
    color: #3b82f6;
}

/* Add Reaction Button */
.add-reaction-btn {
    width: 28px;
    height: 28px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 16px;
    transition: all 0.2s;
}

.add-reaction-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #64748b;
    transform: rotate(90deg);
}

/* Reaction Picker */
.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    gap: 4px;
    margin-bottom: 8px;
    z-index: 100;
    animation: reactionPickerSlideIn 0.2s ease-out;
}

.reaction-picker.show {
    display: flex;
}

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

.reaction-picker button {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
}

.reaction-picker button:hover {
    background: #f1f5f9;
    transform: scale(1.2);
}

/* Timestamp */
.message-timestamp {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-container:hover .message-timestamp {
    opacity: 1;
}

/* Enhanced Code Blocks */
.message-content pre {
    position: relative;
    background: #1e293b !important;
    border-radius: 8px;
    padding: 16px !important;
    margin: 12px 0;
    overflow-x: auto;
}

.message-content pre code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* Code Copy Button */
.code-block-header {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
}

.code-copy-btn {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Message Sources */
.message-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px;
    color: #475569;
    text-decoration: none;
    transition: all 0.2s;
    margin: 4px;
}

.source-chip:hover {
    background: white;
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.source-icon {
    font-size: 14px;
}

/* Loading State */
.message-loading {
    opacity: 0.6;
    pointer-events: none;
}

.message-loading .message-content {
    position: relative;
    overflow: hidden;
}

.message-loading .message-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: messageLoading 1.5s infinite;
}

@keyframes messageLoading {
    to {
        left: 100%;
    }
}

/* Responsive */
@media (max-width: 640px) {
    .message-actions {
        right: 8px;
    }

    .reaction-picker {
        left: 50%;
        transform: translateX(-50%);
    }
}
