/* MongoDB LangChain Agent - Enhanced Modern UI Styles */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Header Styles */
.header {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideInDown 0.6s ease-out;
}

.header-content {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.title-section h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.title-section p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
}

.status-indicator i {
    color: var(--success-color);
    animation: pulse 2s infinite;
}

/* Control Panel */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: slideInUp 0.6s ease-out 0.2s both;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card i {
    font-size: 1.5rem;
    color: var(--primary-color);
    width: 2.5rem;
    text-align: center;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Collection Selector */
.collection-selector {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.selector-header h4 {
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.refresh-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.refresh-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: rotate(180deg);
}

.selector-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.collection-dropdown {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    background: var(--background-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.collection-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.collection-dropdown option {
    padding: 0.5rem;
    background: var(--surface-color);
    color: var(--text-primary);
}

.collection-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

#activeContext.database {
    color: var(--primary-color);
}

#activeContext.collection {
    color: var(--success-color);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-btn {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: var(--text-primary);
}

.action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.action-btn i {
    font-size: 0.875rem;
}

/* Chat Section */
.chat-section {
    flex: 1;
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.6s ease-out 0.4s both;
}

.chat-header {
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.control-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--background-color);
    min-height: 400px;
    max-height: 600px;
}

.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: var(--radius-sm);
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Message Styles */
.message {
    margin-bottom: 1.5rem;
    animation: slideInMessage 0.4s ease-out;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.bot-avatar {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
}

.user-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.message-info {
    display: flex;
    flex-direction: column;
}

.sender {
    font-weight: 600;
    color: var(--text-primary);
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.message-content {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-left: 3.25rem;
}

.user-message .message-content {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: #bfdbfe;
}

.bot-message .message-content {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: #bbf7d0;
}

/* Welcome Message */
.welcome-message .message-content {
    background: linear-gradient(135deg, #fefce8, #fef3c7);
    border-color: #fde047;
}

.welcome-message h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.command-examples {
    margin: 1.5rem 0;
}

.command-examples h5 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.example-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.example-item:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.example-item i {
    font-size: 0.875rem;
    opacity: 0.7;
}

.feature-highlights {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 500;
}

.feature i {
    color: var(--primary-color);
    font-size: 0.875rem;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.data-table th {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 0.75rem;
    font-weight: 600;
    text-align: left;
    font-size: 0.875rem;
    letter-spacing: 0.025em;
}

.data-table td {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.data-table tbody tr:nth-child(even) {
    background: var(--background-color);
}

.data-table tbody tr:hover {
    background: #eff6ff;
    transform: scale(1.01);
    transition: all 0.2s ease;
}

/* Input Section */
.input-section {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: slideInUp 0.6s ease-out 0.6s both;
}

.input-container {
    padding: 1.5rem;
}

.input-wrapper {
    margin-bottom: 1rem;
}

.input-group {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.input-field-wrapper {
    flex: 1;
    position: relative;
}

.input-field {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--background-color);
    color: var(--text-primary);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.input-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.suggestion-item:hover {
    background: var(--primary-color);
    color: white;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.send-button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 1rem 2rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Input Help */
.input-help {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

kbd {
    background: var(--border-color);
    border: 1px solid var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    font-family: monospace;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-spinner {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* Animations */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Status Classes */
#status.ready {
    color: var(--success-color);
}

#status.processing {
    color: var(--warning-color);
}

#status.error {
    color: var(--error-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .title-section h1 {
        font-size: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quick-actions {
        justify-content: center;
    }
    
    .example-grid {
        grid-template-columns: 1fr;
    }
    
    .feature-highlights {
        justify-content: center;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .send-button {
        width: 100%;
        justify-content: center;
    }
    
    .chat-container {
        max-height: 400px;
    }
    
    .message-content {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .action-btn {
        flex: 1;
        justify-content: center;
    }
}

/* Print Styles */
@media print {
    .control-panel,
    .input-section,
    .loading-overlay {
        display: none;
    }
    
    .container {
        padding: 0;
    }
    
    .chat-section {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}