:root {
    /* Brand Colors matching the Dashboard Image */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-disabled: #94a3b8;
    --border-color: #e2e8f0;
    
    --success: #10b981;
    --success-bg: #d1fae5;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

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

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-text h1 {
    font-size: 16px;
    font-weight: 700;
}

.brand-text p {
    font-size: 12px;
    color: var(--text-muted);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-surface-alt);
    color: var(--text-main);
}

.nav-item.active {
    background-color: #eff6ff; /* light blue */
    color: var(--primary);
}

.help-box {
    background-color: var(--bg-surface-alt);
    padding: 16px;
    border-radius: 12px;
    margin-top: auto;
}

.help-icon {
    color: var(--primary);
    margin-bottom: 8px;
}

.help-box h3 {
    font-size: 14px;
    margin-bottom: 4px;
}

.help-box p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.4;
}

.help-box a {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Topbar */
.topbar {
    height: 64px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 32px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.model-badge {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    padding: 24px 32px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
}

.step.active .step-icon {
    border-color: var(--primary);
    color: var(--primary);
}

.step.completed .step-icon {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

.step-text span {
    font-size: 12px;
    color: var(--text-muted);
}

.step-text h4 {
    font-size: 14px;
    font-weight: 600;
}

.step.active .step-text h4, .step.completed .step-text h4 {
    color: var(--text-main);
}

.step-divider {
    flex-grow: 1;
    height: 2px;
    background-color: var(--border-color);
    margin: 0 24px;
    max-width: 60px;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    padding: 32px;
}

/* Left Panel (Controls) */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.control-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

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

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

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
}

/* Drop Zone */
.drop-zone {
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    background-color: #f8fafc;
    transition: all 0.2s;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background-color: #eff6ff;
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 12px;
}

.primary-text {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.secondary-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.browse-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 16px;
}

.tertiary-text {
    font-size: 11px;
    color: var(--text-muted);
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 16px;
    background: #f8fafc;
}

#preview-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
}

.file-info {
    flex-grow: 1;
    overflow: hidden;
}

.file-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
}

.check-icon {
    color: var(--success);
}

/* Buttons */
.run-btn {
    width: 100%;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    font-family: inherit;
}

.run-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--text-disabled);
}

.analysis-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* Right Panel (Results) */
.results-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.results-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-title h2 {
    font-size: 18px;
    font-weight: 600;
}

.results-title p {
    font-size: 13px;
    color: var(--text-muted);
}

.results-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-main);
}

.action-btn:hover {
    background: var(--bg-surface-alt);
}

/* Alert Banner */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fca5a5;
    font-weight: 500;
    font-size: 14px;
}

/* Empty State */
.empty-state {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 400px;
}

.empty-illustration {
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
    max-width: 300px;
}

/* Results Content */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fafaf9;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-success { background: var(--success-bg); color: var(--success); }
.status-danger { background: var(--danger-bg); color: var(--danger); }
.bg-blue { background: #e0f2fe; color: #0284c7; }
.bg-purple { background: #f3e8ff; color: #9333ea; }

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-purple { color: #9333ea; }

.image-viewer {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: #e2e8f0;
    height: 450px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#result-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.viewer-toolbar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
}

.tool-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
}

.tool-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.zoom-level {
    font-size: 13px;
    font-weight: 500;
    margin: 0 8px;
}

/* Legend */
.legend-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.legend-title {
    font-size: 13px;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.bg-green { background: var(--success); }
.bg-red { background: var(--danger); }

.bottom-tip {
    padding: 0 32px 32px 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--primary);
}

.hidden {
    display: none !important;
}

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

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