/* WORKSPACE-WAVE2 (2026-07-03 momentum-engineer)
   Styles for the Mission Control wave-2 sub-views (Journal / Knowledge /
   Automations / Reports) rendered by workspace.js. Sits on top of the
   product token set (styles.css :root) and reuses mission.css primitives
   (mv-card, mv-kpi, mv-bucket, mv-table, mv-pill). Everything new here is
   namespaced ws- so it cannot collide with app.js, crm.css, mission.css,
   or workflows.js surfaces. */

/* ── toolbar ─────────────────────────────────────────────── */
.ws-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.ws-toolbar-spacer { flex: 1; }

/* ── buttons ─────────────────────────────────────────────── */
.ws-btn {
  appearance: none; cursor: pointer;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-body); font-size: 11px;
  padding: 6px 12px;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.ws-btn:hover { color: var(--text); border-color: var(--border-md); background: var(--panel-2); }
.ws-btn.primary {
  color: var(--accent); border-color: var(--accent-border); background: var(--accent-lo);
}
.ws-btn.primary:hover { background: rgba(110,139,255,0.18); }
.ws-btn.danger { color: var(--red); border-color: rgba(240,112,112,0.3); }
.ws-btn.danger:hover { background: rgba(240,112,112,0.08); border-color: rgba(240,112,112,0.45); }
.ws-btn.ws-iconbtn { padding: 5px 10px; font-size: 13px; line-height: 1; }
.ws-btn.ws-mini { padding: 4px 9px; font-size: 10px; }
.ws-btn:disabled { opacity: 0.5; cursor: default; }

/* ── form fields ─────────────────────────────────────────── */
.ws-field {
  appearance: none;
  background: rgba(0,0,0,0.3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-body); font-size: 12px;
  padding: 8px 10px;
  width: 100%;
  transition: border-color var(--transition);
}
.ws-field:focus { outline: none; border-color: var(--accent-border); }
.ws-field::placeholder { color: var(--text-muted); }
.ws-textarea { resize: vertical; line-height: 1.55; min-height: 60px; }
.ws-mdinput { font-family: var(--font-mono); font-size: 11px; }
.ws-select { cursor: pointer; }
.ws-search { max-width: 340px; }
.ws-date { max-width: 160px; }
.ws-fgroup { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ws-fgroup.grow { flex: 1; }
.ws-flabel {
  font-family: var(--font-display);
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-dim);
}
.ws-form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ws-form-row .ws-fgroup { flex: 1; min-width: 180px; }

/* ── coming-online / error states ────────────────────────── */
.ws-coming, .ws-error {
  text-align: center;
  padding: 48px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.ws-error { border-color: rgba(240,112,112,0.25); }
.ws-coming-glyph {
  font-size: 30px; line-height: 1; color: var(--accent);
  opacity: 0.7;
  animation: ws-breathe 2.4s ease-in-out infinite;
}
@keyframes ws-breathe { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.85; } }
@media (prefers-reduced-motion: reduce) { .ws-coming-glyph { animation: none; } }
.ws-coming-title {
  font-family: var(--font-display); font-size: 15px; font-weight: 700;
  color: var(--text);
}
.ws-coming-sub {
  font-size: 11px; color: var(--text-muted); line-height: 1.6; max-width: 440px;
}
.ws-notice {
  font-size: 11px; color: var(--text-dim);
  background: var(--accent-lo); border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px; margin-bottom: 12px;
}

/* ── markdown preview ────────────────────────────────────── */
.ws-md-preview {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  min-height: 120px; max-height: 420px; overflow-y: auto;
  font-size: 12px; line-height: 1.65; color: var(--text-dim);
  word-break: break-word;
}
.ws-md-preview h1, .ws-md-preview h2, .ws-md-preview h3, .ws-md-preview h4 {
  font-family: var(--font-display); color: var(--text);
  margin: 12px 0 6px; line-height: 1.3;
}
.ws-md-preview h1:first-child, .ws-md-preview h2:first-child,
.ws-md-preview h3:first-child, .ws-md-preview p:first-child { margin-top: 0; }
.ws-md-preview h1 { font-size: 17px; }
.ws-md-preview h2 { font-size: 15px; }
.ws-md-preview h3 { font-size: 13px; }
.ws-md-preview p { margin: 6px 0; }
.ws-md-preview a { color: var(--accent); text-decoration: none; }
.ws-md-preview a:hover { text-decoration: underline; }
.ws-md-preview code {
  font-family: var(--font-mono); font-size: 10.5px;
  background: rgba(255,255,255,0.06); border-radius: 3px; padding: 1px 5px;
}
.ws-md-preview pre {
  background: rgba(0,0,0,0.35); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 8px 0;
}
.ws-md-preview pre code { background: transparent; padding: 0; }
.ws-md-preview ul, .ws-md-preview ol { padding-left: 20px; margin: 6px 0; }
.ws-md-preview li { margin: 3px 0; }
.ws-md-preview blockquote {
  margin: 8px 0; padding: 4px 12px;
  border-left: 2px solid var(--accent-border);
  color: var(--text-muted);
}
.ws-md-preview table { border-collapse: collapse; margin: 8px 0; }
.ws-md-preview th, .ws-md-preview td {
  border: 1px solid var(--border); padding: 5px 9px; font-size: 11px;
}
.ws-md-preview img { max-width: 100%; border-radius: 6px; }
.ws-md-preview hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.ws-preview-empty { color: var(--text-muted); font-size: 11px; padding: 8px 0; }
.ws-preview-plain {
  margin: 0; font-family: var(--font-mono); font-size: 11px;
  white-space: pre-wrap; word-break: break-word; color: var(--text-dim);
}

