/*
 * MELA AI Chat Assistant Styles
 * Clean, modern chat interface with smooth animations
 */

/* Main Container */
.chat-assistant-container {
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 0;
}

.chat-header .mud-text,
.chat-header .mud-icon-button {
    color: white !important;
}

/* Messages Container */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f7fa;
    scroll-behavior: smooth;
}

/* Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 20px;
}

.chat-empty-state .mud-icon {
    font-size: 64px !important;
    opacity: 0.5;
}

/* Message Bubble */
.chat-message {
    margin-bottom: 16px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
}

.user-bubble .mud-text {
    color: white !important;
}

.ai-bubble {
    background: white;
    border: 1px solid #e0e4e8;
}

.message-content {
    word-wrap: break-word;
}

.message-timestamp {
    display: block;
    margin-top: 8px;
    opacity: 0.7;
    font-size: 0.75rem;
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Tool Call Card */
.tool-call-card {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    border-radius: 8px;
}

/* Data Table Renderer */
.data-table-render {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.data-table-render .mud-table {
    font-size: 0.875rem;
}

/* JSON Renderer */
.json-renderer {
    background: #f8f9fa;
    border: 1px solid #e0e4e8;
    border-radius: 8px;
}

.json-content {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    margin: 0;
    padding: 8px;
    background: #282c34;
    color: #abb2bf;
    border-radius: 4px;
    overflow-x: auto;
    max-height: 400px;
}

/* Markdown Content */
.markdown-content {
    line-height: 1.6;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
}

.markdown-content h1 {
    font-size: 1.5rem;
}

.markdown-content h2 {
    font-size: 1.25rem;
}

.markdown-content h3 {
    font-size: 1.1rem;
}

.markdown-content ul,
.markdown-content ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.markdown-content li {
    margin-bottom: 4px;
}

.markdown-content code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background: #282c34;
    color: #abb2bf;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.markdown-content table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.markdown-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 16px;
    margin: 12px 0;
    color: #666;
}

/* Input Container */
.chat-input-container {
    border-top: 1px solid #e0e4e8;
    background: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-assistant-container {
        height: calc(100vh - 60px);
    }

    .message-bubble {
        max-width: 85%;
    }

    .chat-messages-container {
        padding: 12px;
    }
}

/* Scrollbar Styling */
.chat-messages-container::-webkit-scrollbar {
    width: 8px;
}

.chat-messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Progress Linear Colors */
.mud-progress-linear.mud-success .mud-progress-linear-bar {
    background: linear-gradient(90deg, #4caf50 0%, #8bc34a 100%);
}

.mud-progress-linear.mud-primary .mud-progress-linear-bar {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

/* Quick Action Buttons */
.message-bubble .mud-button {
    margin: 4px;
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================
   Enhanced Progress Tracking Styles (Phase 3)
   ============================================ */

/* Operation Phase Colors */
:root {
    --phase-pending: #9E9E9E;      /* Gray */
    --phase-initializing: #2196F3;  /* Blue */
    --phase-fetching: #00BCD4;      /* Cyan */
    --phase-processing: #9C27B0;    /* Purple */
    --phase-generating: #FF9800;    /* Orange */
    --phase-completed: #4CAF50;     /* Green */
    --phase-failed: #F44336;        /* Red */

    /* Gradient overlays for active states */
    --gradient-fetching: linear-gradient(90deg, #00BCD4 0%, #03A9F4 100%);
    --gradient-processing: linear-gradient(90deg, #9C27B0 0%, #673AB7 100%);
    --gradient-generating: linear-gradient(90deg, #FF9800 0%, #FF5722 100%);
}

/* Enhanced Animations */
@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progress Bar Animations */
.progress-bar-animated {
    background: var(--gradient-fetching);
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
}

.progress-bar-success {
    transition: all 0.5s ease-in-out;
}

.progress-smooth {
    transition: all 0.3s ease-out;
}

/* Icon Animations */
.icon-pulse {
    animation: pulse 1.5s infinite ease-in-out;
}

.icon-spin {
    animation: spin 2s infinite linear;
}

.icon-bounce {
    animation: bounce 0.5s ease-in-out;
}

.icon-shake {
    animation: shake 0.5s ease-in-out;
}

/* Tool Call Card Enhancements */
.tool-call-card {
    transition: all 0.3s ease;
    background: white;
    border: 1px solid #e0e4e8;
    border-left: 4px solid var(--phase-pending);
}

.tool-call-card.entering {
    animation: slideInUp 0.4s ease-out;
}

/* Phase-specific border colors */
.tool-call-card.phase-pending {
    border-left-color: var(--phase-pending);
}

.tool-call-card.phase-initializing {
    border-left-color: var(--phase-initializing);
}

.tool-call-card.phase-fetching {
    border-left-color: var(--phase-fetching);
}

.tool-call-card.phase-processing {
    border-left-color: var(--phase-processing);
}

.tool-call-card.phase-generating {
    border-left-color: var(--phase-generating);
}

.tool-call-card.phase-completed {
    border-left-color: var(--phase-completed);
    background: #f1f8f4;
}

.tool-call-card.phase-failed {
    border-left-color: var(--phase-failed);
    background: #fef5f5;
}

/* Phase Indicator Container */
.phase-indicator-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    margin-bottom: 16px;
}

/* Phase Step */
.phase-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    min-width: 80px;
}

.phase-step.active {
    background: rgba(33, 150, 243, 0.1);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.phase-step.completed {
    opacity: 0.6;
}

.phase-step.pending {
    opacity: 0.4;
}

/* AI Operation Container */
.ai-operation-container {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    animation: slideInUp 0.4s ease-out;
}

/* Error Alert Enhancements */
.error-alert {
    border-left: 4px solid var(--phase-failed);
    animation: slideInUp 0.3s ease-out;
}

.error-alert .mud-alert-message {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Monospace for technical details */
.monospace {
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 0.85rem;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
}

/* Settings Drawer */
.settings-drawer {
    width: 320px;
}

/* Phase Timeline (Horizontal) */
.phase-timeline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.phase-timeline-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.phase-timeline-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: #e0e4e8;
    z-index: -1;
}

.phase-timeline-item.active::after {
    background: var(--phase-initializing);
}

.phase-timeline-item.completed::after {
    background: var(--phase-completed);
}

/* Responsive Design for Progress Components */
@media (max-width: 768px) {
    .tool-call-card {
        margin: 8px 0;
    }

    .phase-indicator-container {
        padding: 12px;
    }

    .phase-step {
        padding: 4px;
        min-width: 60px;
    }

    .phase-step .mud-text {
        font-size: 0.7rem;
    }

    .ai-operation-container {
        padding: 12px;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .tool-call-card.entering,
    .ai-operation-container,
    .error-alert {
        animation: none;
    }

    .icon-pulse,
    .icon-spin,
    .icon-bounce,
    .icon-shake {
        animation: none;
    }

    .progress-bar-animated {
        animation: none;
    }

    .phase-step.active {
        transform: none;
    }
}

/* Dark Mode Support (for future use) */
@media (prefers-color-scheme: dark) {
    .phase-indicator-container {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    }

    .tool-call-card {
        background: #2d3748;
        border-color: #4a5568;
    }

    .ai-operation-container {
        background: #2d3748;
    }

    .monospace {
        background: #1a202c;
        color: #e2e8f0;
    }
}

/* Connection Status Badge */
.connection-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.connection-status-badge.connected {
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
}

.connection-status-badge.connecting {
    background: rgba(33, 150, 243, 0.1);
    color: #2196f3;
}

.connection-status-badge.disconnected {
    background: rgba(158, 158, 158, 0.1);
    color: #9e9e9e;
}

.connection-status-badge.error {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
}

/* Status Pulse Dot */
.status-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-pulse-dot.active {
    animation: pulse 2s infinite ease-in-out;
}

.status-pulse-dot.connected {
    background: #4caf50;
}

.status-pulse-dot.connecting {
    background: #2196f3;
}

.status-pulse-dot.disconnected {
    background: #9e9e9e;
}

.status-pulse-dot.error {
    background: #f44336;
}

/* Tool Execution Stats */
.tool-stats {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: #666;
    margin-top: 8px;
}

.tool-stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Progress Percentage Badge */
.progress-percentage {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
    padding: 2px 8px;
    background: rgba(33, 150, 243, 0.1);
    color: #2196f3;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
