﻿/* ========================================
   SMART LEGAL SYSTEM - COMPONENT STYLES
   Enterprise Component Library
   ======================================== */

:root {
    /* Primary Colors */
    --color-primary-50: #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-200: #bfdbfe;
    --color-primary-300: #93c5fd;
    --color-primary-400: #60a5fa;
    --color-primary-500: #3b82f6;
    --color-primary-600: #2563eb;
    --color-primary-700: #1d4ed8;
    --color-primary-800: #1e40af;
    --color-primary-900: #1e3a8a;
    
    /* Success */
    --color-success-50: #ecfdf5;
    --color-success-100: #d1fae5;
    --color-success-500: #10b981;
    --color-success-600: #059669;
    --color-success-700: #047857;
    --color-success-light: rgba(16, 185, 129, 0.12);
    --color-success: #10b981;
    
    /* Warning */
    --color-warning-50: #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;
    --color-warning-700: #b45309;
    --color-warning: #f59e0b;
    
    /* Danger */
    --color-danger-50: #fef2f2;
    --color-danger-100: #fee2e2;
    --color-danger-500: #ef4444;
    --color-danger-600: #dc2626;
    --color-danger-700: #b91c1c;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 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);
    
    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    
    /* Legal Colors */
    --color-court: #8b5cf6;
    --color-law: #3b82f6;
    --color-case: #10b981;
    --color-contract: #f59e0b;
    --color-citation: #ec4899;
    --color-ai: #8b5cf6;
    
    /* Typography */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    
    /* Brand */
    --brand-gradient: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --gradient-brand: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --brand-primary: #2563eb;
}

/* Theme-aware mappings */
body.app-layout {
    --card-bg: var(--bg-card);
    --card-border: var(--border-color);
    --border-subtle: var(--border-light);
    --color-bg-primary: var(--bg-page);
    --color-bg-secondary: var(--bg-card);
    --color-bg-hover: var(--bg-hover);
    --color-text-primary: var(--text-primary);
    --color-text-secondary: var(--text-secondary);
    --color-text-tertiary: var(--text-tertiary);
    --color-border: var(--border-color);
}

/* ===== PAGE CONTAINER ===== */

.legal-page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

/* Alias for sl-page */
.sl-page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== PAGE HEADER ===== */

.page-header {
    background: var(--color-bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.page-title-section h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary-600);
    color: white;
    border-color: var(--color-primary-600);
}

.btn-primary:hover {
    background: var(--color-primary-700);
    border-color: var(--color-primary-700);
}

.btn-secondary {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.btn-ai {
    background: linear-gradient(135deg, var(--color-ai), var(--color-primary-600));
    color: white;
    border: none;
}

.btn-ai:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ===== STATS GRID ===== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    border-color: var(--color-primary-200);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.primary {
    background: var(--color-primary-50);
    color: var(--color-primary-600);
}

.stat-icon.success {
    background: var(--color-success-50);
    color: var(--color-success-600);
}

.stat-icon.warning {
    background: var(--color-warning-50);
    color: var(--color-warning-600);
}

.stat-icon.ai {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(59, 130, 246, 0.1));
    color: var(--color-ai);
}

.stat-content h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.stat-change {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.stat-change.up {
    color: var(--color-success-600);
}

.stat-change.down {
    color: var(--color-danger-600);
}

/* ===== TABLE STYLES ===== */

.table-container {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-toolbar {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--color-bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr.selected {
    background: var(--color-primary-50);
}

/* ===== DOCUMENT CARDS ===== */

.document-card {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-fast);
}

.document-card:hover {
    border-color: var(--color-primary-300);
    box-shadow: var(--shadow-md);
}

.document-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.document-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.document-type-badge.court-decision {
    background: var(--color-court);
    color: white;
}

.document-type-badge.law {
    background: var(--color-law);
    color: white;
}

.document-type-badge.contract {
    background: var(--color-contract);
    color: white;
}

/* ===== CONFIDENCE INDICATOR ===== */

.confidence-bar {
    height: 6px;
    background: var(--color-bg-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.confidence-fill.high {
    background: var(--color-success-500);
}

.confidence-fill.medium {
    background: var(--color-warning-500);
}

.confidence-fill.low {
    background: var(--color-danger-500);
}

.confidence-text {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
}

/* ===== CITATION BADGE ===== */

.citation-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--color-citation);
    color: white;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.citation-badge:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ===== AI INDICATOR ===== */

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--color-ai), var(--color-primary-600));
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.ai-badge i {
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== PROCESSING STATUS ===== */

.processing-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.processing-status.completed {
    background: var(--color-success-50);
    color: var(--color-success-700);
}

.processing-status.processing {
    background: var(--color-primary-50);
    color: var(--color-primary-700);
}

.processing-status.pending {
    background: var(--color-bg-hover);
    color: var(--color-text-secondary);
}

.processing-status.failed {
    background: var(--color-danger-50);
    color: var(--color-danger-700);
}

.processing-status.review {
    background: var(--color-warning-50);
    color: var(--color-warning-700);
}

/* ===== CHAT INTERFACE ===== */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
}

.chat-message.user {
    align-self: flex-end;
    background: var(--color-primary-600);
    color: white;
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
}

.chat-message.assistant .citation-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--color-citation);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0 2px;
}

.chat-input-container {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.chat-input:focus {
    border-color: var(--color-primary-500);
}

/* ===== TRAINING DASHBOARD ===== */

.training-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.training-progress-bar {
    height: 8px;
    background: var(--color-bg-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.training-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary-500), var(--color-ai));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.training-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    text-align: center;
}

.training-metric {
    padding: 16px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
}

.training-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary-600);
}

.training-metric-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .legal-page {
        padding: 16px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== BADGES ===== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.badge-danger,
.badge-error {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.badge-neutral {
    background: rgba(107, 114, 128, 0.12);
    color: #6b7280;
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

/* ===== EMPTY STATE ===== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    background: var(--bg-hover, #1f1f1f);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-tertiary, #525252);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text-primary, #fafafa);
}

.empty-state p {
    font-size: 13px;
    color: var(--text-secondary, #a3a3a3);
    max-width: 320px;
    margin: 0 0 20px 0;
}

/* ===== TEXT UTILITIES ===== */

.text-muted {
    color: var(--text-tertiary, #525252);
}

.text-primary {
    color: var(--text-primary, #fafafa);
}

.text-secondary {
    color: var(--text-secondary, #a3a3a3);
}

/* ===== ANIMATIONS ===== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

.animate-slide-up {
    animation: slideUp var(--transition-normal) ease-out;
}

/* Staggered animation for list items */
.stagger-animate > * {
    animation: slideUp 0.2s ease-out forwards;
}

.stagger-animate > *:nth-child(1) { animation-delay: 0ms; }
.stagger-animate > *:nth-child(2) { animation-delay: 50ms; }
.stagger-animate > *:nth-child(3) { animation-delay: 100ms; }
.stagger-animate > *:nth-child(4) { animation-delay: 150ms; }
.stagger-animate > *:nth-child(5) { animation-delay: 200ms; }

