/* DocsGer 2 — sem frameworks, sem fontes externas (tudo sai do próprio servidor/cache) */
:root {
  --brand: #A71E20;
  --bg: #f6f5f3;
  --panel: #ffffff;
  --ink: #1d1b19;
  --muted: #6b6560;
  --line: #e7e3de;
  --soft: #f1eeea;
  --ok: #1f7a4d;
  --warn: #a15c00;
  --err: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px #0000000d, 0 8px 24px #0000000f;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--brand); }

/* ---------- botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: .5rem .9rem; cursor: pointer; white-space: nowrap; line-height: 1.2;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: #f2c9c5; }
.btn.danger:hover { background: #fdf0ef; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.link { border: 0; background: none; color: var(--muted); text-decoration: underline; }
.btn.sm { padding: .3rem .55rem; font-size: .85rem; border-radius: 6px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: .25rem .4rem; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--soft); color: var(--ink); }

label, .lbl { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
input:not([type=checkbox]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font-size: .95rem;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-size: .95rem; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.stack { display: grid; gap: .8rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
.form-msg { min-height: 1.2em; color: var(--err); font-size: .9rem; margin: .6rem 0 0; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 2rem; display: grid; gap: .9rem; }
.login-card h1 { font-size: 1.15rem; margin: 0 0 .4rem; text-align: center; font-weight: 600; }
.login-logo { max-width: 300px; max-height: 110px; margin: 0 auto .4rem; display: block; }
#loginFields { display: grid; gap: .9rem; }

/* ---------- topo */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1.2rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; min-width: 0; }
.brand img { height: 38px; width: auto; max-width: 210px; object-fit: contain; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: .2rem; margin-left: 1rem; flex: 1; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: .55rem .9rem; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs button:hover { background: var(--soft); color: var(--ink); }
.tabs button.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 9%, transparent); }
.usermenu { position: relative; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; padding: .4rem; display: grid; }
.dropdown small { padding: .3rem .6rem; color: var(--muted); }
.dropdown button { text-align: left; border: 0; background: none; padding: .5rem .6rem; border-radius: 6px; cursor: pointer; }
.dropdown button:hover { background: var(--soft); }
.only-mobile { display: none; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem; }

/* ---------- layout documentos */
#app { padding: 1.2rem; max-width: 1500px; margin: 0 auto; }
.docs-layout { display: grid; grid-template-columns: 290px 1fr; gap: 1.2rem; align-items: start; }
.docs-layout > *, .settings-grid > * { min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: .95rem; margin: 0; font-weight: 600; }
.panel-body { padding: 1rem; }

.tree { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow: auto; }
.tree ul { list-style: none; margin: 0; padding-left: .9rem; }
.tree > .panel-body > ul { padding-left: 0; }
.node { display: flex; align-items: center; gap: .25rem; padding: .32rem .4rem; border-radius: 7px; cursor: pointer; user-select: none; }
.node:hover { background: var(--soft); }
.node.sel { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); font-weight: 600; }
.node.drop { outline: 2px dashed var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }
.node .caret { width: 1.1rem; text-align: center; color: var(--muted); font-size: .7rem; transition: transform .15s; flex: none; }
.node .caret.open { transform: rotate(90deg); }
.node .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .count { font-size: .75rem; color: var(--muted); background: var(--soft); border-radius: 99px; padding: 0 .45rem; }
.node .acts { display: none; }
.node:hover .acts { display: flex; }
.node:hover .count { display: none; }
.lock { font-size: .72rem; }

.crumbs { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; font-size: .9rem; color: var(--muted); }
.crumbs b { color: var(--ink); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 200px; }
.search input { padding-left: 2rem !important; }
.search::before { content: "⌕"; position: absolute; left: .7rem; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 1.1rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1.2rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .8rem; }

