/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
    --bg-main:      #0a0e1a;
    --bg-panel:     rgba(22, 27, 34, 0.75);
    --bg-input:     #1c212b;
    --bg-input-h:   #232936;
    --text-main:    #e8eaf6;
    --text-muted:   #8b949e;
    --accent-green: #00f5a0;
    --accent-purple:#7b2fff;
    --accent-red:   #ff4f7b;
    --accent-blue:  #00cfff;
    --border-color: rgba(255, 255, 255, 0.09);
    --font-main:    'Inter', sans-serif;
    --font-mono:    'Fira Code', monospace;
    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    14px;
}

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

/* ── Body ───────────────────────────────────────────────────────────────── */
body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(123, 47, 255, 0.06), transparent 28%),
        radial-gradient(circle at 85% 25%, rgba(0, 245, 160, 0.05), transparent 28%),
        radial-gradient(circle at 50% 90%, rgba(0, 207, 255, 0.04), transparent 25%);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo { display: flex; align-items: center; gap: 0.9rem; }
.logo-icon { font-size: 1.7rem; }
.logo h1 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.4px; }
.logo span { color: var(--accent-green); font-weight: 700; }

.header-badges { display: flex; gap: 0.7rem; }

.badge {
    padding: 0.3rem 0.85rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}
.badge.highlight {
    background: rgba(123, 47, 255, 0.15);
    color: #b388ff;
    border-color: rgba(123, 47, 255, 0.3);
}
.badge.accent2 {
    background: rgba(0, 207, 255, 0.1);
    color: var(--accent-blue);
    border-color: rgba(0, 207, 255, 0.25);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
    display: flex;
    flex: 1;
    padding: 1.8rem 2rem;
    gap: 1.8rem;
    max-width: 1700px;
    margin: 0 auto;
    width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
    width: 340px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    backdrop-filter: blur(12px);
}
.panel h2 {
    font-size: 1.05rem;
    margin-bottom: 1.2rem;
    color: #fff;
    font-weight: 600;
}
.panel h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Experiment Description Card ────────────────────────────────────────── */
.exp-desc-card {
    background: rgba(0, 245, 160, 0.04);
    border: 1px solid rgba(0, 245, 160, 0.12);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    margin-bottom: 1.2rem;
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    transition: border-color 0.3s;
}
.exp-desc-icon { font-size: 1.3rem; line-height: 1.3; flex-shrink: 0; }
.exp-desc-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── Form Elements ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.row-group { display: flex; gap: 0.9rem; }
.sub-group { flex: 1; }

label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 500;
}
.label-hint {
    font-size: 0.72rem;
    color: rgba(139, 148, 158, 0.7);
    font-weight: 400;
}

select, input[type="number"], input[type="text"] {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
select:focus, input:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(0, 245, 160, 0.08);
}
select:hover, input:hover { background: var(--bg-input-h); }

/* Multi-select */
select[multiple] {
    padding: 0.3rem;
    height: auto;
    cursor: pointer;
}
select[multiple] option {
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 2px;
}
select[multiple] option:checked {
    background: linear-gradient(90deg, rgba(123,47,255,0.35), rgba(0,245,160,0.15));
    color: #fff;
    font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    width: 100%;
    padding: 0.78rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.btn.primary {
    background: linear-gradient(135deg, var(--accent-purple), #5e1ac7);
    color: white;
    margin-top: 0.8rem;
    box-shadow: 0 4px 16px rgba(123, 47, 255, 0.3);
}
.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 22px rgba(123, 47, 255, 0.45);
}
.btn.pipeline {
    background: linear-gradient(135deg, #00a36c, #00f5a0);
    color: #0a0e1a;
    flex-direction: column;
    gap: 0.1rem;
    margin-top: 0.6rem;
    box-shadow: 0 4px 16px rgba(0, 245, 160, 0.2);
}
.btn.pipeline:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 22px rgba(0, 245, 160, 0.35);
}
.pipeline-sub { font-size: 0.72rem; font-weight: 400; opacity: 0.75; }
.pipeline-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    line-height: 1.5;
    text-align: center;
}
.pipeline-note code {
    font-family: var(--font-mono);
    color: var(--accent-green);
    font-size: 0.73rem;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }
.btn-icon { font-style: normal; }

.btn-icon-only {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}
.btn-icon-only:hover { border-color: var(--accent-green); color: var(--accent-green); }

.divider { height: 1px; background: var(--border-color); margin: 1rem 0; }

/* ── Cipher Info ──────────────────────────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.7rem 1rem;
    font-size: 0.88rem;
}
.info-grid span:nth-child(odd) { color: var(--text-muted); }

/* ── Pipeline Status Panel ───────────────────────────────────────────────── */
.pipe-step {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0;
    font-size: 0.86rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    transition: color 0.3s;
}
.pipe-step:last-child { border-bottom: none; }
.pipe-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #30363d;
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}
.pipe-step[data-state="running"] { color: var(--accent-green); }
.pipe-step[data-state="running"] .pipe-dot {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(0,245,160,0.6);
    animation: pulse-dot 1s ease-in-out infinite;
}
.pipe-step[data-state="done"] { color: #e8eaf6; }
.pipe-step[data-state="done"] .pipe-dot { background: var(--accent-green); }
.pipe-step[data-state="error"] { color: var(--accent-red); }
.pipe-step[data-state="error"] .pipe-dot { background: var(--accent-red); }

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 6px rgba(0,245,160,0.5); }
    50%       { box-shadow: 0 0 14px rgba(0,245,160,0.9); }
}

