/* Global Styles */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1f2937;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: white !important;
}

.navbar-brand i {
    font-size: 1.5rem;
    color: #fbbf24;
}

#model-status {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.875rem;
}

#model-status i {
    font-size: 0.5rem;
    margin-right: 0.5rem;
}

#embedding-status {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.875rem;
}

#embedding-status i {
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

/* Main Container */
.main-container {
    padding-top: 80px;
    height: calc(100vh - 80px);
    background: var(--bg-secondary);
}

/* Sidebar */
.sidebar {
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    height: 100%;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.sidebar-content {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Assistant Mode Section */
.assistant-mode-section {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.assistant-mode-section .section-title {
    margin-bottom: 1rem;
}

.assistant-mode-section .form-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.assistant-mode-section .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.assistant-mode-section .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.assistant-mode-section .form-text {
    font-size: 0.75rem;
    line-height: 1.4;
}

.assistant-mode-section .form-text i {
    color: var(--primary-color);
}

/* Model Parameters Section */
.model-params-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
}

.params-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.5rem 0;
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s ease;
}

.params-header:hover {
    background-color: var(--bg-tertiary);
}

.params-summary {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.param-value {
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.expand-btn {
    color: var(--text-muted);
    padding: 0.25rem;
    border: none;
    background: none;
    transition: transform 0.2s ease;
}

.expand-btn:hover {
    color: var(--primary-color);
}

.expand-btn.expanded {
    transform: rotate(180deg);
}

.params-content {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.section-subtitle {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-range {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
}

.form-range::-webkit-slider-thumb {
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-range::-moz-range-thumb {
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-range::-webkit-slider-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
    height: 6px;
}

.form-range::-moz-range-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
    height: 6px;
}

.model-params-section .btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

/* Streaming Message Styles */
.message.streaming .message-text {
    position: relative;
}

.streaming-content {
    display: inline;
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--primary-color);
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Smooth streaming updates */
.message.streaming .message-text {
    transition: none;
}

.message.streaming .message-content {
    border-left: 3px solid var(--primary-color);
    padding-left: 0.75rem;
}

/* Upload Section */
.upload-section {
    flex: 1;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-text {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* File List */
.file-list {
    margin-top: 1.5rem;
}

.file-list-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.file-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.file-icon {
    width: 2rem;
    height: 2rem;
    background: var(--primary-color);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    margin-right: 0.75rem;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.file-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Chat History */
.chat-history {
    flex: 1;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.history-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.history-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.history-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-count {
    background: var(--primary-color);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-size: 0.625rem;
    font-weight: 500;
}

/* Chat Area */
.chat-area {
    background: var(--bg-primary);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Welcome Message */
.welcome-message {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    color: white;
    font-size: 2rem;
}

.welcome-content h2 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.welcome-text {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

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

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 1rem;
    animation: fadeInUp 0.3s ease;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

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

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--success-color) 100%);
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-lg);
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.message-text {
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
}

.message.assistant .message-time {
    color: var(--text-muted);
}

/* Input Area */
.input-area {
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    padding: 1.5rem;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.message-input {
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    border-radius: var(--border-radius-sm);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

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

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

.input-footer {
    margin-top: 0.75rem;
    text-align: center;
}

/* Loading Modal */
.modal-content {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    margin-bottom: 1rem;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 80px;
        width: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .chat-area {
        width: 100%;
    }
    
    .features {
        flex-direction: column;
        gap: 1rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .input-wrapper {
        padding: 0.75rem;
    }
    
    .send-btn {
        width: 40px;
        height: 40px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.shadow-custom {
    box-shadow: var(--shadow-lg);
}

/* Status Indicators */
.status-online {
    color: var(--success-color) !important;
}

.status-offline {
    color: var(--danger-color) !important;
}

.status-loading {
    color: var(--warning-color) !important;
    animation: pulse 1.5s infinite;
} 