/* ================================================================
   BIZ-JSON-VIEWER — Component styles
   Prefix: bvw-  (collision-safe)
   ================================================================ */

/* ── BizMetry DS tokens (self-contained fallback) ────────────── */
:root {
  --bm-gradient-primary:       linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bm-color-error:            #f44336;
  --bm-radius-sm:              4px;
  --bm-radius-lg:              12px;
  --bm-shadow-sm:              0 2px 8px rgba(0, 0, 0, 0.08);
  --bm-font-mono:              'Monaco', 'Courier New', monospace;
  --bm-code-bg:                #1e1e1e;
  --bm-code-bg-scrollbar:      #2d2d2d;
  --bm-code-text:              #d4d4d4;
  --bm-code-key:               #9cdcfe;
  --bm-code-string:            #ce9178;
  --bm-code-number:            #b5cea8;
  --bm-code-boolean:           #569cd6;
  --bm-code-teal:              #4ec9b0;
  --bm-code-teal-bg:           rgba(78, 201, 176, 0.10);
}

.biz-json-viewer {
  --bvw-header-h:         52px;
  --bvw-search-h:         44px;
  --bvw-match-bg:         rgba(255, 213, 0, 0.30);
  --bvw-match-border:     rgba(255, 213, 0, 0.70);
  --bvw-match-active-bg:  rgba(255, 140, 0, 0.55);
  --bvw-match-active-brd: rgba(255, 140, 0, 0.90);
  --bvw-toggle-color:     var(--bm-code-teal);
  --bvw-toggle-hover-bg:  rgba(78, 201, 176, 0.15);
}

/* ── Root ────────────────────────────────────────────────────── */
.biz-json-viewer {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;          /* ← fills backdrop container */
  min-height: 0;         /* ← allows shrink in flex column */
  background: var(--bm-code-bg);
  border-radius: var(--bm-radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--bm-shadow-sm);
}

/* ── Header ──────────────────────────────────────────────────── */
.bvw-header {
  background: var(--bm-gradient-primary) !important;
  min-height: var(--bvw-header-h);
  padding: 0 16px 0 20px;
  display: flex !important;
  align-items: center !important;
  gap: 8px;
  flex-shrink: 0;
}

.bvw-header-icon {
  color: white !important;
  font-size: 22px !important;
  width: 22px !important;
  height: 22px !important;
  flex-shrink: 0;
}

