/* mark.blackit.hu — MarkItDown konverter. Önálló, külső függőség nélkül. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f3fa;
  --border: #e1e6f0;
  --text: #1a2238;
  --muted: #6b748c;
  --primary: #2f4ad0;
  --primary-ink: #ffffff;
  --ok-bg: #e3f6ea; --ok-fg: #1c7a3e;
  --wait-bg: #fff3d6; --wait-fg: #8a6100;
  --err-bg: #fde4e4; --err-fg: #b3261e;
  --ai-bg: #efe9fb;  --ai-fg: #5b34c7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20,34,76,.08), 0 6px 20px rgba(20,34,76,.05);
}
/* Sötét téma változói. Kézi választás: :root[data-theme="dark"].
   Ha nincs kézi választás (nincs data-theme), a rendszer-beállítást követi. */
:root[data-theme="dark"] {
  --bg: #0e1326; --surface: #161d36; --surface-2: #1d2643; --border: #283157;
  --text: #e7ebf6; --muted: #98a2c0; --primary: #6981f0; --primary-ink: #0e1326;
  --ok-bg: #14361f; --ok-fg: #7ee0a0; --wait-bg: #3a2f10; --wait-fg: #f3cf7a;
  --err-bg: #3c1816; --err-fg: #f3a39d; --ai-bg: #271a47; --ai-fg: #b7a3f3;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1326; --surface: #161d36; --surface-2: #1d2643; --border: #283157;
    --text: #e7ebf6; --muted: #98a2c0; --primary: #6981f0; --primary-ink: #0e1326;
    --ok-bg: #14361f; --ok-fg: #7ee0a0; --wait-bg: #3a2f10; --wait-fg: #f3cf7a;
    --err-bg: #3c1816; --err-fg: #f3a39d; --ai-bg: #271a47; --ai-fg: #b7a3f3;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.content { width: 100%; max-width: 920px; margin: 0 auto; padding: 24px 20px 48px; flex: 1; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand .mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  background: var(--primary); color: var(--primary-ink); border-radius: 8px; font-weight: 800; font-size: 14px;
}
.brand.big { font-size: 22px; margin-bottom: 8px; }
.brand.big .mark { width: 34px; height: 34px; font-size: 16px; }
.spacer { flex: 1; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a.active { color: var(--primary); background: var(--surface-2); }
.tb-user { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.tb-user .avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); font-size: 11px; font-weight: 700;
}
.tb-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sep { opacity: .5; }

/* Téma-kapcsoló */
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 9px; cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
}
.icon-btn:hover { filter: brightness(.97); }
.login-toggle { position: fixed; top: 16px; right: 16px; }
.icon-btn svg { width: 18px; height: 18px; display: block; }
/* A látható ikon azt mutatja, MELYIK módra váltanál: világosban hold (→sötét), sötétben nap (→világos). */
.theme-toggle .t-sun { display: none; }
.theme-toggle .t-moon { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle .t-sun { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle .t-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .t-sun { display: inline-flex; }
  :root:not([data-theme="light"]) .theme-toggle .t-moon { display: none; }
}

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 22px;
}
.card.narrow { max-width: 640px; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Centered (login) */
body.centered { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { max-width: 400px; text-align: center; }
.btn-block { display: block; width: 100%; margin-top: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:disabled { opacity: .55; cursor: default; }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px 20px;
  cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s;
  margin: 14px 0;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--surface); }
.dz-icon { font-size: 26px; color: var(--primary); }
.dz-text { color: var(--muted); }
.dz-files { font-size: 13px; color: var(--text); font-weight: 600; word-break: break-all; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; }
#busy-note { margin-left: 12px; }

/* Document table */
.doc-list h2 { display: flex; align-items: center; gap: 8px; }
.count {
  font-size: 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 9px; color: var(--muted); font-weight: 600;
}
table.docs { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.docs th, table.docs td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.docs th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
table.docs tr:last-child td { border-bottom: none; }
.fname { font-weight: 600; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.link { background: none; border: none; padding: 0; cursor: pointer; color: var(--primary); font: inherit; font-size: 13px; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--err-fg); }
.inline { display: inline; margin: 0; }

/* Badges */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.wait { background: var(--wait-bg); color: var(--wait-fg); }
.badge.err { background: var(--err-bg); color: var(--err-fg); }
.badge.ai { background: var(--ai-bg); color: var(--ai-fg); }

/* Toolbar (tömeges letöltés) + kijelölő oszlop */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.col-check { width: 32px; text-align: center; }
.col-check input { cursor: pointer; }

/* Markdown preview */
.view-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.vh-title { margin: 6px 0 2px; word-break: break-word; }
.view-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Szegmentált váltó (Renderelt / Nyers) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface-2); }
.seg-btn { border: none; background: transparent; padding: 8px 14px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg-btn.active { background: var(--primary); color: var(--primary-ink); }

.md-preview, .md-source-hidden {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 70vh; overflow: auto;
}

/* Renderelt markdown tipográfia */
.md-rendered {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 28px; max-height: 72vh; overflow: auto; line-height: 1.65; word-break: break-word;
}
.md-rendered > :first-child { margin-top: 0; }
.md-rendered h1, .md-rendered h2, .md-rendered h3, .md-rendered h4 { line-height: 1.3; margin: 1.4em 0 .5em; }
.md-rendered h1 { font-size: 1.7em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.md-rendered h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: .25em; }
.md-rendered h3 { font-size: 1.2em; }
.md-rendered p { margin: .7em 0; }
.md-rendered ul, .md-rendered ol { padding-left: 1.6em; margin: .6em 0; }
.md-rendered li { margin: .25em 0; }
.md-rendered a { color: var(--primary); }
.md-rendered code {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px;
  padding: .1em .4em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em;
}
.md-rendered pre {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 14px 16px; overflow: auto; margin: .8em 0;
}
.md-rendered pre code { background: none; border: none; padding: 0; }
.md-rendered blockquote {
  margin: .8em 0; padding: .2em 1em; border-left: 3px solid var(--primary); color: var(--muted);
}
.md-rendered table { border-collapse: collapse; margin: .9em 0; width: auto; max-width: 100%; }
.md-rendered th, .md-rendered td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.md-rendered th { background: var(--surface-2); font-weight: 700; }
.md-rendered img { max-width: 100%; height: auto; }
.md-rendered hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }

/* Footer */
.app-footer { text-align: center; padding: 18px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }

@media (max-width: 600px) {
  .tb-name { display: none; }
  .fname { max-width: 150px; }
  table.docs th:nth-child(2), table.docs td:nth-child(2) { display: none; }
}
