/* RBytes DocPad Online — temas claro/escuro (sistema, ou fixo por data-theme), layout de editor desktop. */
:root {
  --bg: #f3f4f6; --surface: #ffffff; --toolbar: #f8f9fa; --border: #e1e3e6; --fg: #1f2328; --muted: #6b7280;
  --accent: #2563eb; --accent-fg: #ffffff; --accent-soft: rgba(37, 99, 235, .12); --hover: rgba(0, 0, 0, .06);
  --status: #1d4ed8; --status-fg: #ffffff; --ok: #dcfce7; --ok-fg: #14532d; --err: #fee2e2; --err-fg: #7f1d1d;
  --warn: #fef3c7; --warn-fg: #78350f; --info: #dbeafe; --info-fg: #1e3a8a;
  --tk-c: #6a737d; --tk-s: #a31515; --tk-n: #098658; --tk-k: #0000cc; --tk-t: #800000; --tk-a: #e45649; --tk-x: #7c3aed;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, "JetBrains Mono", "DejaVu Sans Mono", monospace;
  --ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18181b; --surface: #1e1e1e; --toolbar: #232327; --border: #3a3a40; --fg: #e6e6e6; --muted: #9ca3af;
    --accent: #3b82f6; --accent-soft: rgba(59, 130, 246, .2); --hover: rgba(255, 255, 255, .08); --status: #1e3a8a; --status-fg: #f1f5f9;
    --ok: #1f4d2c; --ok-fg: #dcfce7; --err: #5a1f1f; --err-fg: #fee2e2; --warn: #4d3a12; --warn-fg: #fef3c7; --info: #1e3a5f; --info-fg: #dbeafe;
    --tk-c: #6a9955; --tk-s: #ce9178; --tk-n: #b5cea8; --tk-k: #569cd6; --tk-t: #4ec9b0; --tk-a: #9cdcfe; --tk-x: #c586c0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18181b; --surface: #1e1e1e; --toolbar: #232327; --border: #3a3a40; --fg: #e6e6e6; --muted: #9ca3af;
  --accent: #3b82f6; --accent-soft: rgba(59, 130, 246, .2); --hover: rgba(255, 255, 255, .08); --status: #1e3a8a; --status-fg: #f1f5f9;
  --ok: #1f4d2c; --ok-fg: #dcfce7; --err: #5a1f1f; --err-fg: #fee2e2; --warn: #4d3a12; --warn-fg: #fef3c7; --info: #1e3a5f; --info-fg: #dbeafe;
  --tk-c: #6a9955; --tk-s: #ce9178; --tk-n: #b5cea8; --tk-k: #569cd6; --tk-t: #4ec9b0; --tk-a: #9cdcfe; --tk-x: #c586c0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--ui); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 5px 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover:not(:disabled), .button:hover { background: var(--hover); }
button:disabled { opacity: .45; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="text"], input[type="number"], select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 5px 8px; min-width: 0;
}
.mono, textarea.mono, input.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }

