/* Spark Hub Web: clean, icon-first, flat Operate-mode components using tokens.css. */

/* Ensure untyped inputs inside Hub Web studios, inline bars and dialogs match Spark full-width input tokens */
.studio-panel input:not([type]),
.inline-add input:not([type]),
dialog input:not([type]) {
  width: 100%; height: 38px; padding: 0 11px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.studio-panel input:not([type]):focus,
.inline-add input:not([type]):focus,
dialog input:not([type]):focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}

/* Site switcher bar at top of screens */
.hub-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.hub-bar select { width: auto; min-width: 170px; height: 34px; font-size: .88rem; }
.hub-bar .search { flex: 1 1 200px; max-width: 340px; }
.hub-bar .search input { height: 34px; font-size: .88rem; }

/* Site cards */
.site-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.site-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.site-card-top {
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border-bottom: 1px solid var(--line);
}
.site-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.site-mark {
  width: 40px; height: 40px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; padding: 5px;
}
.site-mark img { max-width: 100%; max-height: 100%; object-fit: contain; }
.site-brand h2 { margin: 0; font-size: 1.05rem; line-height: 1.2; }
.site-brand a { font-size: .82rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.site-brand a:hover { color: var(--accent); }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.kpi-cell {
  padding: 12px 14px; border-right: 1px solid var(--line); text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 2px; transition: background .12s;
}
.kpi-cell:last-child { border-right: 0; }
.kpi-cell:hover { background: var(--surface-2); text-decoration: none; }
.kpi-cell b { font-size: 1.2rem; font-weight: 680; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-cell span { font-size: .75rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: 5px; }

.seo-strip { padding: 14px 20px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.seo-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-2); }
.seo-dot { display: inline-flex; align-items: center; gap: 5px; font-weight: 560; font-variant-numeric: tabular-nums; }
.seo-dot i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.seo-dot.ok i { background: var(--ok); }
.seo-dot.warn i { background: var(--warn); }
.seo-dot.bad i { background: var(--bad); }

.site-card-foot { padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--surface-2); }

/* Toggle switch */
.sw { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; font-weight: 520; user-select: none; }
.sw input { display: none; }
.sw-track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background .15s; flex: none;
}
.sw-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.sw input:checked + .sw-track { background: var(--accent); }
.sw input:checked + .sw-track::after { transform: translateX(16px); }

/* 2-column Studio layout (Content Editor, Form Studio) */
.studio-head {
  position: sticky; top: 0; z-index: 15; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 0 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}
.studio-head-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.studio-head-l h1 { font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }
.studio-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.studio-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* Editor title & WYSIWYG toolbar */
.ed-title {
  width: 100%; border: 0 !important; background: transparent !important; padding: 2px 0 10px !important;
  height: auto !important; min-height: 0 !important; resize: none; line-height: 1.24;
  font-size: 1.48rem; font-weight: 700; letter-spacing: -.022em; color: var(--ink);
  box-shadow: none !important;
}
.ed-bar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.ed-bar button { height: 30px; min-width: 30px; padding: 0 9px; font-size: .82rem; border-color: transparent; background: transparent; }
.ed-bar button:hover { background: var(--surface); border-color: var(--line); }
.ed-bar .sep { width: 1px; background: var(--line); margin: 3px 4px; }
.ed-canvas {
  min-height: 440px; max-height: 68vh; overflow-y: auto; padding: 20px;
  border: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 15px; line-height: 1.68; outline: none;
}
/* Override legacy HubSpot inline black text colors so dark & light modes stay high-contrast */
.ed-canvas * { color: inherit !important; background-color: transparent !important; }
.ed-canvas a { color: var(--accent) !important; text-decoration: underline; }
.ed-canvas h2 { font-size: 1.18rem; line-height: 1.32; font-weight: 660; margin: 18px 0 8px; }
.ed-canvas h3 { font-size: 1.04rem; line-height: 1.35; font-weight: 640; margin: 14px 0 6px; }
.ed-canvas p { font-size: 14.5px; line-height: 1.65; margin: 0 0 12px; }
.ed-canvas img { max-width: 100%; height: auto; border-radius: 6px; margin: 12px 0; }
.ed-source {
  width: 100%; min-height: 440px; font-family: var(--mono); font-size: 13px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); border-top: 1px solid var(--line);
}

