/* =============================================================
   Word Building Block Manager — tool-specific styles  (PREVIEW / BETA)
   Built on the shared design system (styles.css); uses its CSS
   variables so the tool follows the site's light/dark theme.
   ============================================================= */

/* ---- Beta banner ---- */
/* Let the hero title wrap the Beta chip instead of overflowing on narrow screens. */
.wbm .tool-hero h1 { flex-wrap: wrap; }
.wbm .tool-hero h1 > span:not(.tool-icon):not(.wbm-beta) { min-width: 0; }
.wbm-beta { font-size: .62rem; align-self: center; }
.wbm-beta-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: color-mix(in srgb, var(--brand-2) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-2) 55%, var(--border));
  border-radius: 12px; padding: 11px 15px; margin-bottom: 16px;
  font-size: 13px; color: var(--text); line-height: 1.5;
}
.wbm-beta-note::before { content: "🧪"; font-size: 15px; line-height: 1.4; }

/* ---- Source bar ---- */
.wbm-source {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 16px 18px; margin-bottom: 16px;
}
.filemeta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.filemeta .grow, .wbm-source .grow { flex: 1 1 auto; min-width: 180px; }
.filemeta .fname { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 13px; color: var(--text); word-break: break-all; }
.filemeta .fsub { font-size: 12.5px; color: var(--text-soft); }
.filemeta.empty .fname { color: var(--text-soft); }
.wbm .btn .ic { width: 16px; height: 16px; }
.wbm .btn svg { display: block; }

/* ---- Toolbar (filters) ---- */
.wbm-toolbar {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 12px; align-items: end;
  padding: 16px 18px; margin-bottom: 14px;
}
.wbm-toolbar .field { margin-bottom: 0; }
.wbm-toolbar label {
  display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-soft); margin-bottom: 7px; font-weight: 600;
}
.wbm-toolbar input[type=search], .wbm-toolbar select {
  width: 100%; box-sizing: border-box; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
}
.wbm-toolbar input[type=search]:focus, .wbm-toolbar select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* ---- Toggle bar ---- */
.wbm-togglebar {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
  padding: 14px 18px; margin-bottom: 16px; font-size: 13px; color: var(--text-soft);
}
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; user-select: none; }
.check input { accent-color: var(--brand); width: 15px; height: 15px; }
.wbm-togglebar .grp { display: flex; gap: 8px; align-items: center; }
.wbm-togglebar .spacer { flex: 1 1 auto; }
.wbm .btn { font-size: .9rem; padding: 9px 15px; }

/* ---- Table ---- */
.tablecard { padding: 0; overflow: hidden; }
.tscroll { overflow: auto; max-height: calc(100vh - 240px); }
.wbm table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wbm thead th {
  position: sticky; top: 0; z-index: 2; background: var(--bg-elev);
  font-size: .66rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-soft); text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.wbm thead th.tc-center { text-align: center; }