/* ── Display Area ─────────────────────────────────────────────────────────── */
.display-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

.view-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(12px);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Placeholder ──────────────────────────────────────────────────────────── */
.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
    gap: 0.8rem;
}
.placeholder-icon { font-size: 4rem; opacity: 0.4; }
.results-placeholder h2 { color: var(--text-main); font-size: 1.4rem; }
.results-placeholder p { max-width: 420px; line-height: 1.6; font-size: 0.9rem; }

.quick-tips {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
    max-width: 480px;
}
.tip-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    text-align: left;
}
.tip-key {
    background: rgba(123,47,255,0.2);
    color: #b388ff;
    border: 1px solid rgba(123,47,255,0.3);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    margin-right: 0.4rem;
}

/* ── Job View ─────────────────────────────────────────────────────────────── */
.job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.3rem;
}
.job-header h2 {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--accent-green);
    font-size: 1.1rem;
}
.job-id {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
}

.spinner {
    width: 18px; height: 18px;
    border: 3px solid rgba(0, 245, 160, 0.25);
    border-radius: 50%;
    border-top-color: var(--accent-green);
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.progress-container {
    margin-bottom: 1.6rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.progress-bar {
    flex: 1;
    height: 7px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-green));
    width: 0%;
    transition: width 0.35s ease;
    box-shadow: 0 0 10px rgba(0, 245, 160, 0.45);
}
.progress-text { font-weight: 600; min-width: 3rem; text-align: right; font-size: 0.9rem; }

/* ── Terminal ─────────────────────────────────────────────────────────────── */
.terminal {
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 240px;
}
.terminal-header {
    background: #161b22;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid #21262d;
    display: flex;
    align-items: center;
}
.mac-btns { display: flex; gap: 6px; }
.mac-btns span { width: 12px; height: 12px; border-radius: 50%; }
.mac-btns span:nth-child(1) { background: #ff5f56; }
.mac-btns span:nth-child(2) { background: #ffbd2e; }
.mac-btns span:nth-child(3) { background: #27c93f; }
.term-title {
    margin: 0 auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
}
.terminal-body {
    padding: 0.9rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.83rem;
    line-height: 1.55;
    color: #c9d1d9;
    overflow-y: auto;
    flex: 1;
    max-height: 420px;
}
.log-entry { margin-bottom: 0.25rem; animation: fadeInLog 0.2s ease; }
.log-time { color: #484f58; margin-right: 0.5rem; }
@keyframes fadeInLog { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ── Results ──────────────────────────────────────────────────────────────── */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.4rem;
}
.results-header h2 { font-size: 1.2rem; }
.results-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.2rem; }

.stat-pill {
    background: rgba(0, 245, 160, 0.1);
    color: var(--accent-green);
    padding: 0.35rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.84rem;
    border: 1px solid rgba(0, 245, 160, 0.25);
    white-space: nowrap;
}
.stat-pill.red {
    background: rgba(255,79,123,0.1);
    color: var(--accent-red);
    border-color: rgba(255,79,123,0.25);
}

.plot-container {
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.4rem;
    display: flex;
    justify-content: center;
}
.plot-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* ── Data Table ───────────────────────────────────────────────────────────── */
.data-table-container {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.2rem;
}
.data-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.15);
}
.data-table-header h3 { font-size: 0.88rem; color: var(--text-main); font-weight: 600; }

.table-scroll { overflow-x: auto; max-height: 320px; overflow-y: auto; }

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}
.results-table thead th {
    background: rgba(123,47,255,0.12);
    color: #b388ff;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.65rem 1rem;
    text-align: left;
    position: sticky;
    top: 0;
    white-space: nowrap;
    border-bottom: 1px solid rgba(123,47,255,0.2);
}
.results-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}
.results-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.results-table tbody td {
    padding: 0.6rem 1rem;
    color: var(--text-main);
    white-space: nowrap;
}
.results-table tbody td.acc-cell {
    font-family: var(--font-mono);
    font-weight: 600;
}
.acc-high { color: var(--accent-green); }
.acc-mid  { color: #ffbd2e; }
.acc-low  { color: var(--accent-red); }

/* ── Raw JSON ─────────────────────────────────────────────────────────────── */
.raw-data-container {
    background: var(--bg-input);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.raw-data-container h3 { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 0.5rem; }
pre#raw-data {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    overflow-x: auto;
    color: #a5d6ff;
    max-height: 240px;
    overflow-y: auto;
}

/* ── Pipeline Grid ────────────────────────────────────────────────────────── */
.pipeline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1.2rem;
    margin-top: 1rem;
}
.pipeline-result-card {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.pipeline-result-card .card-header {
    padding: 0.65rem 1rem;
    background: rgba(123,47,255,0.1);
    border-bottom: 1px solid rgba(123,47,255,0.15);
    font-size: 0.85rem;
    font-weight: 600;
    color: #b388ff;
}
.pipeline-result-card img {
    width: 100%;
    height: auto;
    display: block;
}
