/* ==========================================================================
   ARTIVORALABS — Dashboard (dark chrome / light content cards)
   ========================================================================== */
body.dash-body { background: var(--paper-alt); }

.dash-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.dash-side { background: var(--navy-deep); color: var(--paper-on-navy); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.dash-side-brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-6); height: var(--nav-h); font-family: var(--f-display); font-weight: 700; font-size: 1.0625rem; border-bottom: 1px solid var(--navy-line); }
.dash-side-brand svg { width: 24px; height: 24px; flex-shrink: 0; }
.dash-nav { flex: 1; padding: var(--sp-5) var(--sp-4); overflow-y: auto; }
.dash-nav-label { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--paper-on-navy-40); padding: var(--sp-5) var(--sp-3) var(--sp-2); }
.dash-nav-link { display: flex; align-items: center; gap: 12px; padding: 11px var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--paper-on-navy-60); margin-bottom: 2px; transition: background var(--t-fast), color var(--t-fast); min-height: 42px; }
.dash-nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.dash-nav-link:hover { background: var(--navy-raised); color: var(--paper-on-navy); }
.dash-nav-link.active { background: var(--signal-20); color: var(--signal-bright); box-shadow: inset 2px 0 0 var(--signal-bright); }
.dash-nav-link .badge { margin-left: auto; font-family: var(--f-mono); font-size: 10px; background: var(--navy-raised); padding: 1px 7px; border-radius: var(--r-full); color: var(--paper-on-navy-60); }
.dash-side-foot { padding: var(--sp-4); border-top: 1px solid var(--navy-line); display: flex; align-items: center; gap: 10px; }
.dash-side-user { width: 32px; height: 32px; border-radius: 50%; background: var(--signal); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.dash-side-user-info p { font-size: var(--fs-xs); font-weight: 600; }
.dash-side-user-info span { font-size: 11px; color: var(--paper-on-navy-40); }

/* ── Main column ───────────────────────────────────────────────────────── */
.dash-main { min-width: 0; }
.dash-topbar { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sp-8); height: var(--nav-h); gap: var(--sp-5); box-shadow: 0 1px 0 rgba(0,0,0,0.25), var(--shadow-sm); }
.dash-search { display: flex; align-items: center; gap: 10px; background: var(--paper-soft); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 16px; width: min(420px, 42vw); color: var(--ink-30); }
.dash-search input { background: none; border: none; outline: none; font-size: var(--fs-sm); width: 100%; color: var(--ink); }
.dash-search kbd { font-family: var(--f-mono); font-size: 10px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; color: var(--ink-30); }
.dash-top-actions { display: flex; align-items: center; gap: var(--sp-3); }
.dash-icon-btn { width: 36px; height: 36px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; color: var(--ink-50); position: relative; }
.dash-icon-btn:hover { background: var(--paper-soft); color: var(--ink); }
.dash-icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 1.5px solid var(--paper); }
.dash-sidebar-toggle { display: none; }

.dash-content { padding: var(--sp-8) var(--sp-8) var(--sp-12); max-width: 1440px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: var(--sp-8); flex-wrap: wrap; gap: var(--sp-4); }
.dash-head h1 { font-size: var(--fs-2xl); letter-spacing: -0.03em; }
.dash-head p { color: var(--ink-50); font-size: var(--fs-sm); margin-top: 4px; }

/* ── KPI cards ─────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-5); margin-bottom: var(--sp-8); }
.kpi-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-6); min-height: 148px; display: flex; flex-direction: column; transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); border-color: var(--line-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.kpi-label { font-size: var(--fs-xs); color: var(--ink-50); font-weight: 600; }
.kpi-icon { width: 28px; height: 28px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; }
.kpi-val { font-family: var(--f-display); font-size: var(--fs-2xl); font-weight: 700; }
.kpi-delta { font-family: var(--f-mono); font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--signal); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.neutral { color: var(--ink-50); }
.kpi-card.c-signal .kpi-icon { background: var(--signal-10); color: var(--signal); }
.kpi-card.c-beacon .kpi-icon { background: var(--beacon-10); color: var(--beacon); }
.kpi-card.c-ink .kpi-icon { background: var(--paper-soft); color: var(--ink); }
.kpi-card.c-danger .kpi-icon { background: var(--danger-10); color: var(--danger); }

/* ── Panel grid ────────────────────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--sp-5); margin-bottom: var(--sp-5); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-6); transition: box-shadow var(--t-base), border-color var(--t-base); }
.panel:hover { box-shadow: var(--shadow-sm); border-color: var(--line-strong); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); }
.panel-head h3 { font-size: var(--fs-md); }
.panel-head .tag { cursor: pointer; }
.chart-wrap { height: 300px; position: relative; }

.activity-list { display: flex; flex-direction: column; }
.activity-row { display: flex; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: none; padding-bottom: 0; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.activity-row.type-commit .activity-dot { background: var(--signal); }
.activity-row.type-pr .activity-dot { background: var(--beacon); }
.activity-row.type-alert .activity-dot { background: var(--danger); }
.activity-row.type-issue .activity-dot { background: var(--beacon); }
.activity-row.type-deploy .activity-dot { background: var(--ink-50); }
.lang-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex-shrink: 0; }
.lang-cell { display: flex; align-items: center; font-size: var(--fs-sm); color: var(--ink-70); }
.activity-body p { font-size: var(--fs-sm); line-height: 1.4; }
.activity-body span { font-size: 11px; color: var(--ink-30); font-family: var(--f-mono); }

/* ── Table ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.dash-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.dash-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-30); font-weight: 600; padding: 0 var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--line); }
.dash-table td { padding: var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table tr:hover td { background: var(--paper-soft); }
.proj-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.proj-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-pill { font-size: 11px; padding: 3px 9px; border-radius: var(--r-full); font-weight: 600; }
.status-pill.active { background: var(--signal-10); color: var(--signal); }
.status-pill.review { background: var(--beacon-10); color: var(--beacon); }
.status-pill.blocked { background: var(--danger-10); color: var(--danger); }
.progress-track { width: 90px; height: 5px; border-radius: var(--r-full); background: var(--paper-alt); overflow: hidden; }
.progress-fill { height: 100%; background: var(--signal); border-radius: var(--r-full); }
.avatar-stack { display: flex; }
.avatar-stack .av { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--paper); display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #fff; margin-left: -8px; }
.avatar-stack .av:first-child { margin-left: 0; }

/* ── GitHub connect control ───────────────────────────────────────────── */
.gh-connect { display: flex; align-items: center; gap: 8px; position: relative; }
.gh-connect-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-30); flex-shrink: 0; }
.gh-connect-dot.live { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-10); }

