/* ==========================================================================
   FOLIO — annotate.css
   Markup & content: inspector controls, comment pins, outline tree,
   find bar, stamp chips, comment rows.
   ========================================================================== */

/* ------------------------------------------------------------------ */
/* Inspector                                                          */
/* ------------------------------------------------------------------ */
.annot-insp { display: flex; flex-direction: column; gap: 11px; }
.annot-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.annot-field > span {
  font-size: 10px; font-weight: 600; letter-spacing: .03em;
  color: var(--muted); text-transform: uppercase;
}
.annot-insp .input { height: 30px; font-size: 12px; }
.annot-check {
  display: flex; align-items: flex-start; gap: 7px; font-size: 11.5px;
  color: var(--text-soft); cursor: pointer; line-height: 1.35;
}
.annot-check input { accent-color: var(--accent); margin-top: 2px; }
.annot-color { display: flex; align-items: center; gap: 6px; }
.annot-color input[type="color"] { width: 100%; height: 30px; padding: 3px; border-radius: 6px; }
.annot-range { display: flex; align-items: center; gap: 8px; height: 30px; }
.annot-range input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.annot-range output { min-width: 38px; text-align: right; font-family: var(--mono); font-size: 10.5px; color: var(--text-soft); }
.annot-inline-checks {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: rgba(255, 255, 255, .018);
}
.annot-inline-checks .check-row { padding: 0; }
.annot-opacity-in { width: 70px; }
.annot-inline-checks output { font-family: var(--mono); font-size: 10.5px; color: var(--text-soft); }
.annot-actions-row { display: flex; flex-wrap: wrap; gap: 6px; }
.annot-actions-row .btn { justify-content: flex-start; }
.annot-field .field-hint, .annot-insp .field-hint { font-size: 10px; color: var(--faint); line-height: 1.45; }