/* Google SERP preview */
.serp-box {
  padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
}
.serp-url { font-size: .75rem; color: var(--ok); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serp-title { font-size: .95rem; font-weight: 620; color: var(--info); margin: 2px 0; line-height: 1.3; }
.serp-desc { font-size: .8rem; color: var(--ink-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Post list thumbnail */
.post-row-title { display: flex; align-items: center; gap: 12px; }
.post-thumb {
  width: 48px; height: 34px; border-radius: 6px; object-fit: cover; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
}
.post-thumb-empty {
  width: 48px; height: 34px; border-radius: 6px; flex: none;
  background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-3);
}

/* Media gallery */
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 20px;
  text-align: center; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; }
.media-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
}
.media-tile-img { width: 100%; height: 132px; object-fit: cover; background: var(--surface-2); display: block; }
.media-tile-foot { padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.media-tile-name { min-width: 0; }
.media-tile-name b { display: block; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-tile-name small { display: block; font-size: .72rem; }

/* Live form preview & visual builder rows */
.f-row {
  display: grid; grid-template-columns: 1.1fr .9fr 104px auto auto auto; gap: 6px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.f-row input, .f-row select { height: 32px; font-size: .84rem; }
.link-row {
  display: grid; grid-template-columns: 1fr 1.3fr auto auto; gap: 8px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.link-row input { height: 32px; font-size: .85rem; }

/* Live CTA preview card */
.cta-prev {
  padding: 20px 22px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.cta-prev.dark { background: #16181A; color: #fff; }
.cta-prev.light { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.cta-prev h3 { margin: 0 0 4px; font-size: 1.05rem; }
.cta-prev p { margin: 0; font-size: .86rem; opacity: .82; }
.cta-prev .cta-pill { background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 6px; font-weight: 650; font-size: .84rem; white-space: nowrap; }

/* Workflow visual timeline */
.wf-flow { display: flex; flex-direction: column; gap: 0; }
.wf-node {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.wf-node.trigger { background: var(--surface-2); border-color: var(--line-strong); }
.wf-conn { width: 2px; height: 18px; background: var(--line-strong); margin-left: 24px; }
.wf-badge {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; flex: none;
}

/* Horizontal analytics bar */
.hbar-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 56px; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.hbar-row:last-child { border-bottom: 0; }
.hbar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 4px; }

/* Quick inline redirect bar */
.inline-add {
  display: grid; grid-template-columns: 1.2fr 120px 1.2fr 1fr auto; gap: 8px; align-items: center;
  padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px;
}
.inline-add input, .inline-add select { height: 34px; font-size: .88rem; }

/* Author grid */
.author-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.author-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.author-head { display: flex; align-items: center; gap: 12px; }
.author-ava {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none;
  background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; color: var(--ink-2);
}

/* Prevent badge/URL overflow in CRM Lead Detail + calm collapsed technical metadata */
dl.kv dd, .kv dd { min-width: 0; overflow-wrap: anywhere; }
dl.kv dd .row, .kv dd .row { flex-wrap: wrap; gap: 6px; }
.tech-details {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.tech-details summary {
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.tech-details summary::-webkit-details-marker { display: none; }
.tech-details summary::before { content: "▸"; font-size: 11px; }
.tech-details[open] summary::before { content: "▾"; }
.tech-details[open] summary { margin-bottom: 10px; }

/* Calm Hub Web sub-navigation tabs (5 sidebar items -> crisp single-row horizontal subnav) */
.hub-subnav {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  margin: -8px 0 18px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.hub-subnav::-webkit-scrollbar { display: none; }
.hub-subnav a {
  padding: 9px 13px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; flex: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none;
}
.hub-subnav a:hover { color: var(--ink); }
.hub-subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Contextual AI action bar (single crisp horizontal row) */
.ai-bar {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); margin-bottom: 12px;
}
.ai-bar-lbl {
  font-size: 11.5px; font-weight: 700; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 4px; margin-right: 2px;
}

/* SEO Recommendations Score & List */
.seo-hero {
  display: grid; grid-template-columns: 144px 1fr; gap: 20px; align-items: center;
  padding: 18px 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 18px;
}
.seo-score {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.seo-score b { font-size: 2.1rem; line-height: 1; font-variant-numeric: tabular-nums; }
.seo-score small { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.seo-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seo-chk {
  display: flex; gap: 8px; align-items: flex-start; font-size: 13px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.seo-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.seo-row:last-child { border-bottom: 0; }
.seo-row b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.seo-row small { display: block; font-size: 13px; color: var(--ink-2); }

@media (max-width: 1024px) {
  .studio-grid, .site-grid, .inline-add, .seo-hero, .seo-checks, .seo-row { grid-template-columns: 1fr; }
  .f-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .kpi-cell { border-bottom: 1px solid var(--line); }
}