/* ── Projects table: source badge + row actions ───────────────────────── */
.source-badge { font-family: var(--f-mono); font-size: 10px; padding: 2px 7px; border-radius: var(--r-full); background: var(--paper-soft); color: var(--ink-30); border: 1px solid var(--line); margin-left: 8px; vertical-align: middle; }
.source-badge.custom { background: var(--beacon-10); color: var(--beacon); border-color: transparent; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions button { width: 28px; height: 28px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; color: var(--ink-30); }
.row-actions button:hover { background: var(--paper-soft); color: var(--ink); }
.row-actions button.danger:hover { color: var(--danger); background: var(--danger-10); }
.dash-table td.actions-cell { text-align: right; }
.table-empty { text-align: center; padding: var(--sp-8) 0; color: var(--ink-30); font-size: var(--fs-sm); }
.proj-name a { color: inherit; }
.proj-name a:hover { color: var(--signal); }
.search-hidden { display: none !important; }

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .dash-shell { grid-template-columns: 1fr; }
  .dash-side { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 300; transform: translateX(-100%); transition: transform var(--t-base); }
  .dash-side.open { transform: translateX(0); }
  .dash-sidebar-toggle { display: flex; }
  .dash-search { width: 180px; }
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Large / wide-screen scaling ───────────────────────────────────────
   .dash-content was hard-capped at 1440px, which leaves large amounts of
   dead space on wide monitors and ultrawides. These breakpoints let the
   workspace use the extra width instead of floating in a narrow column,
   while keeping the same card sizes so nothing feels stretched or thin. */
@media (min-width: 1600px) {
  .dash-content { max-width: 1680px; padding-left: var(--sp-12); padding-right: var(--sp-12); }
  .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 1920px) {
  .dash-content { max-width: 1920px; }
  .dash-grid { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr); }
}
@media (min-width: 2200px) {
  .dash-content { max-width: 2160px; }
}

/* ── Create-dashboard role picker (modal) ─────────────────────────────── */
.role-pick { display: flex; flex-direction: column; gap: var(--sp-2); }
.role-option { display: flex; align-items: flex-start; gap: 10px; padding: var(--sp-3); border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast); }
.role-option:hover { background: var(--paper-soft); }
.role-option input { margin-top: 3px; flex-shrink: 0; }
.role-option:has(input:checked) { border-color: var(--signal); background: var(--signal-10); }
.role-option span { display: flex; flex-direction: column; gap: 2px; }
.role-option strong { font-size: var(--fs-sm); }
.role-option small { font-size: var(--fs-xs); color: var(--ink-50); }

/* ── Generated dashboard body ─────────────────────────────────────────── */
.built-dash-section { margin-bottom: var(--sp-5); }
.built-dash-section:last-child { margin-bottom: 0; }
.built-dash-section h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-50); margin-bottom: var(--sp-3); }
.chart-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-5); position: relative; height: 260px; }
.built-dash-note { font-size: var(--fs-xs); color: var(--ink-30); margin-top: var(--sp-2); }

/* ── Saved dashboards grid ────────────────────────────────────────────── */
.saved-dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-3); }
.saved-dash-card { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--sp-4); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.saved-dash-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.saved-dash-card h4 { font-size: var(--fs-sm); margin-bottom: 4px; }
.saved-dash-card .tag { margin-bottom: var(--sp-3); }
.saved-dash-card-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }

/* ── Print (Export as PDF uses the browser's print-to-PDF) ───────────── */
@media print {
  body.dash-body * { visibility: hidden; }
  #builtDashboardPanel, #builtDashboardPanel * { visibility: visible; }
  #builtDashboardPanel { position: absolute; left: 0; top: 0; width: 100%; border: none; box-shadow: none; }
  #builtDashboardPanel [data-no-print="true"] { display: none !important; }
}