.bvw-header-title {
  flex: 1;               /* ← takes free space (replaces span[flex]) */
  font-size: 15px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bvw-ctrl-btn {
  color: white !important;
  margin: 0 !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  flex-shrink: 0;
  border-radius: 50% !important;
  transition: background 0.15s ease !important;
}

.bvw-ctrl-btn:hover { background: rgba(255, 255, 255, 0.15) !important; }

.bvw-ctrl-btn md-icon {
  font-size: 20px !important;
  width: 20px !important;
  height: 20px !important;
  color: white !important;
}

.bvw-ctrl-btn.bvw-copied md-icon { color: #a5d6a7 !important; }

/* ── Search bar ──────────────────────────────────────────────── */
.bvw-search-bar {
  background: #2a2a2a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: var(--bvw-search-h);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bvw-search-icon {
  color: #666 !important;
  font-size: 18px !important;
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
}

.bvw-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--bm-font-mono);
  font-size: 13px;
  color: #ccc;
  caret-color: var(--bm-code-teal);
}
.bvw-search-input::placeholder { color: #555; }
.bvw-search-input:focus        { color: #eee; }

.bvw-search-clear {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: var(--bm-radius-sm);
  transition: background 0.12s;
  flex-shrink: 0;
}
.bvw-search-clear md-icon { font-size: 16px !important; width: 16px !important; height: 16px !important; color: #666 !important; }
.bvw-search-clear:hover          { background: rgba(255, 255, 255, 0.08); }
.bvw-search-clear:hover md-icon  { color: #aaa !important; }

.bvw-search-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding-left: 10px;
}

.bvw-match-count {
  font-family: var(--bm-font-mono);
  font-size: 12px;
  color: #888;
  min-width: 52px;
  text-align: center;
  white-space: nowrap;
}

.bvw-no-match {
  font-size: 12px;
  color: var(--bm-color-error);
  min-width: 62px;
  text-align: center;
  opacity: 0.8;
}

.bvw-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  border-radius: var(--bm-radius-sm);
  transition: background 0.12s;
}
.bvw-nav-btn md-icon { font-size: 18px !important; width: 18px !important; height: 18px !important; color: #777 !important; }
.bvw-nav-btn:hover:not([disabled])          { background: rgba(255, 255, 255, 0.08); }
.bvw-nav-btn:hover:not([disabled]) md-icon  { color: var(--bm-code-teal) !important; }
.bvw-nav-btn[disabled]                      { opacity: 0.35; cursor: not-allowed; }

/* ── Body ────────────────────────────────────────────────────── */
.bvw-body {
  flex: 1;
  min-height: 0;         /* ← critical: allows scroll inside flex column */
  overflow-y: auto;
  overflow-x: auto;
  background: var(--bm-code-bg);
  padding: 18px 20px;
}

/* ── Tree ────────────────────────────────────────────────────── */
.bvw-tree {
  font-family: var(--bm-font-mono);
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--bm-code-text);
  white-space: pre;
}

.bvw-key      { color: var(--bm-code-key); }
.bvw-colon    { color: var(--bm-code-text); }
.bvw-bracket  { color: var(--bm-code-text); font-weight: 600; }
.bvw-comma    { color: var(--bm-code-text); }

.bvw-value         { }
.bvw-value.string  { color: var(--bm-code-string); }
.bvw-value.number  { color: var(--bm-code-number); }
.bvw-value.boolean { color: var(--bm-code-boolean); }
.bvw-value.null    { color: var(--bm-code-boolean); font-style: italic; }

.bvw-index {
  color: var(--bm-code-teal);
  font-weight: 600;
  background: var(--bm-code-teal-bg);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 2px;
  font-size: 11.5px;
  vertical-align: middle;
}

.bvw-hint { color: #6a6a6a; font-style: italic; }

/* ── Collapse toggle ─────────────────────────────────────────── */
.bvw-toggle,
.bvw-toggle-spacer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  flex-shrink: 0;
  margin-right: 3px;
  position: relative;
  top: -1px;
}

.bvw-toggle {
  cursor: pointer;
  color: var(--bvw-toggle-color);
  border-radius: 2px;
  transition: background 0.12s ease, color 0.12s ease;
  user-select: none;
}

.bvw-toggle::before         { content: '▼'; font-size: 8px; line-height: 1; display: block; }
.bvw-toggle.collapsed::before { content: '▶'; }
.bvw-toggle:hover           { background: var(--bvw-toggle-hover-bg); color: #7fffff; }

/* ── Search highlights ───────────────────────────────────────── */
.bvw-match {
  background: var(--bvw-match-bg);
  border-radius: 2px;
  outline: 1px solid var(--bvw-match-border);
  padding: 0 1px;
}

.bvw-match-active {
  background: var(--bvw-match-active-bg) !important;
  outline: 1px solid var(--bvw-match-active-brd) !important;
  border-radius: 2px;
}

/* ── Scrollbars ──────────────────────────────────────────────── */
.bvw-body::-webkit-scrollbar        { width: 8px; height: 8px; }
.bvw-body::-webkit-scrollbar-track  { background: var(--bm-code-bg-scrollbar); border-radius: var(--bm-radius-sm); }
.bvw-body::-webkit-scrollbar-thumb  { background: #444; border-radius: var(--bm-radius-sm); }
.bvw-body::-webkit-scrollbar-thumb:hover { background: #5a5a5a; }
.bvw-body::-webkit-scrollbar-corner { background: var(--bm-code-bg); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .bvw-header       { padding: 0 10px 0 14px; }
  .bvw-header-title { font-size: 14px; }
  .bvw-body         { padding: 14px; }
  .bvw-tree         { font-size: 12px; }
}