/* LLM Scope - Professional Minimalist Theme */

:root {
    /* Base colors - dark, muted palette */
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #18181b;
    --bg-elevated: #1f1f23;

    /* Text colors */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    /* Borders */
    --border-subtle: #27272a;
    --border-default: #3f3f46;

    /* Accent - single professional blue */
    --accent: #3b82f6;
    --accent-muted: #1d4ed8;

    /* Semantic colors for node types - muted, professional */
    --color-embedding: #f59e0b;
    --color-attention: #8b5cf6;
    --color-mlp: #10b981;
    --color-norm: #06b6d4;
    --color-head: #ec4899;
    --color-layers: #6366f1;
    --color-default: #71717a;

    /* Layout */
    --header-height: 52px;
    --legend-height: 32px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Transitions */
    --transition: 150ms ease;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Header */
.header {
    height: var(--header-height);
    min-height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    gap: var(--space-4);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    width: 26px;
    height: 26px;
    color: var(--text-primary);
    opacity: 0.9;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.logo h1 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    line-height: 1.2;
}

.attribution {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
    line-height: 1;
}

.attribution:hover {
    color: var(--text-secondary);
}

/* Quick Models */
.quick-models {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.quick-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-2);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.quick-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-default);
}

/* Toggle Control */
.toggle-control {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    user-select: none;
}

.toggle-control input {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--accent);
}

.toggle-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
}

/* Header Buttons */
.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.header-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.header-btn.primary {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: white;
}

.header-btn.primary:hover {
    background: var(--accent);
}

.header-btn svg {
    width: 16px;
    height: 16px;
}

/* Legend Bar */
.legend-bar {
    height: var(--legend-height);
    min-height: var(--legend-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    overflow-x: auto;
}

.legend {
    display: flex;
    gap: var(--space-4);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    white-space: nowrap;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: lowercase;
    font-weight: 500;
}

/* Panels Container */
.panels-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Panel */
.panel {
    flex: 1;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
    background: var(--bg-primary);
}

.panel:last-child {
    border-right: none;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-input-wrapper {
    flex: 1;
    display: flex;
    gap: var(--space-1);
}

.panel-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-1) var(--space-2);
    font-size: 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    transition: border-color var(--transition);
}

.panel-input:focus {
    outline: none;
    border-color: var(--accent);
}

.panel-input::placeholder {
    color: var(--text-muted);
}

.panel-go-btn {
    background: var(--accent-muted);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-1) var(--space-3);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
}

.panel-go-btn:hover:not(:disabled) {
    background: var(--accent);
}

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

.panel-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.panel-close-btn svg {
    width: 14px;
    height: 14px;
}

/* Panel Info */
.panel-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.7rem;
}

.panel-model-name {
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-params {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 600;
}

.panel-type {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Panel Error */
.panel-error {
    background: rgba(239, 68, 68, 0.1);
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
    padding: var(--space-2) var(--space-3);
    color: #fca5a5;
    font-size: 0.7rem;
}

/* Panel Canvas */
.panel-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.panel-viz {
    width: 100%;
    height: 100%;
    cursor: grab;
}

.panel-viz:active {
    cursor: grabbing;
}

.panel-viz svg {
    width: 100%;
    height: 100%;
}

/* Panel Empty State */
.panel-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    pointer-events: none;
}

.panel-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-2);
    opacity: 0.2;
}

.panel-empty p {
    font-size: 0.75rem;
}

/* Spinner */
.spinner {
    width: 14px;
    height: 14px;
    animation: spin 1s linear infinite;
}

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

/* Tooltip */
.tooltip {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    max-width: 260px;
}

.tooltip-title {
    font-weight: 600;
    margin-bottom: var(--space-1);
    font-size: 0.8rem;
    color: var(--text-primary);
}

.tooltip-content {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 1px 0;
}

.tooltip-label {
    color: var(--text-muted);
}

.tooltip-value {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

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

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

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

/* Comparison Results */
.compare-empty {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-6);
    font-size: 0.85rem;
}

.compare-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.compare-model {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-3);
}

.compare-model-name {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.compare-model-params {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.compare-section {
    margin-bottom: var(--space-4);
}

.compare-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.compare-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.compare-badge.same {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.compare-badge.diff {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.compare-badge.added {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.compare-badge.removed {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.compare-list {
    list-style: none;
    font-size: 0.75rem;
}

.compare-list li {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.compare-list .item-name {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.compare-list .item-detail {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.compare-list .item-diff {
    display: flex;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.compare-list .model-a {
    color: #3b82f6;
}

.compare-list .model-b {
    color: #8b5cf6;
}

.compare-similarity {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.similarity-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
}

.similarity-fill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.similarity-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    min-width: 48px;
    text-align: right;
}

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

/* Error hint */
.error-hint {
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    color: #93c5fd;
}

.error-hint code {
    background: rgba(0,0,0,0.3);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
}

/* Header buttons with text */
.header-btn.with-text {
    width: auto;
    padding: 0 var(--space-3);
    gap: var(--space-1);
}

.header-btn.with-text span {
    font-size: 0.7rem;
    font-weight: 500;
}

.header-btn .dropdown-arrow {
    width: 12px;
    height: 12px;
    margin-left: var(--space-1);
}

/* Export Dropdown */
.export-dropdown {
    position: relative;
}

.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-1);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--transition);
    z-index: 100;
    min-width: 140px;
}

.export-dropdown:hover .export-menu,
.export-menu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.export-option {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
}

.export-option:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.export-option:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.export-option:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Loading Status */
.loading-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
    opacity: 0.5;
}

.status-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    animation: pulse 2s ease-in-out infinite;
}

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

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .header-center {
        display: none;
    }

    .panels-container {
        flex-direction: column;
    }

    .panel {
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .panel:last-child {
        border-bottom: none;
    }
}
