/* Switchboard Dashboard — Custom styles */

/* ── CSS Custom Properties (Theme System) ──────────────────── */
:root {
    /* Dark theme (default) */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #0c1628;
    --bg-card: #0f172a;
    --bg-hover: rgba(30, 41, 59, 0.5);
    --bg-input: #1e293b;
    --bg-overlay: rgba(0, 0, 0, 0.6);

    --border-primary: #233044;
    --border-secondary: #3a4d66;
    --border-subtle: rgba(51, 65, 85, 0.5);

    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #8494a7;
    --text-disabled: #576a82;

    --scrollbar-track: #0f172a;
    --scrollbar-thumb: #334155;
    --scrollbar-hover: #475569;

    --msg-gradient: #1e293b;
    --code-bg: #1e293b;
    --code-text: #93c5fd;
    --pre-bg: #0f172a;
    --pre-text: #cbd5e1;
    --link-color: #60a5fa;
    --blockquote-border: #475569;
    --blockquote-text: #94a3b8;
    --table-header-bg: #1e293b;
    --table-border: #334155;
}

.theme-light {
    --bg-primary: #f8fafc;
    --bg-secondary: #e2e8f0;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: rgba(226, 232, 240, 0.5);
    --bg-input: #f1f5f9;
    --bg-overlay: rgba(0, 0, 0, 0.3);

    --border-primary: #e2e8f0;
    --border-secondary: #cbd5e1;
    --border-subtle: rgba(203, 213, 225, 0.5);

    --text-primary: #0f172a;
    --text-secondary: #1e293b;
    --text-muted: #475569;
    --text-faint: #64748b;
    --text-disabled: #94a3b8;

    --scrollbar-track: #f1f5f9;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-hover: #94a3b8;

    --msg-gradient: #ffffff;
    --code-bg: #f1f5f9;
    --code-text: #2563eb;
    --pre-bg: #f8fafc;
    --pre-text: #334155;
    --link-color: #2563eb;
    --blockquote-border: #cbd5e1;
    --blockquote-text: #64748b;
    --table-header-bg: #f1f5f9;
    --table-border: #e2e8f0;
}

/* Apply theme to body */
body { background: var(--bg-primary); color: var(--text-primary); }
.theme-light body,
.theme-light #app { background: var(--bg-primary); color: var(--text-primary); }

/* ── Pulsing dot for working status ──────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.status-dot-working {
    animation: pulse 2s ease-in-out infinite;
}

/* ── Custom scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ── Collapsible message content ─────────────────────────── */
.msg-collapsed {
    max-height: 200px;
    overflow: hidden;
    position: relative;
}
.msg-collapsed::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--msg-gradient));
    pointer-events: none;
}

/* ── Markdown prose ──────────────────────────────────────── */
.prose-dark h1, .prose-dark h2, .prose-dark h3, .prose-dark h4 {
    color: var(--text-secondary);
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}
.prose-dark h1 { font-size: 1.25rem; }
.prose-dark h2 { font-size: 1.125rem; }
.prose-dark h3 { font-size: 1rem; }
.prose-dark p { margin: 0.5em 0; }
.prose-dark ul, .prose-dark ol { margin: 0.5em 0; padding-left: 1.5em; }
.prose-dark li { margin: 0.25em 0; }
.prose-dark code {
    background: var(--code-bg);
    padding: 0.125em 0.375em;
    border-radius: 4px;
    font-size: 0.875em;
    color: var(--code-text);
}
.prose-dark pre {
    background: var(--pre-bg);
    padding: 0.75em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}
.prose-dark pre code {
    background: none;
    padding: 0;
    color: var(--pre-text);
}
.prose-dark a { color: var(--link-color); text-decoration: underline; }
.prose-dark blockquote {
    border-left: 3px solid var(--blockquote-border);
    padding-left: 0.75em;
    margin: 0.5em 0;
    color: var(--blockquote-text);
}
.prose-dark strong { color: var(--text-primary); }
.prose-dark table { border-collapse: collapse; width: 100%; margin: 0.5em 0; }
.prose-dark th, .prose-dark td {
    border: 1px solid var(--table-border);
    padding: 0.375em 0.75em;
    text-align: left;
}
.prose-dark th { background: var(--table-header-bg); color: var(--text-secondary); }

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar { letter-spacing: 1px; }

