/* ARCHITECTURE: Chat interface styles for medical AI assistant
   WHY: Professional chat UI with dark mode support and medical-grade aesthetics
   TRADEOFF: Custom styles vs framework - chose custom for consistency with existing design
   NOTE: Integrates with existing CSS variables for theming */

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-primary);
    scroll-behavior: smooth;
}

/* Welcome Message */
.chat-welcome {
    text-align: center;
    padding: 3rem 1rem;
    animation: fadeIn 0.5s ease;
}

/* Message Bubbles */
.chat-message {
    margin-bottom: 1.5rem;
    animation: slideUp 0.3s ease;
}

.chat-message.user {
    display: flex;
    justify-content: flex-end;
}

.chat-message.assistant {
    display: flex;
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 0.875rem 1.25rem;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

.user .message-bubble {
    background: var(--primary-500);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Message Metadata */
.message-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

.user .message-time {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

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

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

/* Chat Input Container */
.chat-input-container {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    max-height: 120px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.chat-send-btn {
    padding: 0.75rem 1.25rem;
    background: var(--primary-500);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--primary-600);
    transform: translateY(-1px);
}

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

.chat-send-btn i {
    font-size: 1.25rem;
}

/* Source Citations */
.message-sources {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}

.source-item {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--primary-600);
    background: var(--primary-50);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin: 0.25rem 0.25rem 0 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.source-item:hover {
    background: var(--primary-100);
    transform: translateY(-1px);
}

/* Error Message */
.chat-error {
    background: var(--error-50);
    color: var(--error-700);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Loading State */
.chat-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.chat-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

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

/* Code Blocks in Messages */
.message-bubble pre {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 0.75rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.message-bubble code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Markdown Support */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.message-bubble ul,
.message-bubble ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-bubble li {
    margin: 0.25rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 85%;
    }
    
    .chat-container {
        height: calc(100vh - 150px);
    }
}