:root {
    /* Base Themes - Dark */
    --bg-page: #020617; /* Slate 950 */
    --bg-panel: #0f172a; /* Slate 900 */
    --bg-surface: #1e293b; /* Slate 800 */
    --bg-hover: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --border-light: rgba(255, 255, 255, 0.05);
    
    --primary: #3b82f6; /* Blue 500 */
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.5);
    
    --secondary: #10b981; /* Emerald 500 */
    --accent: #8b5cf6; /* Violet 500 */
    
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px var(--primary-glow);
    
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
    --bg-page: #f8fafc; /* Slate 50 */
    --bg-panel: #ffffff;
    --bg-surface: #f1f5f9;
    --bg-hover: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --border-color: #e2e8f0;
    --border-light: rgba(0, 0, 0, 0.05);
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.3);
    
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Utilities */
.font-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 0.85rem; }
.hide { display: none !important; }

/* Layout */
.app-container {
    width: 100%; max-width: 1400px; margin: 0 auto; padding: 1.5rem;
    display: flex; flex-direction: column; gap: 1.5rem; height: 100vh;
}

/* Glass panel */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    position: relative; overflow: hidden;
}
.glass-panel::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}

/* Header */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-radius: var(--radius-lg); flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 1rem; }
.logo {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: white;
}
.title-group h1 { font-size: 1.2rem; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
.badge { background: var(--bg-surface); color: var(--text-muted); padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; border: 1px solid var(--border-color);}

.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.divider { width: 1px; height: 24px; background: var(--border-color); margin: 0 0.5rem; }

/* Buttons */
.btn {
    display: inline-flex; justify-content: center; align-items: center; gap: 0.5rem;
    padding: 0.6rem 1.2rem; border-radius: var(--radius-md); font-size: 0.9rem; font-weight: 600; font-family: inherit;
    border: 1px solid transparent; cursor: pointer; transition: all 0.2s;
}
.btn i { width: 18px; height: 18px; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; border: none; box-shadow: 0 2px 10px var(--primary-glow); }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 15px var(--primary-glow); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { background: var(--bg-surface); color: var(--text-primary); }
.full-width { width: 100%; }

.icon-btn {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md); border: none; background: transparent; color: var(--text-secondary);
    cursor: pointer; transition: 0.2s;
}
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm i { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--bg-surface); color: var(--text-primary); }

/* Workspace Split View */
.workspace {
    display: flex; gap: 1.5rem; flex: 1; min-height: 0;
}

.panel {
    border-radius: var(--radius-lg); flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* Input Panel */
.input-panel { border: 1px solid var(--border-color); background: var(--bg-panel); }

.tabs { display: flex; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); }
.tab {
    flex: 1; padding: 1rem; background: transparent; border: none; font-family: inherit;
    font-size: 0.9rem; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: 0.2s;
    border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--bg-panel); }

.panel-body { flex: 1; overflow: auto; position: relative; }
.tab-content { display: none; height: 100%; }
.tab-content.active { display: block; height: 100%; }

textarea {
    width: 100%; height: 100%; padding: 1.5rem; border: none; background: var(--bg-panel); color: var(--text-primary);
    font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.6; outline: none; resize: none; white-space: pre;
}

/* Upload Zone */
.upload-zone {
    height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 2px dashed var(--border-color); border-radius: var(--radius-md); margin: 1.5rem;
    transition: all 0.2s; cursor: pointer; text-align: center; background: rgba(0,0,0,0.02);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: rgba(59, 130, 246, 0.05); }
.upload-icon { width: 48px; height: 48px; color: var(--primary); margin-bottom: 1rem; opacity: 0.8; }
.upload-zone h3 { font-size: 1.1rem; margin-bottom: 0.2rem; }

.image-preview-container { height: 100%; width: 100%; padding: 1.5rem; position: relative; display: flex; align-items: center; justify-content: center; }
.image-preview-container img { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-md); object-fit: contain;}
.delete-btn { position: absolute; top: 2rem; right: 2rem; background: var(--error); color: white; border-radius: 50%; opacity: 0.8;}
.delete-btn:hover { background: var(--error); opacity: 1;}

.panel-footer { padding: 1.5rem; border-top: 1px solid var(--border-color); background: var(--bg-surface); }

/* Output Panel */
.output-tabs { display: flex; padding: 1rem 1.5rem 0; gap: 1rem; border-bottom: 1px solid var(--border-color); }
.out-tab {
    padding: 0.5rem 1rem 0.75rem; background: transparent; border: none; font-family: inherit; font-size: 0.9rem; font-weight: 500;
    color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
    border-bottom: 2px solid transparent; transition: 0.2s;
}
.out-tab:hover { color: var(--text-secondary); }
.out-tab.active { color: var(--text-primary); border-bottom-color: var(--primary); }

.output-body { display: flex; flex-direction: column; }

.out-tab-content { height: 100%; display: flex; flex-direction: column; }

/* Empty State / Radar */
.empty-state { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 2rem; }
.radar-container {
    width: 100px; height: 100px; border: 2px solid var(--border-color); border-radius: 50%; position: relative; margin-bottom: 1.5rem;
    display: flex; justify-content: center; align-items: center; background: rgba(0,0,0,0.1); overflow: hidden;
}
.radar-container i { color: var(--text-muted); width: 32px; height: 32px; z-index: 2; }
.radar-sweep {
    position: absolute; top: 50%; left: 50%; width: 50px; height: 50px; transform-origin: 0 0;
    background: linear-gradient(45deg, var(--primary-glow) 0%, transparent 50%); animation: sweep 3s infinite linear; z-index: 1;
}
@keyframes sweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Loading state */
.loading-state { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.spinner { width: 50px; height: 50px; border: 4px solid var(--bg-surface); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s infinite linear; margin-bottom: 1.5rem; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Report */
.report-header { display: flex; justify-content: space-between; align-items: flex-end; padding: 1.5rem; border-bottom: 1px solid var(--border-color); }
.report-header h2 { font-size: 1.25rem; }
.score-text { font-weight: 600; margin-top: 0.2rem; }
.gradient-text { background: linear-gradient(135deg, var(--primary), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
.report-actions { display: flex; gap: 0.5rem; }

.report-content { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.report-section { background: var(--bg-surface); padding: 1.25rem; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.report-section h3 { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; margin-bottom: 0.75rem; }
.report-section h3 i { width: 18px; height: 18px; }
.report-section ul { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.report-section li { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.report-section li i { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; }

.severity-high { color: var(--error); }
.severity-medium { color: var(--warning); }
.severity-low { color: var(--success); }

.box-critical { border-left: 4px solid var(--error); }
.box-warning { border-left: 4px solid var(--warning); }
.box-success { border-left: 4px solid var(--success); }
.box-info { border-left: 4px solid var(--primary); }

/* Visualization */
.visual-header { display: flex; justify-content: space-between; padding: 0.75rem 1.5rem; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); }
.zoom-controls { display: flex; }
.visual-canvas { flex: 1; overflow: auto; padding: 2rem; display: flex; justify-content: center; align-items: center; background: var(--bg-editor); min-height: 300px; }
.visual-canvas svg { max-width: 100%; height: auto; }
.image-canvas { flex: 1; overflow: auto; padding: 1rem; display: flex; justify-content: center; align-items: center; }

/* Toasts */
.toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px);
    background: var(--text-primary); color: var(--bg-page); padding: 0.75rem 1.5rem; border-radius: 99px;
    font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow-md); z-index: 2000;
    opacity: 0; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 900px) {
    .workspace { flex-direction: column; }
    .panel { min-height: 500px; }
}
