/* ============================================================
   DRAG & DROP
   ============================================================ */

/* Wrap: viewport + dock layout */
.bb-wrap {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 8px;
  height: 100%;
  min-height: 420px;
  align-items: stretch;
}
.bb-wrap .bb-viewport {
  position: relative;
  overflow: hidden;
  height: 100%;
  min-height: 420px;
}

/* ============================================================
   INVENTORY DOCK (right-side draggable source panel)
   ============================================================ */
.bb-dock {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-dark) 100%);
  border: 3px solid var(--brass-dark);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  padding: 8px;
  gap: 6px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.3),
    0 2px 4px rgba(0,0,0,0.2);
  transition: background 0.15s, box-shadow 0.15s;
  min-height: 420px;
}
.bb-dock.drop-hover {
  background: rgba(255, 217, 125, 0.4);
  box-shadow:
    0 0 0 2px var(--gold),
    inset 0 2px 0 rgba(255,255,255,0.3);
}

.bb-dock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--paper-edge);
}
.bb-dock-title {
  font-family: 'Didot', Georgia, serif;
  font-size: 10px;
  letter-spacing: 3px;
  font-weight: bold;
  color: var(--ink);
}
.bb-dock-count {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  background: var(--ink);
  color: var(--gold);
  padding: 1px 6px;
  border-radius: 2px;
  min-width: 18px;
  text-align: center;
}

.bb-dock-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 60px;
  padding-right: 2px;
}

.bb-dock-empty {
  font-family: Georgia, serif;
  font-size: 11px;
  font-style: italic;
  color: var(--ink-light);
  text-align: center;
  padding: 14px 4px;
  line-height: 1.4;
}
.bb-dock-empty span {
  font-size: 9px;
  opacity: 0.7;
  display: block;
  margin-top: 4px;
}

.bb-dock-hint {
  font-family: Georgia, serif;
  font-size: 9px;
  font-style: italic;
  color: var(--ink-light);
  text-align: center;
  padding-top: 4px;
  border-top: 1px dashed var(--paper-edge);
  letter-spacing: 0.5px;
}

