/* ==========================================================================
   SchemCAD — Workshop Donor Box ("📦 Моя коробка плат-доноров")
   File: frontend/donor_box.css
   Strict .dbx-* Namespace + #donorBoxHitBanner Inspector Integration
   ========================================================================== */

.dbx-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--bg-canvas, #0b0e13);
  color: var(--text, #e8edf5);
  font-family: var(--sans, "Inter", "Segoe UI", system-ui, sans-serif);
  font-size: 12.5px;
  line-height: 1.4;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Top Section: My Scrap Donor Boards + Autocomplete Add Bar
   -------------------------------------------------------------------------- */
.dbx-top-box {
  background: linear-gradient(180deg, #161c27 0%, #121720 100%);
  border-bottom: 1px solid var(--border, #262f3d);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.dbx-top-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dbx-top-title-grp {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.dbx-top-title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text, #e8edf5);
  letter-spacing: -0.01em;
}

.dbx-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(44, 165, 104, 0.18);
  border: 1px solid rgba(44, 165, 104, 0.48);
  color: #6ee7b7;
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 700;
}

.dbx-btn-add-cur {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius, 5px);
  border: 1px solid rgba(220, 160, 58, 0.48);
  background: linear-gradient(180deg, rgba(220, 160, 58, 0.2) 0%, rgba(220, 160, 58, 0.09) 100%);
  color: #fde68a;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
  white-space: nowrap;
}

.dbx-btn-add-cur:hover:not(:disabled) {
  background: rgba(220, 160, 58, 0.28);
  border-color: rgba(220, 160, 58, 0.75);
}

.dbx-btn-add-cur:disabled {
  opacity: 0.52;
  cursor: default;
}

.dbx-btn-add-cur.is-saved {
  border-color: rgba(44, 165, 104, 0.5);
  background: rgba(44, 165, 104, 0.16);
  color: #86efac;
}

/* Autocomplete Board Add Row */
.dbx-add-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dbx-suggest-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.dbx-input {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 10px;
  border-radius: var(--radius, 5px);
  border: 1px solid var(--border-strong, #374357);
  background: var(--bg-canvas, #0b0e13);
  color: var(--text, #e8edf5);
  font-family: var(--sans, sans-serif);
  font-size: 12.5px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.dbx-input:focus {
  border-color: var(--pcb-green, #2ca568);
  box-shadow: 0 0 0 2px rgba(44, 165, 104, 0.2);
}

.dbx-input::placeholder {
  color: var(--text-muted, #657287);
}

.dbx-input-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim, #9aa6b8);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.dbx-input-clear.visible {
  display: inline-flex;
}

.dbx-input-clear:hover {
  background: var(--bg-hover, #273042);
  color: var(--text, #e8edf5);
}

.dbx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius, 5px);
  border: 1px solid var(--border-strong, #374357);
  background: var(--bg-elev, #202736);
  color: var(--text, #e8edf5);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}

.dbx-btn:hover:not(:disabled) {
  background: var(--bg-hover, #273042);
  border-color: #4b5b76;
}

.dbx-btn--green {
  background: linear-gradient(180deg, rgba(44, 165, 104, 0.28) 0%, rgba(44, 165, 104, 0.15) 100%);
  border-color: rgba(44, 165, 104, 0.6);
  color: #a7f3d0;
}

.dbx-btn--green:hover:not(:disabled) {
  background: rgba(44, 165, 104, 0.36);
  border-color: #34d399;
}

.dbx-btn--sm {
  height: 25px;
  padding: 0 8px;
  font-size: 11.5px;
}

/* Suggest Dropdown */
.dbx-suggest-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 250px;
  overflow-y: auto;
  background: #151b26;
  border: 1px solid var(--border-strong, #374357);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.62);
  z-index: 60;
  display: none;
}

.dbx-suggest-menu.open {
  display: block;
}

.dbx-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(38, 47, 61, 0.65);
  cursor: pointer;
  transition: background 90ms ease;
}

.dbx-suggest-item:last-child {
  border-bottom: none;
}

.dbx-suggest-item:hover,
.dbx-suggest-item.is-active {
  background: var(--bg-hover, #273042);
}

.dbx-suggest-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.dbx-suggest-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #e8edf5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dbx-suggest-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim, #9aa6b8);
}

.dbx-plat-tag {
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.38);
  color: #93c5fd;
}

.dbx-cad-tag {
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(44, 165, 104, 0.18);
  border: 1px solid rgba(44, 165, 104, 0.42);
  color: #6ee7b7;
}

.dbx-suggest-add {
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 700;
  color: #6ee7b7;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(44, 165, 104, 0.15);
  border: 1px solid rgba(44, 165, 104, 0.35);
  flex-shrink: 0;
}

.dbx-suggest-item.is-in-box .dbx-suggest-add {
  color: var(--text-dim, #9aa6b8);
  background: rgba(100, 116, 139, 0.16);
  border-color: rgba(100, 116, 139, 0.35);
}

/* Saved Scrap Boards Strip */
.dbx-saved-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-height: 76px;
  overflow-y: auto;
  padding-top: 2px;
}

.dbx-saved-empty {
  font-size: 11.5px;
  color: var(--text-muted, #657287);
  font-style: italic;
}

.dbx-board-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
  padding: 2px 5px 2px 8px;
  border-radius: 999px;
  background: var(--bg-panel-2, #191f2a);
  border: 1px solid var(--border-strong, #374357);
  color: var(--text, #e8edf5);
  font-size: 11.5px;
  transition: border-color 120ms ease, background 120ms ease;
}

.dbx-board-chip:hover {
  border-color: rgba(44, 165, 104, 0.55);
  background: #1e2736;
}

.dbx-board-chip-lbl {
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.dbx-board-chip-lbl:hover {
  color: #6ee7b7;
}

.dbx-board-chip-del {
  width: 17px;
  height: 17px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted, #657287);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dbx-board-chip-del:hover {
  background: rgba(223, 84, 84, 0.22);
  color: #fca5a5;
}

/* --------------------------------------------------------------------------
   Navigation Tabs (Search vs Full Box Inventory)
   -------------------------------------------------------------------------- */
.dbx-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--bg-panel, #13171f);
  border-bottom: 1px solid var(--border, #262f3d);
  flex-shrink: 0;
}

.dbx-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}

.dbx-tab {
  position: relative;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim, #9aa6b8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.dbx-tab:hover {
  color: var(--text, #e8edf5);
}

.dbx-tab.active {
  color: #6ee7b7;
  border-bottom-color: var(--pcb-green, #2ca568);
}

.dbx-io-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

/* --------------------------------------------------------------------------
   Tab Panes & Search Controls
   -------------------------------------------------------------------------- */
.dbx-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.dbx-pane.active {
  display: flex;
}

.dbx-search-bar {
  padding: 10px 12px 8px;
  background: var(--bg-panel, #13171f);
  border-bottom: 1px solid var(--border, #262f3d);
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}

.dbx-search-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dbx-quick-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.dbx-quick-lbl {
  font-size: 11px;
  color: var(--text-muted, #657287);
  margin-right: 2px;
}

.dbx-qchip {
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border, #262f3d);
  background: var(--bg-panel-2, #191f2a);
  color: var(--text-dim, #9aa6b8);
  font-family: var(--mono, monospace);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 110ms ease, color 110ms ease, background 110ms ease;
}

.dbx-qchip:hover {
  border-color: var(--accent, #dca03a);
  color: #fde68a;
  background: rgba(220, 160, 58, 0.1);
}

.dbx-qchip--ctx {
  border-color: rgba(59, 130, 246, 0.48);
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
}

/* Scrollable Results Area */
.dbx-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   Search Hit Banner ("✅ НАЙДЕНО У ВАС НА ДОНОРЕ!") & Match Cards
   -------------------------------------------------------------------------- */
.dbx-hit-hero {
  border-radius: 7px;
  border: 1px solid rgba(44, 165, 104, 0.65);
  background: linear-gradient(180deg, rgba(16, 68, 45, 0.52) 0%, rgba(15, 34, 28, 0.42) 100%);
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.1);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dbx-hit-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dbx-hit-badge-big {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #6ee7b7;
}

.dbx-chip-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-panel, #13171f);
  border: 1px solid var(--border, #262f3d);
}

.dbx-chip-id {
  font-family: var(--mono, monospace);
  font-size: 14px;
  font-weight: 700;
  color: #fde68a;
}

.dbx-cat-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(220, 160, 58, 0.14);
  border: 1px solid rgba(220, 160, 58, 0.35);
  color: #fcd34d;
}

.dbx-1v8-pill {
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(223, 84, 84, 0.2);
  border: 1px solid rgba(223, 84, 84, 0.55);
  color: #fca5a5;
}

.dbx-match-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dbx-match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(13, 19, 27, 0.88);
  border: 1px solid rgba(44, 165, 104, 0.38);
}

.dbx-match-row.is-equiv {
  border-color: rgba(220, 160, 58, 0.45);
}

.dbx-match-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.dbx-match-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dbx-match-board {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text, #e8edf5);
}

.dbx-refdes-pill {
  font-family: var(--mono, monospace);
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(44, 165, 104, 0.22);
  border: 1px solid rgba(44, 165, 104, 0.55);
  color: #86efac;
}

.dbx-exact-pill {
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(44, 165, 104, 0.15);
  color: #6ee7b7;
}

.dbx-equiv-pill {
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(220, 160, 58, 0.18);
  border: 1px solid rgba(220, 160, 58, 0.42);
  color: #fde68a;
}

.dbx-miss-box {
  border-radius: 6px;
  border: 1px solid var(--border-strong, #374357);
  background: var(--bg-panel, #13171f);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dbx-miss-title {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text, #e8edf5);
}

.dbx-sec-card {
  border-radius: 6px;
  border: 1px solid var(--border, #262f3d);
  background: var(--bg-panel, #13171f);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dbx-sec-head {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-dim, #9aa6b8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Inventory Tab
   -------------------------------------------------------------------------- */
.dbx-inv-toolbar {
  padding: 9px 12px;
  background: var(--bg-panel, #13171f);
  border-bottom: 1px solid var(--border, #262f3d);
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}

.dbx-inv-kpi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dbx-inv-kpi {
  font-size: 12px;
  color: var(--text-dim, #9aa6b8);
}

.dbx-inv-kpi strong {
  color: #6ee7b7;
  font-family: var(--mono, monospace);
}

.dbx-cat-strip {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.dbx-cat-btn {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border, #262f3d);
  background: var(--bg-panel-2, #191f2a);
  color: var(--text-dim, #9aa6b8);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.dbx-cat-btn.active {
  background: rgba(44, 165, 104, 0.2);
  border-color: rgba(44, 165, 104, 0.55);
  color: #6ee7b7;
}

.dbx-inv-card {
  border-radius: 6px;
  border: 1px solid var(--border, #262f3d);
  background: var(--bg-panel, #13171f);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dbx-inv-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dbx-inv-donors {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dbx-inv-donor-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(44, 165, 104, 0.38);
  background: rgba(44, 165, 104, 0.11);
  color: #a7f3d0;
  font-family: var(--mono, monospace);
  font-size: 11px;
  cursor: pointer;
}

.dbx-inv-donor-btn:hover {
  background: rgba(44, 165, 104, 0.24);
  border-color: #34d399;
}

.dbx-empty-state {
  padding: 26px 16px;
  text-align: center;
  color: var(--text-dim, #9aa6b8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dbx-footer {
  padding: 6px 12px;
  border-top: 1px solid var(--border, #262f3d);
  background: var(--bg-panel, #13171f);
  font-size: 11px;
  color: var(--text-dim, #9aa6b8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.dbx-footer.is-ok {
  color: #6ee7b7;
}

.dbx-footer.is-err {
  color: #fca5a5;
}

/* --------------------------------------------------------------------------
   Live Inspector Banner (#donorBoxHitBanner inside #inspectorBody)
   -------------------------------------------------------------------------- */
#donorBoxHitBanner {
  margin: 0 0 8px 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(44, 165, 104, 0.62);
  border-left: 3px solid #34d399;
  background: linear-gradient(90deg, rgba(16, 72, 48, 0.56) 0%, rgba(19, 28, 38, 0.92) 100%);
  color: #ecfdf5;
  font-size: 12px;
  line-height: 1.38;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.dbx-insp-text {
  min-width: 0;
  flex: 1;
}

.dbx-insp-text strong {
  color: #6ee7b7;
  font-family: var(--mono, monospace);
}

.dbx-insp-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.dbx-insp-open-btn {
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(52, 211, 153, 0.65);
  background: rgba(44, 165, 104, 0.25);
  color: #a7f3d0;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.dbx-insp-open-btn:hover {
  background: rgba(44, 165, 104, 0.42);
  color: #ffffff;
}

.dbx-insp-more-btn {
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-strong, #374357);
  background: var(--bg-elev, #202736);
  color: var(--text-dim, #9aa6b8);
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  cursor: pointer;
}

.dbx-insp-more-btn:hover {
  color: var(--text, #e8edf5);
  border-color: #4b5b76;
}

/* Fallback Modal Wrapper when CadWindowManager is absent */
.dbx-fallback-modal {
  position: fixed;
  inset: 52px 16px 16px auto;
  width: min(760px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 76px));
  background: var(--bg-canvas, #0b0e13);
  border: 1px solid var(--border-strong, #374357);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.72);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dbx-fallback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-panel, #13171f);
  border-bottom: 1px solid var(--border, #262f3d);
  font-weight: 700;
}

@media (max-width: 768px) {
  .dbx-match-row {
    flex-direction: column;
    align-items: stretch;
  }
  .dbx-match-row .dbx-btn {
    width: 100%;
  }
  .dbx-tabs-bar {
    flex-wrap: wrap;
    padding-bottom: 4px;
  }
}