/* Tela de carregamento estática (conteúdo para buscadores). */
.boot { max-width: 680px; margin: 10vh auto; padding: 0 20px; text-align: center; }
.boot h1 { font-size: 28px; margin: 12px 0; }
.boot-progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin: 24px auto; max-width: 260px; }
.boot-progress span { display: block; height: 100%; width: calc(var(--blazor-load-percentage, 10%)); background: var(--accent); transition: width .2s; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 16px; background: var(--err); color: var(--err-fg); z-index: 1000; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* Estrutura */
.app { display: grid; grid-template-rows: auto auto 1fr auto; height: 100vh; height: 100dvh; }
/* Linhas fixas: sem abas abertas, a barra de abas some e as demais áreas não podem mudar de linha. */
.app > .topbar { grid-row: 1; } .app > .tabs { grid-row: 2; } .app > .workspace { grid-row: 3; } .app > .statusbar { grid-row: 4; }
.topbar { display: flex; align-items: center; gap: 8px; background: var(--toolbar); border-bottom: 1px solid var(--border); padding: 0 10px; min-height: 36px; }
.brand { display: flex; align-items: center; gap: 6px; color: var(--fg); text-decoration: none; font-weight: 600; white-space: nowrap; margin-right: 6px; }
.brand em { font-style: normal; color: var(--accent); }
.get-desktop { margin-left: auto; font-size: 13px; white-space: nowrap; }

/* Menus */
.menubar { display: flex; align-items: stretch; position: relative; }
.menu { position: relative; }
.menu-title { border: 0; background: transparent; padding: 7px 10px; border-radius: 4px; }
.menu.open > .menu-title { background: var(--accent-soft); }
.menu-backdrop { position: fixed; inset: 0; z-index: 40; }
.menu-list {
  position: absolute; z-index: 50; top: 100%; left: 0; min-width: 240px; margin: 2px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
/* Só os submenus (listas finais, sem outro nível) rolam: um contêiner com rolagem cortaria os submenus filhos. */
.menu-list .menu-list { top: -5px; left: 100%; margin: 0 0 0 2px; display: none; max-height: 75vh; overflow-y: auto; }
.menu.flip .menu-list .menu-list { left: auto; right: 100%; margin: 0 2px 0 0; }
.menu-item { position: relative; }
.menu-item.has-sub:hover > .menu-list, .menu-item.has-sub:focus-within > .menu-list { display: block; }
.menu-item > button { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: transparent; text-align: left; padding: 5px 8px; border-radius: 4px; white-space: nowrap; }
.menu-item > button:hover:not(:disabled) { background: var(--accent-soft); }
.mi-check { width: 14px; display: inline-block; color: var(--accent); }
.mi-label { flex: 1; }
.mi-shortcut { color: var(--muted); font-size: 12px; margin-left: 18px; }
.mi-arrow { color: var(--muted); margin-left: 12px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* Abas */
.tabs { display: flex; overflow-x: auto; background: var(--toolbar); border-bottom: 1px solid var(--border); }
.tab { display: flex; align-items: center; border-right: 1px solid var(--border); background: var(--bg); }
.tab.active { background: var(--surface); box-shadow: inset 0 2px 0 var(--accent); }
.tab-name { border: 0; background: transparent; padding: 6px 4px 6px 12px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 0; }
.tab-close { border: 0; background: transparent; padding: 4px 8px; color: var(--muted); border-radius: 0; }
.tab[draggable="true"] { cursor: default; }
.tab.dragging { opacity: .6; }
.tab-rename { margin: 3px 2px 3px 8px; padding: 2px 6px; width: 200px; font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--accent); border-radius: 4px; outline: none; }
.tab-rename.error { border-color: #dc2626; box-shadow: 0 0 0 2px rgba(220, 38, 38, .25); }

/* Área de trabalho e editor */
.workspace { min-height: 0; position: relative; background: var(--surface); }
.editor { display: flex; height: 100%; font: 13.5px/20px var(--mono); }
.editor .gutter {
  margin: 0; padding: 8px 10px 8px 8px; min-width: 48px; text-align: right; color: var(--muted); background: var(--toolbar); border-right: 1px solid var(--border);
  overflow: hidden; user-select: none; font: inherit; white-space: pre;
}
.editor .gutter.hidden { display: none; }
.editor .code { position: relative; flex: 1; min-width: 0; }
.editor .hl, .editor .input {
  position: absolute; inset: 0; margin: 0; padding: 8px 12px; border: 0; font: inherit; tab-size: 4; letter-spacing: normal; word-spacing: normal;
  white-space: pre; overflow: auto; overflow-wrap: normal;
}
.editor.wrap .hl, .editor.wrap .input { white-space: pre-wrap; overflow-wrap: anywhere; }
.editor .hl { pointer-events: none; color: var(--fg); overflow: hidden; }
.editor .hl code { font: inherit; }
.editor .input { resize: none; background: transparent; outline: none; color: var(--fg); caret-color: var(--fg); }
.editor.highlighted .input { color: transparent; }
.editor.highlighted .input::selection { background: rgba(59, 130, 246, .35); color: transparent; }
.editor.plain .hl { display: none; }
.tk-c { color: var(--tk-c); font-style: italic; } .tk-s { color: var(--tk-s); } .tk-n { color: var(--tk-n); } .tk-k { color: var(--tk-k); }
.tk-t { color: var(--tk-t); } .tk-a { color: var(--tk-a); } .tk-x { color: var(--tk-x); }

.preview { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.preview-bar { display: flex; gap: 8px; align-items: center; padding: 6px 10px; background: var(--accent-soft); flex-wrap: wrap; }
.preview-bar span { flex: 1; min-width: 200px; }
.preview iframe { width: 100%; height: 100%; border: 0; background: #fff; grid-row: 2; }
.preview:not(:has(.preview-bar)) iframe { grid-row: 1 / span 2; }

.welcome { max-width: 760px; margin: 8vh auto; padding: 0 20px; text-align: center; }
.welcome h1 { font-size: 26px; margin: 12px 0 6px; }
.welcome-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 22px 0; }
.welcome-points { text-align: left; display: inline-block; color: var(--muted); }

.statusbar { display: flex; gap: 16px; align-items: center; background: var(--status); color: var(--status-fg); padding: 0 12px; min-height: 26px; font-size: 12.5px; white-space: nowrap; overflow: hidden; }
.statusbar .status-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* Ferramentas e diálogos */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 80; }
.tool, .dialog {
  position: fixed; z-index: 90; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.tool { width: min(960px, calc(100vw - 24px)); height: min(86vh, 900px); display: grid; grid-template-rows: auto 1fr auto; }
.tool.wide { width: min(1240px, calc(100vw - 24px)); }
.tool-head { display: flex; gap: 16px; align-items: flex-start; padding: 16px 18px 10px; border-bottom: 1px solid var(--border); }
.tool-head > div:first-child { flex: 1; }
.tool-head h2 { margin: 0 0 4px; font-size: 19px; }
.tool-head p { margin: 0; }
.country { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.country select { color: var(--fg); font-size: 14px; }
.icon.close { border: 0; background: transparent; font-size: 16px; padding: 4px 8px; }
.tool-body { overflow-y: auto; padding: 14px 18px; }
.note { background: var(--accent-soft); padding: 8px 12px; border-radius: 6px; margin: 0 0 12px; font-size: 13px; }
.fields { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; }
.fields.side { display: grid; grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 180px; }
.field > label { font-size: 12px; color: var(--muted); }
.field.wide { flex-basis: 100%; }
.fields.side .field:not(.wide) { grid-column: span 1; }
.field textarea { width: 100%; resize: vertical; }
.field input[type="text"].mono { min-width: 320px; }
.field.toggle { justify-content: flex-end; min-height: 52px; min-width: 0; }
.check { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.color-row, .file-row { display: flex; gap: 6px; align-items: center; }
.color-row input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.status { padding: 8px 12px; border-radius: 6px; font-weight: 600; margin: 10px 0; }
.status.ok { background: var(--ok); color: var(--ok-fg); } .status.err { background: var(--err); color: var(--err-fg); }
.status.warn { background: var(--warn); color: var(--warn-fg); } .status.info { background: var(--info); color: var(--info-fg); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; margin: 8px 0; }
.details dt { color: var(--muted); } .details dd { margin: 0; overflow-wrap: anywhere; }
.output { display: flex; flex-direction: column; gap: 10px; }
.tool-text { margin: 0; padding: 10px 12px; background: var(--toolbar); border: 1px solid var(--border); border-radius: 6px; font: 13px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow: auto; }
.tool-image { max-width: min(100%, 520px); max-height: 420px; align-self: center; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { position: sticky; top: 0; background: var(--toolbar); text-align: left; font-weight: 600; }
th, td { padding: 4px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
td { font-family: var(--mono); font-size: 12.5px; }
.chip { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--muted); border-radius: 2px; vertical-align: -1px; margin-right: 6px; }
.diff td { border: 0; white-space: pre-wrap; }
.diff td.ln { color: var(--muted); text-align: right; width: 44px; user-select: none; }
.diff td.sign { width: 16px; } .diff tr.added { background: var(--ok); } .diff tr.removed { background: var(--err); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 52px; height: 40px; padding: 0; border-radius: 5px; }
.contrast-sample { padding: 16px 20px; border-radius: 6px; }
.contrast-sample p { margin: 4px 0; } .contrast-sample .large { font-size: 24px; font-weight: 600; } .contrast-sample .small { font-size: 11.5px; }
.tool-foot { display: flex; gap: 6px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.foot-msg { margin-left: 8px; font-size: 12.5px; }
.dialog { width: min(520px, calc(100vw - 24px)); padding: 18px 20px; }
.dialog h2 { margin: 0 0 10px; font-size: 18px; }
.dialog .actions { justify-content: flex-end; }

@media (max-width: 760px) {
  .brand span, .get-desktop { display: none; }
  .menu-title { padding: 7px 7px; }
  .fields.side { grid-template-columns: 1fr; }
  .field, .field input[type="text"].mono { min-width: 0; width: 100%; }
  .tool { height: calc(100vh - 16px); }
  .statusbar span:not(.status-msg):not(.strong) { display: none; }
}