/* ── Session log entries ─────────────────────────────────── */
.log-system { color: var(--text-faint); font-style: italic; }
.log-text { color: var(--text-secondary); }
.log-tool { color: #67e8f9; }
.log-result { color: var(--text-muted); }
.log-done { color: #4ade80; }
.log-error { color: #f87171; }

/* ── Gate pipeline pulse ─────────────────────────────────── */
@keyframes gate-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}
.gate-pulse { animation: gate-pulse 2s ease-in-out infinite; }

/* ── Tooltip ─────────────────────────────────────────────── */
.tip {
    position: relative;
    display: inline-flex;
}
.tip-text {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    font-size: 0.7rem;
    line-height: 1.3;
    border-radius: 4px;
    background: #1e293b;
    color: #e2e8f0;
    white-space: nowrap;
    max-width: 320px;
    white-space: normal;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid #334155;
}
/* Intentional: tooltips stay dark in both themes for contrast and consistency */
.theme-light .tip-text {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}
.tip:hover .tip-text { opacity: 1; }

/* Tooltip arrow */
.tip-text::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-bottom-color: #1e293b;
}

/* ── Confirmation Dialog ─────────────────────────────────── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.15s ease;
}
.confirm-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.confirm-dialog h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}
.confirm-dialog p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1.25rem;
    line-height: 1.5;
}
.confirm-dialog .confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}
.confirm-dialog .confirm-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    font-weight: 500;
}
.confirm-dialog .confirm-btn-cancel {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border-color: var(--border-secondary);
}
.confirm-dialog .confirm-btn-cancel:hover {
    background: var(--border-secondary);
    color: var(--text-primary);
}
.confirm-dialog .confirm-btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}
.confirm-dialog .confirm-btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}
.confirm-dialog .confirm-btn-primary {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.3);
}
.confirm-dialog .confirm-btn-primary:hover {
    background: rgba(59, 130, 246, 0.25);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Loading States ──────────────────────────────────────── */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-secondary);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-secondary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Error State ─────────────────────────────────────────── */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    text-align: center;
}
.error-state-icon {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}
.error-state-msg {
    color: #f87171;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.error-state-retry {
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    cursor: pointer;
}
.error-state-retry:hover {
    background: rgba(59, 130, 246, 0.25);
}

/* ── Stale data warning ──────────────────────────────────── */
.stale-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.7rem;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 4px;
}

/* ── Worktree Indicators ─────────────────────────────────── */
.worktree-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
}
.worktree-active { color: #4ade80; }
.worktree-amber { color: #f59e0b; }

/* ── Review Verdict Badge ────────────────────────────────── */
.verdict-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.verdict-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.verdict-changes {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.verdict-pending {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ── DAG Graph Styles ────────────────────────────────────── */

/* Layout: graph + detail panel side by side */
.graph-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 140px);
}
.graph-main {
    flex: 1;
    min-width: 0;
    transition: flex 0.3s ease;
}
.graph-layout-split .graph-main {
    flex: 1 1 50%;
}

/* Graph container */
.dag-container {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    overflow: hidden;
}
.dag-scroll {
    overflow: auto;
    min-height: 300px;
    max-height: calc(100vh - 160px);
    position: relative;
}
.dag-canvas {
    min-width: 100%;
}

/* Task node */
.dag-node {
    position: absolute;
    border-radius: 8px;
    border: 2px solid transparent;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    z-index: 2;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
    overflow: hidden;
}
.dag-node:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 3;
}
.dag-node-selected {
    border-width: 2px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    z-index: 4;
}

/* SVG edge layer */
.dag-edges {
    z-index: 1;
}

/* Detail panel — slide in from right */
.graph-detail-panel {
    width: 55%;
    min-width: 560px;
    max-width: 1100px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInRight 0.25s ease;
}
@keyframes slideInRight {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Heartbeat indicators */
.heartbeat-active {
    background: #22c55e;
    animation: pulse 1.5s ease-in-out infinite;
}
.heartbeat-stale {
    background: #f59e0b;
    animation: pulse 3s ease-in-out infinite;
}
.heartbeat-dead {
    background: #ef4444;
}

/* Responsive: narrow screens overlay the panel */
@media (max-width: 1200px) {
    .graph-detail-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        width: 85%;
        max-width: 500px;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    }
    .graph-layout-split .graph-main {
        flex: 1 1 100%;
    }
}

/* Panel backdrop on narrow screens */
.panel-backdrop {
    display: none;
}
@media (max-width: 1200px) {
    .panel-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 49;
    }
}