/* ---------- tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; padding: .6rem .8rem; border-bottom: 1px solid var(--line); background: #fcfbfa; white-space: nowrap; }
td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfbfa; }
tr.dragging { opacity: .4; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: .2rem; }
.doc-title { display: flex; align-items: center; gap: .65rem; min-width: 220px; }
.doc-title div { min-width: 0; }
.doc-title strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.doc-title small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.ft { flex: none; width: 34px; height: 40px; border-radius: 6px; display: grid; place-items: center; font-size: .62rem; font-weight: 700; color: #fff; letter-spacing: .02em; }
.ft.pdf { background: #c0392b; } .ft.doc { background: #2b5797; } .ft.xls { background: #1e7145; }
.ft.ppt { background: #d24726; } .ft.img { background: #7e57c2; } .ft.zip { background: #6d4c41; }
.ft.vid { background: #00838f; } .ft.txt { background: #607d8b; }
.badge { display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.l2 { background: #fff4e0; color: var(--warn); } .badge.l3 { background: #fdecea; color: var(--err); }
.badge.ok { background: #e6f4ec; color: var(--ok); } .badge.off { background: #f1f1f1; color: #888; }
.badge.warn { background: #fff4e0; color: var(--warn); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: .4rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }

/* ---------- upload */
.dropzone { position: relative; }
.dropzone.over::after { content: "Solte os arquivos para enviar a esta pasta"; position: absolute; inset: 0; border: 2px dashed var(--brand); border-radius: var(--radius);
  background: color-mix(in srgb, var(--brand) 7%, #fffffff0); display: grid; place-items: center; font-weight: 600; color: var(--brand); z-index: 5; }
.queue { display: grid; gap: .4rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.qitem { display: grid; grid-template-columns: 1fr 120px 60px; gap: .6rem; align-items: center; font-size: .85rem; }
.qitem .bar { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.qitem .bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.qitem.err { color: var(--err); }

/* ---------- modal */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 2rem)); box-shadow: 0 20px 60px #0004; color: var(--ink); }
dialog.wide { width: min(860px, calc(100vw - 2rem)); }
dialog::backdrop { background: #1d1b1966; backdrop-filter: blur(2px); }
.m-head { display: flex; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.m-head h3 { margin: 0; font-size: 1.05rem; flex: 1; }
.m-body { padding: 1.2rem; display: grid; gap: .9rem; max-height: 70vh; overflow: auto; }
.m-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .9rem 1.2rem; border-top: 1px solid var(--line); background: #fcfbfa; border-radius: 0 0 14px 14px; }

/* ---------- QR */
.qr-layout { display: grid; grid-template-columns: 1fr 240px; gap: 1.2rem; align-items: start; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .8rem; text-align: center; }
.qr-box canvas { width: 100%; height: auto; image-rendering: pixelated; }
.qr-box .url { font-size: .78rem; color: var(--muted); word-break: break-all; margin-top: .4rem; }
.slug-field { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.slug-field span { padding: .55rem .6rem; background: var(--soft); color: var(--muted); font-size: .85rem; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; direction: rtl; }
.slug-field input { border: 0 !important; border-radius: 0 !important; }
.doc-pick { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.doc-pick button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .45rem .7rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.doc-pick button:hover, .doc-pick button.sel { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.doc-pick small { color: var(--muted); display: block; }

/* ---------- toasts */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: grid; gap: .5rem; z-index: 100; }
.toast { background: #1d1b19; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; font-size: .9rem; animation: up .2s ease-out; }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.logo-box { border: 1px dashed var(--line); border-radius: 10px; padding: 1rem; display: grid; place-items: center; background: repeating-conic-gradient(#f4f2ef 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.logo-box img { max-height: 90px; max-width: 100%; }
.icon-box { width: 84px; height: 84px; padding: .5rem; }
.icon-box img { width: 64px; height: 64px; object-fit: contain; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* ---------- responsivo */
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .tree { position: fixed; inset: 60px auto 0 0; width: 300px; z-index: 30; max-height: none; border-radius: 0; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  .tree.open { transform: none; }
  .only-mobile { display: inline-block; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .settings-grid, .qr-layout, .grid2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: .3rem .6rem; padding: .5rem .7rem .3rem; }
  .tabs { margin-left: 0; order: 3; flex-basis: 100%; }
  .tabs button { padding: .45rem .7rem; }
  .usermenu { margin-left: auto; }
  .tree { top: 0; padding-top: .5rem; }
  .brand span { display: none; }
  td.actions .btn[data-a=edit], td.actions .btn[data-a=replace] { display: none; }
  .hide-sm { display: none; }
  #app { padding: .7rem; }
}
