/*
 * Copyright (c) Biovisuals Private Limited. All rights reserved.
 *
 * Phase 7A-2 — Official Drafts (Admin-only authoring workspace). A body-level overlay: it never
 * resizes the canvas. Dialogs (BioDialog, z-index 10000) stay above it.
 */

.bv-od-panel {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 88px);
  background: #ffffff;
  color: #1c2d4a;
  border: 1px solid #e2e6ee;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  z-index: 4100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
}
.bv-od-panel[hidden] { display: none; }
.bv-od-panel:focus { outline: none; }

.bv-od-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid #eef1f6;
}
.bv-od-title { margin: 0; font-size: 14px; font-weight: 600; }
.bv-od-subtitle { display: block; margin-top: 2px; font-size: 11px; color: #6b7280; }
.bv-od-close {
  background: transparent; border: none; cursor: pointer; color: #6b7280;
  font-size: 18px; line-height: 1; padding: 2px 8px; border-radius: 6px;
}
.bv-od-close:hover, .bv-od-close:focus-visible { background: #f1f3f8; color: #1c2d4a; }

.bv-od-body { overflow-y: auto; padding: 10px 12px 14px; flex: 1; }

.bv-od-toolbar { margin-bottom: 8px; }
.bv-od-search, .bv-od-input {
  width: 100%; box-sizing: border-box; padding: 7px 9px; font: inherit;
  border: 1px solid #d7dce6; border-radius: 8px; background: #fff; color: inherit;
}
.bv-od-search:focus, .bv-od-input:focus { outline: 2px solid #4f6ef7; outline-offset: 0; border-color: #4f6ef7; }

.bv-od-status { color: #6b7280; padding: 4px 2px; }
.bv-od-status:empty { display: none; }

.bv-od-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bv-od-card {
  display: flex; gap: 10px; padding: 8px; border: 1px solid #eef1f6; border-radius: 10px;
}
.bv-od-card:hover { background: #f8fafd; }
.bv-od-thumb {
  width: 72px; height: 72px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  background: #f1f3f8 repeating-conic-gradient(#eef1f6 0 25%, transparent 0 50%) 50% / 12px 12px;
  border: 1px solid #e6e9f0; display: flex; align-items: center; justify-content: center;
}
.bv-od-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bv-od-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bv-od-card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bv-od-card-desc { color: #4b5565; font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bv-od-card-meta { color: #6b7280; font-size: 11px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bv-od-card-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.bv-od-btn {
  font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid #d7dce6; background: #fff; color: #1c2d4a;
}
.bv-od-btn:hover, .bv-od-btn:focus-visible { background: #f1f3f8; }
.bv-od-btn--primary { background: #4f6ef7; border-color: #4f6ef7; color: #fff; }
.bv-od-btn--primary:hover, .bv-od-btn--primary:focus-visible { background: #3f5ce6; }
.bv-od-btn:disabled { opacity: 0.55; cursor: default; }
.bv-od-link { font: inherit; background: none; border: none; color: #4f6ef7; cursor: pointer; padding: 2px 0; }
.bv-od-link:hover, .bv-od-link:focus-visible { text-decoration: underline; }

.bv-od-chip {
  display: inline-block; padding: 0 6px; border-radius: 9px; font-size: 10.5px; font-weight: 600;
  background: #e8edff; color: #3346b8;
}
.bv-od-chip--warn { background: #fff4d6; color: #8a5a00; }

.bv-od-ws-head { display: flex; flex-direction: column; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid #eef1f6; margin-bottom: 8px; }
.bv-od-ws-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.bv-od-ws-meta { color: #6b7280; font-size: 11px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bv-od-ws-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.bv-od-section-title { font-weight: 600; font-size: 12px; margin: 8px 0 4px; color: #1c2d4a; }
.bv-od-hint { color: #6b7280; font-size: 11.5px; margin: 2px 0 6px; }

.bv-od-tree { list-style: none; margin: 0; padding: 0; border: 1px solid #eef1f6; border-radius: 8px; max-height: 260px; overflow-y: auto; }
.bv-od-node {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 8px 5px calc(8px + var(--bv-od-depth, 0) * 14px);
  border-bottom: 1px solid #f4f6fa;
}
.bv-od-node:last-child { border-bottom: none; }
.bv-od-node:hover { background: #f6f8fc; }
.bv-od-node.is-selected { background: #e8edff; }
.bv-od-node:focus-visible { outline: 2px solid #4f6ef7; outline-offset: -2px; }
.bv-od-node--root { cursor: default; font-weight: 600; }
.bv-od-node-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bv-od-node-type { color: #8a93a3; font-size: 11px; }
.bv-od-empty { padding: 12px; color: #6b7280; }

.bv-od-node-editor { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.bv-od-label { font-size: 11.5px; color: #4b5565; margin-top: 4px; }
.bv-od-error { color: #b42318; font-size: 12px; margin: 4px 0 0; }
.bv-od-editor-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.bv-od-advanced { margin-top: 6px; color: #6b7280; font-size: 11px; }
.bv-od-node-id { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; user-select: all; }

/* Details dialog (built on the My Icons form dialog).
 *
 * Always fully inside the viewport. The shared BioDialog backdrop centres its dialog in a box with a
 * 60px bottom offset; this form is taller than short screens, so centring pushed its title above the
 * top edge. Scoped to this dialog only (other BioDialogs keep their behaviour):
 *   - the backdrop leaves a 16px gap all round and never scrolls (no page-level scroll behind it);
 *   - `margin: auto` centres the dialog when it fits and pins it to the top gap when it does not
 *     (auto margins never go negative — top-safe, not centred off-screen);
 *   - the dialog is capped at the viewport height minus the gaps (border-box: padding included); its
 *     title, note and close button stay put and the long form scrolls inside it.
 * The visual width is unchanged (560px content + 52px padding); on narrow screens it keeps the 16px gaps. */
.bio-dialog-backdrop.bv-od-meta-backdrop { padding: 16px; box-sizing: border-box; overflow: hidden; }
.bio-dialog.bv-od-meta-dialog {
  box-sizing: border-box;
  width: calc(100vw - 32px);
  max-width: 612px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bv-od-meta-dialog .bv-od-meta-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.bv-od-meta-note { margin: -4px 0 8px; color: #6b7280; font-size: 12px; }
.bv-od-meta-group { border: 1px solid #eef1f6; border-radius: 8px; padding: 6px 10px 8px; margin: 0 0 8px; }
.bv-od-meta-group legend { font-weight: 600; font-size: 12px; padding: 0 4px; }
.bv-od-meta-hint { display: block; color: #8a93a3; font-size: 11px; margin-top: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .bv-od-card, .bv-od-node { transition: background 0.12s ease; }
}
