/* ════════════════════════════════════════════════════════════════════
   styles/workspace-sections.css — Components for Flows, Inbox,
   Calendar, Insights, Intelligence, MCP catalog.

   All selectors namespaced under .ws-* — no bleed into other engines.
   Loads after workspace.css, before _overrides.css.
   ════════════════════════════════════════════════════════════════════ */

/* ─── Toggle switch (used for flow enable/disable) ──────────────── */
.ws-toggle {
  position: relative;
  display: inline-block;
  width: 36px; height: 20px;
  flex: 0 0 auto;
  cursor: pointer;
}
.ws-toggle input { opacity: 0; width: 0; height: 0; }
.ws-toggle__track {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  transition: background 160ms ease, border-color 160ms ease;
}
.ws-toggle__track::before {
  content: '';
  position: absolute;
  left: 2px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  transition: left 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ws-toggle input:checked + .ws-toggle__track {
  background: rgba(72, 187, 120, 0.55);
  border-color: rgba(72, 187, 120, 0.70);
}
.ws-toggle input:checked + .ws-toggle__track::before {
  left: 17px;
}

/* ─── Flow cards ────────────────────────────────────────────────── */
.ws-flow-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ws-flow-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ws-flow-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.ws-flow-card__title {
  font: 600 15px/1.3 ui-sans-serif, system-ui;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.96);
  margin: 0 0 4px;
}
.ws-flow-card__trigger {
  font: 400 12.5px/1.5 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.60);
  margin: 0;
}
.ws-flow-card__desc {
  font: 400 13px/1.5 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
}
.ws-flow-card__meta {
  display: flex;
  gap: 8px;
  font: 400 11.5px/1 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.42);
}
.ws-flow-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ─── Run history rows ─────────────────────────────────────────── */
.ws-run-list {
  display: flex;
  flex-direction: column;
  max-height: 360px;
  overflow-y: auto;
}
.ws-run-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font: 400 12.5px/1.3 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.72);
}
.ws-run-row:last-child { border-bottom: 0; }
.ws-run-row__status {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  font: 600 10px/1 ui-sans-serif, system-ui;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ws-run-row__status--success   { background: rgba(72, 187, 120, 0.18); color: #cdf5e0; }
.ws-run-row__status--partial   { background: rgba(245, 158, 11, 0.20); color: #fde68a; }
.ws-run-row__status--failed    { background: rgba(244, 63, 94, 0.20);  color: #fecaca; }
.ws-run-row__status--cancelled { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.55); }
.ws-run-row__status--pending,
.ws-run-row__status--running   { background: rgba(255, 255, 255, 0.10); color: rgba(255, 255, 255, 0.80); }
.ws-run-row__time {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11.5px;
}
.ws-run-row__error {
  flex: 1 1 auto;
  text-align: right;
  color: rgba(254, 202, 202, 0.80);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Inbox messages ────────────────────────────────────────────── */
.ws-inbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-inbox-group {
  font: 600 11px/1 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 6px;
}
.ws-inbox-group:first-child { margin-top: 0; }
.ws-msg-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition: background 140ms ease, border-color 140ms ease;
}
.ws-msg-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
.ws-msg-card--unread {
  border-left: 3px solid rgba(96, 165, 250, 0.65);
  padding-left: 13px;
}
.ws-msg-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.ws-msg-card__icon {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font: 600 11px/1 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.75);
}
.ws-msg-card__from {
  font: 600 13px/1.3 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.92);
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-msg-card__time {
  flex: 0 0 auto;
  font: 400 11.5px/1 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.45);
}
.ws-msg-card__subject {
  font: 500 13px/1.4 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.88);
  margin: 2px 0 4px;
}
.ws-msg-card__snippet {
  font: 400 12.5px/1.5 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ws-msg-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ─── Calendar event cards ──────────────────────────────────────── */
.ws-cal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ws-cal-card {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.ws-cal-card__time {
  font: 600 13px/1.3 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.92);
  padding-top: 2px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding-right: 16px;
}
.ws-cal-card__title {
  font: 600 14px/1.3 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.96);
  margin: 0 0 4px;
}
.ws-cal-card__loc,
.ws-cal-card__att {
  font: 400 12px/1.5 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
}
.ws-cal-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ─── MCP catalog grid ──────────────────────────────────────────── */
.ws-mcp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.ws-mcp-card {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-mcp-card__title {
  font: 600 14px/1.2 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.95);
  margin: 0;
}
.ws-mcp-card__desc {
  font: 400 12.5px/1.5 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
}

/* ─── Template grid (used by Flows + Intelligence) ──────────────── */
.ws-tpl-pack {
  margin-top: 18px;
}
.ws-tpl-pack:first-of-type { margin-top: 4px; }
.ws-tpl-pack__title {
  font: 600 12px/1 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}
.ws-tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.ws-tpl-card {
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 100ms ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ws-tpl-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}
.ws-tpl-card__title {
  font: 600 13px/1.3 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.95);
  margin: 0;
}
.ws-tpl-card__desc {
  font: 400 12px/1.45 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
}
.ws-tpl-card__req {
  font: 500 10.5px/1.3 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.40);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Tag pill ──────────────────────────────────────────────────── */
.ws-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font: 500 10px/1.2 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Generic dialog — PURE LIQUID GLASS ─────────────────────────
   No dark fill. Just a heavy backdrop blur (so the orbs stay visible
   underneath as ambient colour) + a very light white tint + an inner
   highlight for depth. Same language as the rest of the workspace. */

.ws-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  /* Pure liquid glass — no dark dim. The blur + light white frost
     softens the background so the dialog reads clearly without any
     dark fill. Orbs remain visible as ambient colour. */
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(32px) saturate(140%);
  -webkit-backdrop-filter: blur(32px) saturate(140%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: ws-fade-in 200ms ease;
}
@keyframes ws-fade-in { from { opacity: 0; } to { opacity: 1; } }

.ws-dialog {
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 22px;
  /* PURE liquid glass — white-tinted, no dark fill. */
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(48px) saturate(180%);
  -webkit-backdrop-filter: blur(48px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 40px 100px rgba(0, 0, 0, 0.40),
    0 8px 32px rgba(0, 0, 0, 0.24);
}
.ws-dialog__title {
  font: 600 18px/1.25 ui-sans-serif, system-ui;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.96);
  margin: 0 0 4px;
}
.ws-dialog__sub {
  font: 400 13px/1.5 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  margin: 0 0 18px;
}
.ws-dialog__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ─── Form inputs ───────────────────────────────────────────────── */
.ws-form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}
.ws-form-row__label {
  font: 600 12px/1.3 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: -0.005em;
}
.ws-form-row__hint {
  font: 400 11.5px/1.4 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.45);
  margin: 4px 0 0;
}
.ws-input {
  display: block;
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  /* Light-tinted glass input — no dark fill */
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.94);
  font: 400 13.5px/1.4 ui-sans-serif, system-ui;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
  box-sizing: border-box;
}
.ws-input:focus {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}
.ws-input::placeholder { color: rgba(255, 255, 255, 0.35); }
.ws-input--textarea {
  resize: vertical;
  min-height: 90px;
  font-family: ui-sans-serif, system-ui;
}

@media (prefers-reduced-motion: reduce) {
  .ws-dialog-backdrop { animation: none; }
  .ws-tpl-card, .ws-toggle__track, .ws-toggle__track::before { transition: none; }
}