/* ── JOURNAL ─────────────────────────────────────────────── */
.ws-monthnav { display: flex; align-items: center; gap: 8px; }
.ws-month-label {
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  color: var(--text); min-width: 132px; text-align: center;
}
.ws-journal-shell {
  display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
.ws-entry-list { padding: 10px; max-height: 640px; overflow-y: auto; }
.ws-list-cap {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.5px;
  color: var(--text-muted); padding: 4px 8px 10px;
}
.ws-entry-row {
  padding: 9px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.ws-entry-row:hover { background: var(--panel-2); }
.ws-entry-row.active { background: var(--accent-lo); border-color: var(--accent-border); }
.ws-entry-row:focus-visible { outline: 1px solid var(--accent-border); }
.ws-entry-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ws-entry-date {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.5px;
  color: var(--accent);
}
.ws-entry-tagcount { font-family: var(--font-mono); font-size: 8px; color: var(--text-muted); }
.ws-entry-title {
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
  color: var(--text); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-entry-excerpt {
  font-size: 10px; color: var(--text-muted); margin-top: 2px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.ws-editor { display: flex; flex-direction: column; gap: 12px; }
.ws-editor-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 56px 20px; text-align: center;
}
.ws-editor-meta { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.ws-editor-split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch;
}
.ws-write-col, .ws-preview-col { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ws-write-col .ws-textarea { flex: 1; }
.ws-editor-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ws-action-status { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── KNOWLEDGE ───────────────────────────────────────────── */
.ws-k-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.ws-k-grid > .mv-empty { grid-column: 1 / -1; }
.ws-k-card {
  cursor: pointer; display: flex; flex-direction: column; gap: 8px;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.ws-k-card:hover { background: var(--panel-2); border-color: var(--border-md); transform: translateY(-1px); }
.ws-k-card:focus-visible { outline: 1px solid var(--accent-border); }
.ws-k-title {
  font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--text);
  line-height: 1.35;
}
.ws-k-excerpt { font-size: 11px; color: var(--text-muted); line-height: 1.55; flex: 1; }
.ws-k-foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ws-k-updated {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 8px; color: var(--text-muted);
}

/* drawer */
.ws-drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 6, 0.55);
  backdrop-filter: blur(2px);
}
.ws-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(480px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--border-md);
  box-shadow: -18px 0 50px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  animation: ws-drawer-in 0.22s ease;
}
@keyframes ws-drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ws-drawer { animation: none; } }
.ws-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.ws-drawer-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--text); }
.ws-drawer-body {
  flex: 1; overflow-y: auto; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.ws-drawer-body .ws-md-preview { max-height: 260px; }
.ws-drawer-foot {
  display: flex; gap: 8px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--border);
}

/* ── AUTOMATIONS ─────────────────────────────────────────── */
.ws-auto-form { margin-bottom: 14px; }
.ws-toggle {
  appearance: none; position: relative; cursor: pointer;
  width: 34px; height: 18px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 0;
  transition: background var(--transition), border-color var(--transition);
}
.ws-toggle::after {
  content: ''; position: absolute; top: 1px; left: 1px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-muted);
  transition: left 0.18s ease, background 0.18s ease;
}
.ws-toggle.on { background: var(--accent-lo); border-color: var(--accent-border); }
.ws-toggle.on::after { left: 17px; background: var(--accent); box-shadow: 0 0 8px rgba(110,139,255,0.5); }
.ws-toggle.busy { opacity: 0.5; cursor: wait; }
.ws-row-disabled td { opacity: 0.55; }
.ws-row-busy td { opacity: 0.6; }
.ws-lastrun { display: flex; align-items: center; gap: 8px; }
.ws-lastrun-ago { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); white-space: nowrap; }
.ws-row-actions { white-space: nowrap; }
.ws-row-actions .ws-btn { margin-right: 6px; }

/* ── DASHBOARD-EXTRA-V1: Org Chart ──────────────────────────── */
.org-tree { display: flex; flex-direction: column; align-items: center; padding: 20px 0 8px; }
.org-owner-wrap { display: flex; justify-content: center; margin-bottom: 4px; }
.org-connector { width: 1px; height: 22px; background: var(--border-md); }
.org-agent-row {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 14px;
  margin-top: 4px; max-width: 1000px;
}
.org-node { width: 210px; padding: 14px; }
.org-node.org-owner { width: 240px; border-color: var(--accent-border); background: linear-gradient(135deg, var(--accent-lo), var(--panel)); }
.org-node-top { display: flex; align-items: center; gap: 10px; }
.org-node-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border-md);
}
.org-node-avatar.owner { background: var(--accent-lo); border-color: var(--accent-border); color: var(--accent); }
.org-node-info { min-width: 0; }
.org-node-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-node-role { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.org-node-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 980px) {
  .ws-journal-shell { grid-template-columns: 1fr; }
  .ws-entry-list { max-height: 300px; }
  .ws-editor-split { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .ws-search { max-width: none; }
  .ws-form-row { flex-direction: column; }
  .ws-drawer { width: 100vw; }
}
