/* html-lesson blocks editor — Fluent-like document stream */

:root,
.hlb-root,
.hlb-popover {
  --hlb-chrome: #fafafa;
  --hlb-chrome-2: #f4f4f5;
  --hlb-line: #e4e4e7;
  --hlb-text: #18181b;
  --hlb-muted: #71717a;
  --hlb-accent: #0ea5e9;
  --hlb-accent-hover: #0284c7;
  --hlb-accent-soft: #e0f2fe;
  --hlb-page: #ffffff;
  --hlb-font: "DM Sans", system-ui, -apple-system, sans-serif;
  --hlb-radius: 0.75rem;
  --hlb-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.hlb-root {
  position: fixed;
  inset: 12px;
  z-index: 99990;
  display: none;
  flex-direction: column;
  border: 1px solid #e4e4e7;
  border-radius: var(--hlb-radius);
  background: #fafafa;
  color: #18181b;
  font-family: var(--hlb-font);
  overflow: hidden;
  box-shadow: 0 8px 32px rgb(0 0 0 / 0.12), var(--hlb-shadow);
}

.hlb-root.is-open {
  display: flex;
}

.hlb-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Top bar */
.hlb-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  min-height: 52px;
  background: var(--hlb-page);
  border-bottom: 1px solid var(--hlb-line);
  flex-shrink: 0;
}

.hlb-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hlb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.hlb-brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--hlb-accent);
  flex-shrink: 0;
}

.hlb-status {
  display: none;
  margin: 0;
  font-size: 12px;
  color: var(--hlb-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.hlb-status.is-ok,
.hlb-status.is-err,
.hlb-status.is-info,
.hlb-status.is-dirty {
  display: block;
}

.hlb-status.is-ok { color: #059669; }
.hlb-status.is-err { color: #dc2626; }
.hlb-status.is-info { color: var(--hlb-muted); }
.hlb-status.is-dirty { color: #d97706; }

.hlb-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hlb-btn {
  appearance: none;
  border: 1px solid var(--hlb-line);
  background: var(--hlb-page);
  color: var(--hlb-text);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s;
}

.hlb-btn:hover {
  background: var(--hlb-chrome-2);
  border-color: #d4d4d8;
}

.hlb-btn-primary {
  background: var(--hlb-accent);
  border-color: var(--hlb-accent);
  color: #fff;
}

.hlb-btn-primary:hover {
  background: var(--hlb-accent-hover);
  border-color: var(--hlb-accent-hover);
}

.hlb-btn-primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.hlb-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--hlb-muted);
  font-weight: 500;
}

.hlb-btn-ghost:hover {
  color: var(--hlb-text);
  background: var(--hlb-chrome-2);
}

/* Document stream */
.hlb-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--hlb-chrome-2);
  padding: 24px 16px 48px;
}

.hlb-doc {
  max-width: 720px;
  margin: 0 auto;
}

.hlb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42vh;
  margin: 0;
  color: var(--hlb-muted, #71717a);
  font: 500 14px/1.4 "DM Sans", system-ui, sans-serif;
}

.hlb-loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0ea5e9;
  animation: hlb-pulse 0.9s ease-in-out infinite;
}

@keyframes hlb-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.hlb-empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--hlb-muted);
  font-size: 15px;
  line-height: 1.5;
}

.hlb-empty strong {
  display: block;
  color: var(--hlb-text);
  font-size: 17px;
  margin-bottom: 8px;
}

/* Block inserter between cards */
.hlb-inserter {
  display: flex;
  justify-content: center;
  padding: 6px 0;
  opacity: 1;
}

.hlb-inserter-btn {
  appearance: none;
  border: 1px dashed #d4d4d8;
  background: var(--hlb-page);
  color: var(--hlb-muted);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.hlb-inserter-btn:hover {
  border-color: var(--hlb-accent);
  color: var(--hlb-accent);
  box-shadow: 0 0 0 3px rgb(14 165 233 / 0.15);
}

/* Block cards */
.hlb-block {
  background: var(--hlb-page);
  border: 1px solid var(--hlb-line);
  border-radius: var(--hlb-radius);
  box-shadow: var(--hlb-shadow);
  margin: 0;
  transition: box-shadow 0.12s, border-color 0.12s;
}

.hlb-block.is-dragging {
  opacity: 0.45;
}

.hlb-block.is-drop-target {
  border-color: var(--hlb-accent);
  box-shadow: 0 0 0 3px rgb(14 165 233 / 0.15);
}

.hlb-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #f4f4f5;
  background: #fafafa;
  border-radius: var(--hlb-radius) var(--hlb-radius) 0 0;
}

.hlb-drag {
  appearance: none;
  border: 0;
  background: transparent;
  color: #a1a1aa;
  cursor: grab;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
  touch-action: none;
}

.hlb-drag:active {
  cursor: grabbing;
}

.hlb-drag:hover {
  background: var(--hlb-chrome-2);
  color: var(--hlb-muted);
}