/* Dock pills (draggable sources) */
.bb-dock-pill {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 4px;
  align-items: center;
  padding: 4px 6px;
  background: rgba(253,240,213,0.9);
  border: 1px solid var(--paper-edge);
  border-left: 3px solid var(--brass);
  border-radius: 2px;
  cursor: grab;
  user-select: none;
  transition: transform 0.1s, background 0.12s, box-shadow 0.12s;
}
.bb-dock-pill:hover {
  background: rgba(255, 217, 125, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.bb-dock-pill:active { cursor: grabbing; }
.bb-dock-pill.is-dragging { opacity: 0.4; }

/* Zone-color left border */
.bb-dock-pill.zone-9v   { border-left-color: var(--copper); }
.bb-dock-pill.zone-5v   { border-left-color: #5aa0c4; }
.bb-dock-pill.zone-3v   { border-left-color: #68c47e; }
.bb-dock-pill.zone-1_5v { border-left-color: #aaaaaa; }

.bb-dock-pill-zone {
  font-family: 'Courier New', monospace;
  font-size: 9px;
  font-weight: bold;
  background: var(--ink);
  color: var(--gold);
  padding: 1px 4px;
  border-radius: 2px;
}
.bb-dock-pill-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}
.bb-dock-pill-icon svg { max-width: 100%; max-height: 100%; }
.bb-dock-pill-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.1;
}
.bb-dock-pill-name {
  font-weight: bold;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}
.bb-dock-pill-draw {
  font-family: 'Courier New', monospace;
  font-size: 9px;
  color: var(--ink-light);
}
.bb-dock-pill-tune {
  font-family: 'Courier New', monospace;
  font-size: 8px;
  color: var(--brass-dark);
  background: rgba(201,169,97,0.2);
  padding: 1px 3px;
  border-radius: 2px;
}

/* ============================================================
   LOOSE PARTS (floating chips on the board canvas)
   ============================================================ */
.bb-loose {
  position: absolute;
  width: 96px;
  min-height: 96px;
  background: rgba(40, 20, 20, 0.92);
  border: 2px dashed var(--bad);
  border-radius: 5px;
  color: #ffcaca;
  font-family: Georgia, serif;
  padding: 8px 4px 6px;
  text-align: center;
  cursor: grab;
  user-select: none;
  box-shadow:
    0 4px 10px rgba(166, 48, 48, 0.45),
    inset 0 0 12px rgba(166, 48, 48, 0.2);
  animation: loosePulse 2s infinite ease-in-out;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
@keyframes loosePulse {
  0%, 100% { box-shadow: 0 4px 10px rgba(166,48,48,0.45), inset 0 0 12px rgba(166,48,48,0.2); }
  50%      { box-shadow: 0 4px 14px rgba(166,48,48,0.65), inset 0 0 18px rgba(166,48,48,0.35); }
}
.bb-loose:active { cursor: grabbing; }
.bb-loose.is-dragging { opacity: 0.4; }

.bb-loose-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: var(--bad);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: bold;
  line-height: 20px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.4);
}

.bb-loose-icon {
  width: 32px;
  height: 32px;
  margin-top: 4px;
  opacity: 0.95;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bb-loose-icon svg {
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(0 0 3px rgba(255, 200, 200, 0.4));
}
.bb-loose-name {
  font-size: 9px;
  font-weight: bold;
  line-height: 1.1;
  color: #ffcaca;
  padding: 0 2px;
}
.bb-loose-sub {
  font-size: 8px;
  color: rgba(255, 202, 202, 0.7);
  font-family: 'Courier New', monospace;
}
.bb-loose-tune {
  font-size: 8px;
  color: #ffd97d;
  margin-top: 1px;
  font-family: 'Courier New', monospace;
}
.bb-loose-remove {
  position: absolute;
  top: 2px;
  left: 2px;
  background: transparent;
  border: none;
  color: rgba(255, 202, 202, 0.6);
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 2px;
  line-height: 1;
}
.bb-loose-remove:hover { background: var(--bad); color: #fff; }

/* ============================================================
   DROP-TARGET HIGHLIGHTING
   ============================================================ */
.bb-chip-empty.drop-valid {
  border-color: var(--green) !important;
  background: rgba(74,133,87,0.25) !important;
  box-shadow:
    0 0 0 2px var(--green),
    0 0 16px rgba(74,133,87,0.6) !important;
  animation: dropValidPulse 0.8s infinite alternate;
}
@keyframes dropValidPulse {
  to { box-shadow: 0 0 0 2px var(--green), 0 0 20px rgba(74,133,87,0.9); }
}
.bb-chip-empty.drop-invalid {
  border-color: var(--bad) !important;
  background: rgba(166,48,48,0.18) !important;
  box-shadow: 0 0 0 2px var(--bad);
  cursor: not-allowed;
}

/* Dim all empty slots during drag, except the one currently hovered —
   this focuses attention on the actual target as the cursor moves. */
body.dnd-active .bb-chip-empty { opacity: 0.65; transition: opacity 0.12s, box-shadow 0.12s; }
body.dnd-active .bb-chip-empty.drop-valid,
body.dnd-active .bb-chip-empty.drop-invalid { opacity: 1; }

/* ============================================================
   LOOSE PARTS BANNER (list view) + SHIP GATE
   ============================================================ */
.loose-banner {
  background: linear-gradient(180deg, rgba(166,48,48,0.95) 0%, rgba(107,24,24,0.95) 100%);
  color: #ffe5cc;
  border: 2px solid var(--bad);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-family: Georgia, serif;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.loose-banner-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.loose-banner-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.3;
}
.loose-banner-text strong {
  letter-spacing: 1px;
  color: #fff;
  display: block;
  margin-bottom: 2px;
  font-family: 'Didot', Georgia, serif;
  font-size: 13px;
}
.loose-banner-cta {
  background: var(--bad);
  color: #fff;
  border: 1px solid #fff;
  padding: 4px 10px;
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 2px;
}
.loose-banner-cta:hover { background: #c23030; }

/* Disabled SHIP button styling */
#btnApprove.gated {
  background: rgba(43, 24, 16, 0.4) !important;
  color: rgba(255, 255, 255, 0.4) !important;
  cursor: not-allowed;
  box-shadow: none !important;
}
#btnApprove.gated:hover { transform: none; }
