/* Legal AI Vault - Modern UI Styles */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --transition: all 0.2s ease;
}

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

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

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

/* Header */
.header {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
}

.header-content h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-logo-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.header-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
}

.header-text {
    flex: 1;
}

.health-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    flex-shrink: 0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.status-dot.healthy {
    background: var(--success-color);
}

.status-dot.unhealthy {
    background: var(--danger-color);
}

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

/* Main Content */
.main-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 0 20px;
    gap: 5px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 16px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--bg-primary);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Panel */
.panel {
    max-width: 900px;
}

.panel h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.panel-desc {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* Forms */
.form {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.input-field,
.textarea-field {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    background: var(--bg-primary);
}

.input-field:focus,
.textarea-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.textarea-field {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

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

/* Result Panel */
.result-panel {
    margin-top: 30px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.result-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.result-content {
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.result-stats {
    display: flex;
    gap: 20px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

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

/* Embeddings */
.embed-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.info-card {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.info-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.info-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.embed-preview {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    font-family: 'Courier New', monospace;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.6;
}

/* Models Grid */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.model-card {
    padding: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.model-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.model-card.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.05) 100%);
    border-color: var(--primary-color);
}

.model-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.model-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.model-detail {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.model-detail-label {
    color: var(--text-secondary);
}

.model-detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.btn-model-select {
    padding: 8px 16px;
    border: 2px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-model-select:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-model-select:active {
    transform: translateY(0);
}

/* Documentation */
.docs-section {
    margin-bottom: 40px;
}

.docs-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.endpoint-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.method {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.method-get {
    background: #dbeafe;
    color: #1e40af;
}

.method-post {
    background: #dcfce7;
    color: #166534;
}

.endpoint-header code {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.code-block {
    background: var(--text-primary);
    color: #10b981;
    padding: 16px;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-top: 12px;
}

.quick-links {
    display: grid;
    gap: 12px;
}

.link-card {
    display: block;
    padding: 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.link-card:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: white;
    font-size: 0.875rem;
}

.footer-meta {
    margin-top: 8px;
    opacity: 0.8;
}

/* RAG Sources */
.sources-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.source-card {
    padding: 16px;
    background: var(--bg-primary);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
}

.source-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.source-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.source-title {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.source-score {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.source-section {
    margin: 8px 0;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.source-preview {
    margin-top: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-secondary);
    font-style: italic;
}

.result-sources {
    margin-top: 20px;
}

/* Agent Sub-Tabs */
.agent-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 20px 0;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    justify-content: center;
}

.agent-tab-btn {
    background: transparent;
    border: 2px solid transparent;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--border-radius-sm);
    white-space: nowrap;
    flex: 0 1 auto;
}

.agent-tab-btn:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.agent-tab-btn.active {
    color: var(--primary-color);
    background: var(--bg-primary);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Agent Content */
.agent-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.agent-content.active {
    display: block;
}

.agent-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.agent-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

/* Synthesis and Validation */
.synthesis-source,
.validation-doc {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--primary-color);
}

.synthesis-source .input-field,
.validation-doc .input-field {
    margin-bottom: 10px;
}

.form-hint {
    display: block;
    margin-top: 8px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Utilities */
.text-muted {
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-logo-section {
        gap: 12px;
    }

    .header-logo {
        width: 60px;
        height: 60px;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .health-status {
        align-self: flex-start;
    }

    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab-btn {
        white-space: nowrap;
    }

    .agent-tabs {
        gap: 4px;
    }

    .agent-tab-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .result-stats {
        flex-direction: column;
        gap: 12px;
    }

    .models-grid {
        grid-template-columns: 1fr;
    }
}

/* Workflow Tags */
.tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    margin-right: 6px;
    margin-bottom: 4px;
}