.wbm tbody td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.wbm tbody tr { animation: wbmRise .42s cubic-bezier(.2,.7,.2,1) both; }
.wbm tbody tr:hover { background: var(--bg-soft); }
.wbm tbody tr.changed { background: color-mix(in srgb, var(--brand) 9%, transparent); }
.wbm tbody tr.changed:hover { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.wbm tbody tr.selected { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.wbm tbody tr.selected:hover { background: color-mix(in srgb, var(--brand) 17%, transparent); }
.wbm tbody tr.selected.changed { background: color-mix(in srgb, var(--brand) 18%, transparent); }
@keyframes wbmRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tc-center { text-align: center; }
.col-name { min-width: 200px; }
.col-sel { width: 38px; }
.col-gal { min-width: 150px; }
.col-cat { min-width: 120px; }
.col-beh { min-width: 150px; }
.col-typ { min-width: 110px; }
.col-desc { min-width: 170px; }
.col-act { text-align: right; white-space: nowrap; }

.namerow { display: flex; align-items: center; gap: 6px; }
.nameedit {
  font: inherit; font-weight: 600; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  padding: 4px 7px; margin: -4px 0; width: 100%; max-width: 320px; min-width: 0;
  transition: background .14s, border-color .14s, box-shadow .14s;
}
.nameedit:hover { border-color: var(--border); background: var(--bg); }
.nameedit:focus { outline: none; border-color: var(--brand); background: var(--bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.nameedit.warnfld { border-color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2) inset; }
.guidline { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--text-soft); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resetname {
  font: inherit; font-size: 11px; font-weight: 600; color: var(--brand);
  background: transparent; border: 1px solid var(--border); border-radius: 7px;
  padding: 2px 8px; cursor: pointer; line-height: 1.4; white-space: nowrap;
}
.resetname:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); border-color: var(--brand); }

/* in-cell editable controls */
.cellinput {
  font: inherit; font-size: 13.5px; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 5px 8px; width: 100%; min-width: 0; box-sizing: border-box;
  transition: background .14s, border-color .14s, box-shadow .14s;
}
.cellinput:hover { border-color: var(--border); background: var(--bg); }
.cellinput:focus { outline: none; border-color: var(--brand); background: var(--bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
select.cellinput { appearance: none; -webkit-appearance: none; padding-right: 24px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%238b93a5' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; }

.selcb { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; vertical-align: middle; margin: 0; }
.rowact {
  font: inherit; font-size: 11px; font-weight: 600; color: var(--office-word);
  background: transparent; border: 1px solid var(--border); border-radius: 7px;
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s;
}
.rowact:hover { background: color-mix(in srgb, var(--office-word) 12%, transparent); border-color: var(--office-word); }

.wbm-nomatch { text-align: center; padding: 56px 24px; color: var(--text-soft); }
.wbm-nomatch .big { font-size: 1.2rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }

/* ---- Sticky action bar ---- */
.wbm-actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.wbm-actionbar .inner { max-width: var(--maxw); margin: 0 auto; padding: 13px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.wbm-actionbar .count { font-size: 13.5px; color: var(--text-soft); }
.wbm-actionbar .count b { color: var(--brand); font-weight: 700; }
.wbm-actionbar .spacer { flex: 1 1 auto; }

/* ---- Modals ---- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(5,6,10,.55); backdrop-filter: blur(3px); padding: 20px; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 460px; width: 100%; padding: 24px; }
.modal-msg { margin: 0 0 18px; font-size: 14px; color: var(--text); line-height: 1.5; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.wbm .btn.danger { background: var(--office-powerpoint); border-color: transparent; color: #fff; }
.wbm .btn.danger:hover { background: color-mix(in srgb, var(--office-powerpoint) 88%, #fff); }

/* preview + import modal (wider) */
.modal.preview { max-width: 760px; }
.modal.preview .modal-head { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.modal.preview .modal-head .mt { font-weight: 700; font-size: 18px; color: var(--text); }
.modal.preview .modal-head .ms { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.modal.preview .modal-head .x { margin-left: auto; }
.modal.preview .imp-selall { margin-left: auto; white-space: nowrap; font-size: 13px; }
.modal-scroll { max-height: 70vh; overflow: auto; }
.imp-count { margin-right: auto; color: var(--text-soft); font-size: 12.5px; }

.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; font-size: 13px; margin: 0 0 18px; }
.meta-grid dt { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft); }
.meta-grid dd { color: var(--text); margin: 0; }
.sheet-label { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft); margin: 0 0 8px; }

/* the "paper" sheet shows real Word content; kept light for legibility in both themes */
.sheet {
  background: #fbfbf9; color: #23262c; border-radius: 10px; border: 1px solid var(--border);
  padding: 30px 36px; font-family: "Calibri", system-ui, sans-serif; line-height: 1.55; font-size: 15px;
}
.sheet p { margin: 0 0 .55em; }
.sheet table.wtbl { border-collapse: collapse; margin: .6em 0; width: 100%; }
.sheet table.wtbl td { border: 1px solid #cfcfca; padding: 6px 9px; vertical-align: top; }
.sheet .fld { background: #e7eefb; border-radius: 4px; padding: 0 5px; color: #2f5c9e; font-family: ui-monospace, Menlo, monospace; font-size: .82em; }
.sheet .gfx { display: inline-block; background: #ecebe5; border: 1px dashed #b9b6ad; border-radius: 6px; padding: 1px 9px; color: #8a857a; font-size: .85em; }
.sheet .wm { display: block; text-align: center; font-size: 2.6em; font-weight: 800; color: #e3e0d6; letter-spacing: .1em; }
.sheet .brk { display: block; border-top: 1px dashed #d8d4c8; margin: .7em 0; height: 0; }

/* import modal list */
.imp-list { display: flex; flex-direction: column; gap: 6px; }
.imp-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.imp-row:hover { background: var(--bg-soft); }
.imp-row:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.imp-row input { margin-top: 3px; }
.imp-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.imp-name { font-weight: 600; color: var(--text); }
.imp-meta { font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: .04em; color: var(--text-soft); text-transform: uppercase; }
.imp-desc { font-size: 12.5px; color: var(--text-soft); }

/* ---- Toast ---- */
.wbm-toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev); color: var(--text); padding: 12px 18px; border-radius: 12px;
  border: 1px solid var(--border); font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: all .25s ease; z-index: 70; box-shadow: var(--shadow-lg); max-width: 90vw;
}
.wbm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.wbm-toast.err { border-color: color-mix(in srgb, var(--office-powerpoint) 60%, var(--border)); color: var(--office-powerpoint); }

/* drag & drop highlight */
.wbm.droplit { outline: 2px dashed var(--brand); outline-offset: -10px; border-radius: 18px; }

/* legal note */
.wbm-legal { margin-top: 36px; font-size: 11.5px; color: var(--text-soft); line-height: 1.55; }
.wbm-legal p { margin: 0 0 8px; max-width: 84ch; }

@media (max-width: 720px) {
  .wbm-toolbar { grid-template-columns: 1fr; }
}
