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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --error-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    padding: 2rem;
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
.header {
    background: var(--secondary-gradient);
    color: white;
    padding: 2.5rem;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Navigation Bar */
.nav-bar {
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.nav-link {
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: var(--bg-tertiary);
}

.nav-link.active {
    background: var(--primary-gradient);
    color: white;
}

/* Content Section */
.content-section {
    padding: 2rem;
}

/* Setup Grid */
.setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.setup-grid.single-column {
    grid-template-columns: 1fr;
}

.setup-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.setup-card.wide {
    grid-column: 1 / -1;
}

.setup-card h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Step Numbers */
.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Workflow Cards */
.workflow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.workflow-card {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.workflow-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.workflow-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--bg-primary);
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area.has-file {
    background: #e8f5e9;
    border-color: #4caf50;
}

.upload-area input {
    display: none;
}

.upload-label {
    cursor: pointer;
    display: block;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.upload-label small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Buttons */
.action-btn {
    padding: 0.75rem 2rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.action-btn.primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
}

.action-btn.success {
    background: var(--success-gradient);
    color: white;
    border: none;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Progress Bar */
.progress-container {
    margin: 2rem 0;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 15px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.progress-text {
    text-align: center;
    margin-top: 0.5rem;
    color: var(--text-secondary);
}

/* Status Elements */
.status-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-message.loading {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0.25rem;
}

.status-badge.ready {
    background: #d4edda;
    color: #155724;
}

.status-badge.loading {
    background: #fff3cd;
    color: #856404;
}

.status-badge.error {
    background: #f8d7da;
    color: #721c24;
}

.status-indicators {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Settings Panel */
.settings-panel {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.setting-item input {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.3s ease;
}

.setting-item input:focus {
    outline: none;
    border-color: #667eea;
}

.setting-item small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.settings-mini {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.setting-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.setting-row label {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.setting-row input {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Model Select */
.model-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    background: var(--bg-primary);
}

/* Tabs */
.tab-container {
    margin-top: 1rem;
}

.tab-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

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

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
}

/* Output Display */
.output-display {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--primary-gradient);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: white;
}

.stat-card p {
    font-size: 0.9rem;
    opacity: 0.95;
}

/* Search Interface */
.search-container {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.search-buttons {
    display: flex;
    gap: 1rem;
}

.stats-banner {
    background: #e8f5e9;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    color: #2e7d32;
    font-weight: 500;
}

/* Search Results */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-item {
    background: var(--bg-secondary);
    border-left: 4px solid #667eea;
    padding: 1rem;
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.result-item:hover {
    transform: translateX(5px);
}

.similarity-score {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.chunk-text {
    color: var(--text-primary);
    line-height: 1.6;
    margin-top: 0.5rem;
}

.highlight {
    background: yellow;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Chat Interface */
.chat-interface {
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--bg-tertiary);
}

.message {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
}

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

.message-bubble {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    line-height: 1.5;
}

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

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

.message-sources {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
}

.source-item {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    color: var(--text-primary);
}

.source-score {
    display: inline-block;
    padding: 2px 6px;
    background: #4caf50;
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

/* Input Container */
.input-container {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn {
    padding: 0.75rem 2rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

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

/* Info Section */
.info-section {
    margin: 3rem 0;
}

.info-section h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

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

.info-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.info-card h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.info-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Requirements Notice */
.requirements-notice {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.requirements-notice strong {
    display: block;
    margin-bottom: 0.5rem;
}

.requirements-section {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    margin-top: 2rem;
}

.requirements-section h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.requirements-section ul {
    list-style-position: inside;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* Document Info */
.doc-info {
    background: #e8f5e9;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.doc-info strong {
    color: #2e7d32;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Results Section */
.results-section {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.results-section h2 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.output-section {
    margin-top: 2rem;
}

.output-section h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive Design */
@media (max-width: 968px) {
    .setup-grid {
        grid-template-columns: 1fr;
    }
    
    .workflow-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .search-buttons {
        flex-direction: column;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 640px) {
    body {
        padding: 1rem;
    }
    
    .header {
        padding: 1.5rem;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .content-section {
        padding: 1rem;
    }
    
    .nav-bar {
        flex-wrap: wrap;
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
    }
    
    .setup-card {
        padding: 1rem;
    }
    
    .workflow-card {
        padding: 1.5rem;
    }
    
    .search-container {
        padding: 1rem;
    }
    
    .messages-container {
        padding: 1rem;
    }
    
    .input-container {
        padding: 1rem;
    }
    
    .chat-input {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }
    
    .send-btn {
        padding: 0.6rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
    }
}