.hlb-type-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hlb-muted);
  flex: 1;
}

.hlb-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
}

.hlb-icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--hlb-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.hlb-icon-btn:hover {
  background: var(--hlb-chrome-2);
  color: var(--hlb-text);
}

.hlb-block-body {
  padding: 14px 16px 16px;
}

/* Fields */
.hlb-field {
  width: 100%;
  border: 1px solid var(--hlb-line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  color: var(--hlb-text);
  background: var(--hlb-page);
  outline: none;
  resize: vertical;
}

.hlb-field:focus {
  border-color: var(--hlb-accent);
  box-shadow: 0 0 0 3px rgb(14 165 233 / 0.15);
}

.hlb-field-sm {
  font-size: 13px;
  padding: 8px 10px;
}

.hlb-editable {
  min-height: 1.5em;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.hlb-editable:empty::before {
  content: attr(data-placeholder);
  color: #a1a1aa;
  pointer-events: none;
}

.hlb-editable.is-slash::before {
  content: none;
}

.hlb-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.hlb-row:last-child {
  margin-bottom: 0;
}

.hlb-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #3f3f46;
  margin: 0 0 6px;
}

.hlb-sep {
  border: 0;
  border-top: 1px solid var(--hlb-line);
  margin: 0;
}

.hlb-heading-preview {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--hlb-text);
}

.hlb-heading-preview[data-level="1"] { font-size: 1.75rem; }
.hlb-heading-preview[data-level="2"] { font-size: 1.45rem; }
.hlb-heading-preview[data-level="3"] { font-size: 1.2rem; }
.hlb-heading-preview[data-level="4"] { font-size: 1.05rem; }

/* Inserter popover (vive em document.body — cores literais, não só vars) */
.hlb-popover {
  position: fixed;
  z-index: 100000;
  min-width: 240px;
  max-width: 300px;
  max-height: 360px;
  overflow-y: auto;
  background: #ffffff;
  color: #18181b;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.18);
  padding: 6px;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
}

.hlb-popover-title {
  margin: 4px 8px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #71717a;
}

.hlb-pop-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  font-family: inherit;
  color: #18181b;
}

.hlb-pop-item:hover,
.hlb-pop-item.is-active {
  background: #e0f2fe;
}

.hlb-pop-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #18181b;
}

.hlb-pop-copy {
  display: block;
  min-width: 0;
}

.hlb-pop-item .hlb-pop-copy > span {
  display: block;
  font-size: 11px;
  color: #71717a;
  margin-top: 1px;
}

.hlb-pop-ico {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f4f4f5;
  color: #3f3f46;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hlb-pop-ico .hlb-pop-svg {
  display: block;
  width: 16px;
  height: 16px;
}