.annot-img-preview {
  display: flex; align-items: center; gap: 9px; padding: 7px;
  border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.022);
}
.annot-img-preview img {
  width: 54px; height: 42px; object-fit: contain; border-radius: 4px;
  background: #fff; border: 1px solid var(--line); flex: none;
}
.annot-img-preview div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.annot-img-preview strong { font-size: 11px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.annot-img-preview span { font-size: 10px; color: var(--faint); line-height: 1.4; }
.annot-img-preview.empty { color: var(--faint); }
.annot-img-preview.empty strong { color: var(--muted); }

/* Stamp presets */
.annot-stamp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.annot-stamp-chip {
  height: 28px; border-radius: 5px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 9.5px; font-weight: 700;
  letter-spacing: .05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 3px;
}
.annot-stamp-chip:hover { color: var(--text); border-color: var(--line-strong); }
.annot-stamp-chip.on { color: var(--accent); border-color: rgba(124,147,255,.4); background: var(--accent-soft); }
.annot-stamp-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.annot-stamp-tab {
  height: 29px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .05em;
}
.annot-stamp-tab:hover { color: var(--text); border-color: var(--line-strong); }
.annot-stamp-tab.on { color: var(--accent); border-color: rgba(124,147,255,.4); background: var(--accent-soft); }

/* ------------------------------------------------------------------ */
/* Page overlay: pins + links                                         */
/* ------------------------------------------------------------------ */
.ann-pin.annot-pin {
  border: 0; padding: 0; font-family: var(--font);
  background: var(--accent); color: var(--accent-ink);
}
.ann-pin.annot-pin:hover { filter: brightness(1.08); transform: translate(-4px, -100%) scale(1.06); }
.ann-pin.annot-pin.resolved {
  background: transparent; color: var(--ok); box-shadow: none;
  border: 1.5px solid var(--ok); opacity: .85;
}
.annot-pin-n { font-size: 10px; font-weight: 800; line-height: 1; }
.ann-pin.annot-pin.resolved .annot-pin-n { font-size: 9px; }
.annot-link-box {
  position: absolute; padding: 0; margin: 0; background: transparent;
  border: 1px dashed transparent; border-radius: 2px; cursor: pointer;
  pointer-events: auto;
}
.annot-link-box:hover, .annot-link-box:focus-visible {
  border-color: rgba(124, 147, 255, .85);
  background: rgba(124, 147, 255, .1);
  outline: none;
}

/* Draft previews */
.draft-box.hl { border-color: rgba(214, 176, 0, .85); background: rgba(255, 225, 77, .32); border-style: solid; }
.draft-box.link { border-color: var(--accent); background: rgba(124, 147, 255, .10); }
.draft-box.text { border-color: var(--accent); background: rgba(124, 147, 255, .06); }
.draft-box.stamp { border-width: 2px; background: transparent; }

/* ------------------------------------------------------------------ */
/* Comments panel                                                     */
/* ------------------------------------------------------------------ */
.annot-panel-head { display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 8px; }
.annot-panel-title {
  display: flex; align-items: center; gap: 7px; font-size: 11.5px;
  color: var(--text-soft); font-weight: 600;
}
.annot-panel-title .badge { margin-left: auto; }
.annot-panel-title svg { color: var(--muted); }
.annot-panel-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.annot-panel-actions .pill-row { gap: 4px; margin-left: auto; }
.annot-panel-actions .pill { height: 24px; font-size: 10px; padding: 0 8px; }
.annot-group { margin-bottom: 10px; }
.annot-group-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 10px 2px 4px;
}
.mini-link {
  background: none; border: 0; color: var(--faint); font-size: 9.5px;
  letter-spacing: .02em; padding: 2px 4px; border-radius: 4px; text-transform: none;
}
.mini-link:hover { color: var(--accent); background: var(--accent-soft); }
.annot-comment-row {
  display: flex; align-items: flex-start; gap: 7px; padding: 7px 6px;
  border-radius: 7px; border: 1px solid transparent;
}
.annot-comment-row:hover { background: rgba(255,255,255,.04); }
.annot-comment-row.resolved { opacity: .62; }
.annot-cmt-pin {
  width: 21px; height: 21px; flex: none; border-radius: 50% 50% 50% 4px;
  border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 9.5px; font-weight: 800; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.annot-comment-row.resolved .annot-cmt-pin { background: transparent; color: var(--ok); border: 1px solid var(--ok); }
.annot-cmt-main {
  flex: 1; min-width: 0; background: none; border: 0; padding: 0;
  text-align: left; display: flex; flex-direction: column; gap: 3px;
}
.annot-cmt-text {
  font-size: 11.5px; color: var(--text-soft); line-height: 1.4;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.annot-cmt-meta { font-size: 9.5px; color: var(--faint); }
.annot-cmt-actions { display: flex; flex-direction: column; gap: 1px; opacity: 0; transition: opacity .12s; }
.annot-comment-row:hover .annot-cmt-actions, .annot-comment-row:focus-within .annot-cmt-actions { opacity: 1; }
.annot-empty {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 26px 12px; text-align: center; color: var(--faint);
}
.annot-empty svg { color: var(--faint); opacity: .7; }
.annot-empty p { margin: 0; font-size: 11.5px; color: var(--muted); }
.annot-empty span { font-size: 10px; line-height: 1.5; }
.annot-empty.small { padding: 10px; }
.annot-attach-list { display: flex; flex-direction: column; gap: 2px; }
.annot-attach-row { padding: 6px; }
.annot-attach-ic { color: var(--faint); display: flex; }

/* ------------------------------------------------------------------ */
/* Outline tree                                                       */
/* ------------------------------------------------------------------ */
.annot-tree { display: flex; flex-direction: column; gap: 1px; }
.annot-tree-row {
  display: flex; align-items: center; gap: 2px; border-radius: 6px;
  padding-right: 4px; min-height: 28px;
}
.annot-tree-row:hover { background: rgba(255,255,255,.045); }
.annot-tree-row.group .annot-tree-title { font-weight: 650; color: var(--text); }
.annot-tree-chev {
  width: 18px; height: 22px; flex: none; border: 0; background: transparent;
  color: var(--faint); display: flex; align-items: center; justify-content: center;
  padding: 0; border-radius: 4px;
}
.annot-tree-chev:hover { color: var(--text); background: rgba(255,255,255,.06); }
.annot-tree-chev.collapsed svg { transform: rotate(-90deg); }
.annot-tree-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 2px 0; text-align: left; color: var(--text-soft);
}
.annot-tree-ic { display: flex; color: var(--faint); flex: none; }
.annot-tree-row.group .annot-tree-ic { color: var(--accent); }
.annot-tree-title { flex: 1; min-width: 0; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.annot-tree-page {
  font-family: var(--mono); font-size: 9px; color: var(--faint);
  background: rgba(255,255,255,.05); border-radius: 4px; padding: 1px 4px; flex: none;
}
.annot-tree-tools { display: flex; align-items: center; gap: 0; opacity: 0; transition: opacity .12s; }
.annot-tree-row:hover .annot-tree-tools, .annot-tree-row:focus-within .annot-tree-tools { opacity: 1; }
.annot-tree-tools .icon-mini { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ */
/* Headers dialog groups                                              */
/* ------------------------------------------------------------------ */
.annot-form-section { border-top: 1px solid var(--line); padding-top: 10px; }
.annot-form-section:first-child { border-top: 0; padding-top: 0; }
.annot-form-label {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint); font-weight: 700; margin-bottom: 7px;
}
.annot-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ------------------------------------------------------------------ */
/* Find bar                                                           */
/* ------------------------------------------------------------------ */
.find-bar {
  position: absolute; top: 46px; right: 22px; z-index: 70;
  display: none; align-items: center; gap: 4px;
  padding: 6px 7px; border-radius: 9px;
  background: rgba(20, 24, 33, .97); border: 1px solid var(--line-strong);
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  backdrop-filter: blur(10px);
}
:root[data-theme="light"] .find-bar { background: #fff; }
.find-bar.on { display: flex; animation: findIn .14s cubic-bezier(.2,.9,.3,1); }
@keyframes findIn { from { opacity: 0; transform: translateY(-4px); } }
.find-ic { color: var(--faint); display: flex; padding: 0 2px; }
.find-input {
  width: 220px; height: 28px; border: 0; outline: none; background: transparent;
  color: var(--text); font-size: 12.5px;
}
.find-input::placeholder { color: var(--faint); }
.find-count {
  min-width: 56px; text-align: right; font-family: var(--mono);
  font-size: 10px; color: var(--muted); padding: 0 4px;
}
.find-count.none { color: var(--err); }
.find-bar .icon-mini { width: 26px; height: 26px; }
.find-opt {
  height: 24px; min-width: 26px; padding: 0 6px; border-radius: 5px;
  border: 1px solid transparent; background: transparent;
  color: var(--faint); font-size: 10px; font-weight: 700; font-family: var(--mono);
}
.find-opt:hover { color: var(--text); background: rgba(255,255,255,.06); }
.find-opt.on { color: var(--accent); background: var(--accent-soft); border-color: rgba(124,147,255,.3); }

@media (max-width: 1160px) {
  .find-input { width: 160px; }
}