/* ===================================
   STRAND AI PLATFORM - MILESTONE 1
   Functional Demo Platform
   =================================== */

:root {
    /* Colors */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #06b6d4;
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-dark: #1f2937;
    
    /* Text */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    /* Borders */
    --border: #e5e7eb;
    --border-dark: #d1d5db;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Transitions */
    --transition: 200ms ease;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-dark: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border: #334155;
    --border-dark: #475569;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background var(--transition), color var(--transition);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* Header */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-lg) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo i {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.header-info {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.milestone-badge {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    font-weight: 600;
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* Main Layout */
.main-container {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: var(--space-lg);
    padding: var(--space-lg);
    max-width: 1600px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.sidebar-section {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.sidebar-section h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.sidebar-section h3 i {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.control-group {
    margin-bottom: var(--space-lg);
}

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.select-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
}

.select-input:hover {
    border-color: var(--primary);
}

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

.btn-primary, .btn-secondary {
    width: 100%;
    padding: var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: all var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    margin-bottom: var(--space-sm);
}

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

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

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

.btn-primary i {
    width: 18px;
    height: 18px;
}

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

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

.btn-secondary i {
    width: 18px;
    height: 18px;
}

/* Status Items */
.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
}

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

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

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

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

/* Config Items */
.config-item {
    margin-bottom: var(--space-md);
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Doc Links */
.doc-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: var(--space-sm);
    transition: all var(--transition);
}

.doc-link:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateX(4px);
}

.doc-link i {
    width: 16px;
    height: 16px;
}

/* Main Content */
.content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Card */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header h2 i {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.card-body {
    padding: var(--space-xl);
}

/* Badges */
.badge {
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Prompt Display */
.prompt-display {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

.prompt-text {
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    font-style: italic;
}

.prompt-meta {
    display: flex;
    gap: var(--space-xl);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.prompt-meta span {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.prompt-meta i {
    width: 16px;
    height: 16px;
}

/* Pipeline Flow */
.pipeline-flow {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.pipeline-stage {
    display: flex;
    gap: var(--space-lg);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    cursor: pointer;
}

.pipeline-stage:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.pipeline-stage.active {
    background: rgba(37, 99, 235, 0.05);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.pipeline-stage.completed {
    background: rgba(16, 185, 129, 0.05);
    border-color: var(--success);
}

.pipeline-stage.error {
    background: rgba(239, 68, 68, 0.05);
    border-color: var(--error);
}

.stage-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stage-icon i {
    width: 24px;
    height: 24px;
    color: white;
}

.pipeline-stage.completed .stage-icon {
    background: linear-gradient(135deg, var(--success), #059669);
}

.pipeline-stage.error .stage-icon {
    background: linear-gradient(135deg, var(--error), #dc2626);
}

.stage-content {
    flex: 1;
}

.stage-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.stage-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.stage-status {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stage-status[data-status="pending"] {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-tertiary);
}

.stage-status[data-status="running"] {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
    animation: pulse 2s infinite;
}

.stage-status[data-status="completed"] {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stage-status[data-status="error"] {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

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

.pipeline-arrow {
    display: flex;
    justify-content: center;
    color: var(--text-tertiary);
}

.pipeline-arrow i {
    width: 24px;
    height: 24px;
}

/* Pipeline Controls */
.pipeline-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.execution-status {
    padding: var(--space-sm) var(--space-lg);
    background: rgba(156, 163, 175, 0.1);
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.execution-status.running {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

.execution-status.completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.execution-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Results Section */
.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

.result-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.result-panel h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.result-panel h3 i {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

/* Video Placeholder */
.video-placeholder {
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, var(--bg-dark), #374151);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    color: white;
    padding: var(--space-xl);
    text-align: center;
}

.video-placeholder i {
    width: 64px;
    height: 64px;
    opacity: 0.7;
}

.video-placeholder p {
    font-size: 1.125rem;
    font-weight: 600;
}

.video-meta {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Attribution Results */
.attribution-results {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.attribution-item {
    padding: var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.attribution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.attribution-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

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

.attribution-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.attribution-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: var(--radius-xl);
    transition: width 1s ease;
}

.attribution-meta {
    display: flex;
    gap: var(--space-md);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Safety Results */
.safety-results {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.safety-check {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.safety-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.safety-icon.pass {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.safety-icon.fail {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.safety-icon i {
    width: 18px;
    height: 18px;
}

.safety-info {
    flex: 1;
}

.safety-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
    display: block;
    margin-bottom: var(--space-xs);
}

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

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.metric-item {
    padding: var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
    margin-bottom: var(--space-xs);
}

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

/* Logs Sidebar */
.logs-sidebar {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
    position: sticky;
    top: 100px;
}

.logs-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logs-header h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logs-header h3 i {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.logs-controls {
    display: flex;
    gap: var(--space-sm);
}

.log-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

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

.log-btn i {
    width: 16px;
    height: 16px;
}

.logs-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.log-entry {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-xs);
    animation: slideIn 0.3s ease;
}

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

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

.log-level {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.log-info .log-level {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

.log-success .log-level {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.log-warning .log-level {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.log-error .log-level {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.log-message {
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: var(--space-xl);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.modal-close i {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: var(--space-xl);
    overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 260px 1fr 300px;
    }
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar, .logs-sidebar {
        max-height: none;
        position: static;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .pipeline-stage {
        flex-direction: column;
        text-align: center;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar Styling */
.logs-content::-webkit-scrollbar {
    width: 8px;
}

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

.logs-content::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: var(--radius-xl);
}

.logs-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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