/* ── Activity Bar ──────────────────────────────────────────────── */

.activity-bar {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    font-size: 0.75rem;
    position: relative;
    z-index: 10;
}

.activity-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 32px;
    gap: 0.75rem;
}

.activity-bar-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.activity-bar-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.activity-working-task {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.5rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 4px;
    color: #fbbf24;
    text-decoration: none;
    white-space: nowrap;
    max-width: 220px;
}
.activity-working-task:hover {
    background: rgba(245, 158, 11, 0.18);
}

.activity-spinner {
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 1.5px solid rgba(251, 191, 36, 0.3);
    border-top-color: #fbbf24;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.activity-task-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fbbf24;
}

.activity-elapsed {
    color: rgba(251, 191, 36, 0.6);
    white-space: nowrap;
    font-size: 0.7rem;
}

.activity-divider {
    color: var(--border-secondary);
    flex-shrink: 0;
    padding: 0 0.125rem;
}

.activity-event {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
    color: var(--text-muted);
}

.activity-expand-btn {
    background: none;
    border: 1px solid var(--border-secondary);
    border-radius: 4px;
    color: var(--text-faint);
    padding: 0.125rem 0.5rem;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
}
.activity-expand-btn:hover {
    border-color: var(--scrollbar-hover);
    color: var(--text-muted);
}

/* Expanded feed panel */
.activity-feed {
    border-top: 1px solid var(--border-primary);
    padding: 0.5rem 1rem;
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.activity-feed-empty {
    color: var(--text-disabled);
    font-size: 0.75rem;
    padding: 0.5rem 0;
    text-align: center;
}

.activity-feed-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.2rem 0;
    border-radius: 4px;
}

.activity-feed-ts {
    color: var(--text-disabled);
    font-size: 0.7rem;
    white-space: nowrap;
    min-width: 56px;
    flex-shrink: 0;
}

.activity-feed-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

.activity-feed-task-link {
    color: var(--text-disabled);
    font-size: 0.7rem;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.activity-feed-task-link:hover { color: var(--text-muted); }

/* ── Activity Timeline ─────────────────────────────────────────── */
.activity-timeline {
    margin-top: 1.5rem;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-card);
}

.tl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.tl-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--pre-text);
    margin: 0;
}

.tl-title-icon {
    color: var(--text-faint);
}

.tl-count {
    background: var(--bg-secondary);
    color: var(--text-faint);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.0625rem 0.375rem;
    border-radius: 9999px;
}

.tl-collapse-btn {
    background: none;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    color: var(--text-disabled);
    font-size: 0.7rem;
    padding: 0.125rem 0.5rem;
    cursor: pointer;
}
.tl-collapse-btn:hover { color: var(--text-muted); border-color: var(--border-secondary); }

.tl-body {
    padding: 0.5rem 0;
}

.tl-loading {
    color: var(--text-disabled);
    font-size: 0.75rem;
    padding: 1rem;
    text-align: center;
}

.tl-row {
    display: flex;
    align-items: stretch;
    padding: 0 1rem;
    min-height: 40px;
}