.hlb-pop-ico.tone-slate { background: #f4f4f5; color: #3f3f46; }
.hlb-pop-ico.tone-sky { background: #e0f2fe; color: #0284c7; }
.hlb-pop-ico.tone-zinc { background: #f4f4f5; color: #52525b; }
.hlb-pop-ico.tone-rose { background: #ffe4e6; color: #e11d48; }
.hlb-pop-ico.tone-violet { background: #ede9fe; color: #7c3aed; }
.hlb-pop-ico.tone-amber { background: #fef3c7; color: #d97706; }
.hlb-pop-ico.tone-emerald { background: #d1fae5; color: #059669; }
.hlb-pop-ico.tone-orange { background: #ffedd5; color: #ea580c; }
.hlb-pop-ico.tone-indigo { background: #e0e7ff; color: #4f46e5; }
.hlb-pop-ico.tone-teal { background: #ccfbf1; color: #0d9488; }

.hlb-pop-item:hover .hlb-pop-ico {
  filter: saturate(1.05);
}

/* CTA "Abrir Editor" abaixo do select de tipo */
.hlb-reopen-chip {
  display: none !important;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  padding: 11px 14px;
  border: 1px solid #3f3f46;
  border-radius: 10px;
  background: #fafafa;
  color: #18181b;
  font: 600 13px/1.3 "DM Sans", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

.hlb-reopen-chip.is-visible {
  display: inline-flex !important;
}

.hlb-reopen-chip:hover {
  border-color: #0ea5e9;
  color: #0369a1;
  background: #fff;
}

@media (prefers-color-scheme: dark) {
  .hlb-reopen-chip {
    background: #27272a;
    color: #fafafa;
    border-color: #52525b;
  }
  .hlb-reopen-chip:hover {
    background: #3f3f46;
    color: #7dd3fc;
    border-color: #0ea5e9;
  }
}

/* Member builder Getfy usa dark: via classe no html */
.dark .hlb-reopen-chip,
html.dark .hlb-reopen-chip {
  background: #27272a;
  color: #fafafa;
  border-color: #52525b;
}
.dark .hlb-reopen-chip:hover,
html.dark .hlb-reopen-chip:hover {
  background: #3f3f46;
  color: #7dd3fc;
  border-color: #0ea5e9;
}

.hlb-btn-close {
  appearance: none;
  border: 1px solid #e4e4e7;
  background: #fff;
  color: #52525b;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hlb-btn-close:hover {
  background: #f4f4f5;
  color: #18181b;
}

/* Video picker (Fluent hub) */
.hlb-vpicker {
  border: 1px solid var(--hlb-line);
  border-radius: 12px;
  background: var(--hlb-page);
  padding: 24px 20px 20px;
  box-shadow: var(--hlb-shadow);
}

.hlb-vpicker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.hlb-vpicker-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hlb-vpicker-ico svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.hlb-vpicker-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--hlb-text);
}

.hlb-vpicker-sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--hlb-muted);
  line-height: 1.45;
}

.hlb-vpicker-srcs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.hlb-vpicker-src {
  appearance: none;
  border: 1px solid var(--hlb-line);
  background: var(--hlb-chrome);
  color: var(--hlb-text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hlb-vpicker-src:hover {
  background: var(--hlb-page);
  border-color: #a1a1aa;
}

.hlb-vpicker-src.is-active {
  border-color: var(--hlb-accent);
  box-shadow: 0 0 0 3px rgb(14 165 233 / 0.15);
  color: #0369a1;
}

.hlb-vpicker-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: #a1a1aa;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hlb-vpicker-or::before,
.hlb-vpicker-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hlb-line);
}

.hlb-vpicker-row {
  display: flex;
  gap: 8px;
}

.hlb-vpicker-row input {
  flex: 1;
  min-width: 0;
}

.hlb-vpicker-go {
  appearance: none;
  border: 0;
  background: #0f172a;
  color: #fff;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.hlb-vpicker-go:hover {
  background: #1e293b;
}

.hlb-vpicker-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: #a1a1aa;
}

.hlb-vpicker-recent {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f4f4f5;
}

.hlb-vpicker-recent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.hlb-vpicker-recent-item {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid #f4f4f5;
  background: var(--hlb-chrome);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
}

.hlb-vpicker-recent-item:hover {
  border-color: var(--hlb-line);
  background: var(--hlb-page);
}

.hlb-vpicker-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
}

.hlb-vpicker-badge.yt { background: #ff0000; }
.hlb-vpicker-badge.vm { background: #1ab7ea; }
.hlb-vpicker-badge.file { background: #52525b; }

.hlb-vpicker-recent-meta {
  min-width: 0;
  flex: 1;
}

.hlb-vpicker-recent-meta strong,
.hlb-vpicker-recent-meta span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hlb-vpicker-recent-meta strong {
  font-size: 12px;
  color: var(--hlb-text);
}

.hlb-vpicker-recent-meta span {
  font-size: 11px;
  color: #a1a1aa;
}

/* Video player embed */
.hlb-vplay-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.hlb-vplay-bar strong {
  font-size: 13px;
}

.hlb-vplay-frame {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  background: #0a0a0a;
  border: 1px solid var(--hlb-line);
  border-radius: 12px;
}

.hlb-vplay-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* HTML page block */
.hlb-html-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.hlb-html-preview {
  margin-top: 12px;
  border: 1px solid var(--hlb-line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.hlb-html-preview iframe {
  display: block;
  width: 100%;
  min-height: 280px;
  border: 0;
  background: #fff;
}

.hlb-html-code {
  min-height: 160px;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
  line-height: 1.45;
}

/* Image */
.hlb-img-preview {
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--hlb-line);
  background: var(--hlb-chrome-2);
}

.hlb-img-preview img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Embed */
.hlb-embed-frame {
  margin-top: 10px;
  border: 1px solid var(--hlb-line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 200px;
}

.hlb-embed-frame iframe {
  display: block;
  width: 100%;
  min-height: 200px;
  border: 0;
}

.hlb-note {
  font-size: 12px;
  color: var(--hlb-muted);
  margin: 8px 0 0;
}

/* Rich / legacy */
.hlb-rich-note {
  padding: 10px 12px;
  background: var(--hlb-accent-soft);
  border-radius: 8px;
  font-size: 13px;
  color: #0369a1;
  margin-bottom: 10px;
}

.hlb-rich-preview {
  border: 1px solid var(--hlb-line);
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow: auto;
  font-size: 14px;
  margin-bottom: 10px;
}

.hlb-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--hlb-muted);
  cursor: pointer;
  user-select: none;
}

.hlb-check input {
  accent-color: var(--hlb-accent);
}

/* Mobile */
@media (max-width: 640px) {
  .hlb-root {
    inset: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .hlb-topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    min-height: auto;
  }

  .hlb-topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .hlb-main {
    padding: 16px 10px 32px;
  }

  .hlb-vpicker-row {
    flex-direction: column;
  }

  .hlb-vpicker-go {
    padding: 10px 16px;
  }
}
