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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    background: #1e293b;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* ── Navbar ──────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: #60a5fa;
}

.nav-links { display: flex; gap: 16px; }

.nav-link {
    color: #94a3b8;
    font-weight: 500;
    transition: color .2s;
}
.nav-link:hover { color: #e2e8f0; text-decoration: none; }

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar { width: 32px; height: 32px; border-radius: 50%; }
.user-name { color: #cbd5e1; font-size: 0.9rem; }
.logout-link { color: #f87171 !important; font-size: 0.85rem; }

/* ── Container ───────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ── Login page ──────────────────────────────────────── */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
}

.login-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 48px;
    max-width: 520px;
    width: 100%;
    text-align: center;
}

.login-card h1 {
    font-size: 2rem;
    color: #60a5fa;
    margin-bottom: 8px;
}

.login-subtitle {
    color: #94a3b8;
    margin-bottom: 32px;
    line-height: 1.5;
}

.theory-block {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 32px;
    text-align: left;
}

.theory-block h3 { color: #60a5fa; margin-bottom: 8px; }
.theory-block p { color: #94a3b8; line-height: 1.6; font-size: 0.95rem; }

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.email-input {
    padding: 14px 18px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 1rem;
    outline: none;
    transition: border-color .2s;
}
.email-input:focus { border-color: #3b82f6; }
.email-input::placeholder { color: #64748b; }

.btn-login { width: 100%; }

.error-msg {
    background: rgba(248, 113, 113, .15);
    color: #f87171;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

/* ── Sort page ───────────────────────────────────────── */
.sort-page {}

.info-panel { margin-bottom: 24px; }
.info-panel h2 { color: #60a5fa; margin-bottom: 8px; }
.algo-desc { color: #94a3b8; margin-bottom: 16px; }

.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-primary:disabled { background: #475569; cursor: not-allowed; }

.status-text {
    margin-top: 12px;
    font-size: 0.95rem;
    color: #fbbf24;
    min-height: 1.4em;
}

/* ── Visualization ───────────────────────────────────── */
.visualization {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 800px) {
    .visualization { grid-template-columns: 1fr; }
}

.viz-section {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
}

.viz-section h3 {
    color: #cbd5e1;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: #0f172a;
}

/* ── Thread log ──────────────────────────────────────── */
.thread-log {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
}

.thread-log h3 {
    color: #cbd5e1;
    margin-bottom: 12px;
}

.log-entries {
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

.log-entry {
    padding: 4px 8px;
    border-radius: 4px;
    animation: fadeIn .3s ease;
}

.log-entry:nth-child(odd) { background: rgba(255,255,255,.03); }

.log-entry .time { color: #64748b; }
.log-entry .thread { color: #a78bfa; }
.log-entry .value { color: #34d399; font-weight: 600; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Journal page ────────────────────────────────────── */
.journal-page h2 { color: #60a5fa; margin-bottom: 24px; }

.journal-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 800px) {
    .journal-sections { grid-template-columns: 1fr; }
}

.journal-section {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
}

.journal-section h3 {
    color: #cbd5e1;
    margin-bottom: 16px;
    font-size: 1rem;
}

.journal-item {
    padding: 12px;
    border-bottom: 1px solid #334155;
    font-size: 0.9rem;
}

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

.journal-item-header {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 6px;
}

.run-number { color: #60a5fa; font-weight: 700; }
.run-date { color: #94a3b8; }
.run-duration { color: #34d399; margin-left: auto; font-weight: 600; }

.run-arrays { color: #cbd5e1; font-family: monospace; font-size: 0.85rem; }
.run-arrays div { margin-top: 4px; }

.login-ip { color: #64748b; margin-left: auto; }

.loading, .empty { color: #64748b; text-align: center; padding: 24px; }