.tl-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 28px;
    flex-shrink: 0;
    padding-top: 0.375rem;
}

.tl-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
}

.tl-dot-completed { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.4); color: #60a5fa; }
.tl-dot-failed    { background: rgba(239, 68, 68, 0.15);  border-color: rgba(239, 68, 68, 0.4);  color: #f87171; }
.tl-dot-done      { background: rgba(99, 102, 241, 0.15); border-color: rgba(99, 102, 241, 0.4); color: #818cf8; }
.tl-dot-gate      { background: rgba(139, 92, 246, 0.15); border-color: rgba(139, 92, 246, 0.4); color: #a78bfa; }
.tl-dot-review    { background: rgba(236, 72, 153, 0.15); border-color: rgba(236, 72, 153, 0.4); color: #f472b6; }
.tl-dot-handoff   { background: rgba(99, 102, 241, 0.15); border-color: rgba(99, 102, 241, 0.4); color: #818cf8; }
.tl-dot-status    { background: var(--bg-secondary); border-color: var(--border-secondary); color: var(--text-faint); }

.tl-line {
    flex: 1;
    width: 1px;
    background: var(--border-primary);
    margin: 0.25rem 0;
}

.tl-content {
    flex: 1;
    min-width: 0;
    padding: 0.375rem 0 0.375rem 0.75rem;
}

.tl-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.tl-task-link {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.tl-task-link:hover { color: var(--text-secondary); text-decoration: underline; }

.tl-ts {
    color: var(--text-disabled);
    font-size: 0.7rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.tl-desc {
    color: var(--text-faint);
    font-size: 0.7rem;
    margin-top: 0.125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tl-load-more {
    display: block;
    width: calc(100% - 2rem);
    margin: 0.5rem 1rem;
    padding: 0.375rem;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    color: var(--text-disabled);
    font-size: 0.75rem;
    cursor: pointer;
    text-align: center;
}
.tl-load-more:hover { border-color: var(--border-secondary); color: var(--text-muted); }

/* ── Theme Toggle Button ─────────────────────────────────── */
.theme-toggle {
    background: none;
    border: 1px solid var(--border-secondary);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-faint);
}

/* ── Responsive: tablet ───────────────────────────────────── */
@media (max-width: 1024px) {
    /* Board table: hide less important columns */
    table th:nth-child(3),
    table td:nth-child(3) { display: none; } /* Progress */
    table th:nth-child(5),
    table td:nth-child(5) { display: none; } /* Activity */
}

/* ── Responsive: mobile ──────────────────────────────────── */
@media (max-width: 768px) {
    .activity-bar-left { gap: 0.375rem; }
    .activity-working-task { max-width: 160px; }
    .activity-event { display: none; }
    .activity-divider { display: none; }

    nav .flex.items-center.gap-6 { gap: 0.75rem; }
    nav .flex.items-center.gap-6 > a:first-child { font-size: 0.875rem; }

    /* Board table: hide even more columns on mobile */
    table th:nth-child(4),
    table td:nth-child(4) { display: none; } /* Cost */

    /* Task detail: stack layout */
    .p-6 { padding: 1rem; }

    /* Graph: full-height scroll */
    .dag-scroll { max-height: calc(100vh - 200px); }
}

/* ── Light theme specific overrides ──────────────────────── */
.theme-light nav { background: var(--bg-card); }
.theme-light .activity-bar { background: var(--bg-tertiary); }
.theme-light .dag-container { background: var(--bg-card); }
.theme-light .graph-detail-panel { background: var(--bg-card); }
.theme-light .activity-timeline { background: var(--bg-card); }

/* Light theme: tweak Tailwind-generated bg/text classes via overrides */
.theme-light .bg-slate-900 { background-color: var(--bg-card) !important; }
.theme-light .bg-slate-950 { background-color: var(--bg-primary) !important; }
.theme-light .bg-slate-800 { background-color: var(--bg-secondary) !important; }
.theme-light .bg-slate-800\/50 { background-color: var(--bg-hover) !important; }
.theme-light .border-slate-800 { border-color: var(--border-primary) !important; }
.theme-light .border-slate-700 { border-color: var(--border-secondary) !important; }
.theme-light .border-slate-700\/50 { border-color: var(--border-subtle) !important; }
.theme-light .text-slate-100 { color: var(--text-primary) !important; }
.theme-light .text-slate-200 { color: var(--text-secondary) !important; }
.theme-light .text-slate-300 { color: var(--text-secondary) !important; }
.theme-light .text-slate-400 { color: var(--text-muted) !important; }
.theme-light .text-slate-500 { color: var(--text-faint) !important; }
.theme-light .text-slate-600 { color: var(--text-disabled) !important; }
.theme-light .placeholder-slate-500::placeholder { color: var(--text-faint) !important; }
.theme-light .hover\:bg-slate-800\/50:hover { background-color: var(--bg-hover) !important; }
.theme-light .hover\:text-slate-200:hover { color: var(--text-secondary) !important; }
.theme-light .hover\:text-slate-100:hover { color: var(--text-primary) !important; }
.theme-light .bg-slate-700 { background-color: var(--bg-secondary) !important; }
.theme-light select,
.theme-light input[type="text"] {
    background-color: var(--bg-input) !important;
    border-color: var(--border-secondary) !important;
    color: var(--text-primary) !important;
}

/* ── Foreman Design System — Base Global Styles ──────────── */
/* Applied to the #foreman-app root so they don't conflict with the existing dashboard */

*, *::before, *::after { box-sizing: border-box; }

#foreman-app {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    background: #101114;
    color: #e8e9ea;
    min-height: 100vh;
}

#foreman-app ::selection {
    background: rgba(124, 90, 246, 0.3);
    color: inherit;
}

/* Foreman header bar */
.foreman-header {
    height: 52px;
    background: #101114;
    border-bottom: 1px solid #2a2c32;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 8px;
}

.foreman-header-brand {
    font-size: 14px;
    font-weight: 600;
    color: #e8e9ea;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.foreman-header-version {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    color: #5c5e66;
    background: #18191d;
    border: 1px solid #2a2c32;
    border-radius: 4px;
    padding: 1px 5px;
    letter-spacing: 0.02em;
}

.foreman-header-spacer {
    flex: 1;
}

.foreman-header-settings {
    font-size: 13px;
    color: #9b9ea6;
    text-decoration: none;
}

.foreman-header-settings:hover {
    color: #e8e9ea;
}

/* Foreman content area */
.foreman-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Foreman CSS custom properties — scoped to #foreman-app */
#foreman-app {
    --f-bg:             #101114;
    --f-surface:        #18191d;
    --f-surface-hover:  #1e2025;
    --f-border:         #2a2c32;
    --f-border-subtle:  rgba(42, 44, 50, 0.6);
    --f-text:           #e8e9ea;
    --f-text-secondary: #9899a1;
    --f-text-tertiary:  #5c5e66;
    --f-accent:         #7c5af6;
    --f-green:          #3dd68c;
    --f-yellow:         #f5a623;
    --f-red:            #f25c5c;
    --f-blue:           #4da3ff;
}

/* Pulse animation for working status (reused from existing, scoped for foreman) */
@keyframes foreman-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.foreman-status-dot-pulse {
    animation: foreman-pulse 1.8s ease-in-out infinite;
}

/* Action button spinner */
@keyframes foreman-spin { to { transform: rotate(360deg) } }
.foreman-action-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: foreman-spin 0.6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* Action error toast */
@keyframes foreman-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.foreman-error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1715;
    border: 1px solid #ef4444;
    color: #ede8e3;
    border-radius: 6px;
    padding: 12px 20px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    z-index: 9999;
    max-width: 480px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    animation: foreman-toast-in 0.2s ease;
    white-space: pre-wrap;
    word-break: break-word;
}

