/*
 * Phase 127 — Director's Board
 * Full-feature blocking & pre-vis app replacing "Spatial Studio"
 */

/* ── Override phase110 nuclear hide rule ────────────────────────────────
   phase110-podcast-spatial-polish.css hides every #spatial-app child that
   is not #p100-spatial-suite via !important. Since phase127 loads later and
   targets the ID directly, these !important rules win the cascade.          */
body #db-directors-board,
body[data-active-view] #db-directors-board,
body[data-active-view="spatial-app"] #db-directors-board,
#spatial-app #db-directors-board {
  display:           flex    !important;
  visibility:        visible !important;
  pointer-events:    auto    !important;
  opacity:           1       !important;
  position:          absolute !important;
  top:    0          !important;
  left:   0          !important;
  right:  0          !important;
  bottom: 0          !important;
  width:  100%       !important;
  height: 100%       !important;
  overflow: hidden   !important;
  z-index: 10        !important;
}

/* ── Shell ─────────────────────────────────────────────────────────────── */
#db-directors-board {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #f8f6f2;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  color: #1e293b;
  z-index: 5;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
#db-header {
  flex-shrink: 0;
  background: #1a1d2e;
  color: #f1f5f9;
  border-bottom: 1px solid rgba(255,255,255,.08);
  user-select: none;
}

.db-header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  flex-wrap: wrap;
}

.db-sidebar-toggle {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #94a3b8;
  border-radius: 7px;
  padding: 5px 9px;
  font-size: .82rem;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.db-sidebar-toggle:hover { background: rgba(255,255,255,.14); color: #fff; }
.db-sidebar-toggle.sidebar-open { color: #60a5fa; border-color: rgba(96,165,250,.35); }

.db-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 900;
  font-size: .95rem;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.db-brand-icon { font-size: 1.1rem; }
.db-brand-name { color: #f1f5f9; }

.db-scene-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}
.db-scene-lbl {
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: #64748b;
  white-space: nowrap;
}
#db-scene-select {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #f1f5f9;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 240px;
}
#db-scene-select option { background: #1e293b; color: #f1f5f9; }

.db-scene-meta {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.db-meta-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: .65rem;
  font-weight: 800;
  background: rgba(37,99,235,.25);
  color: #93c5fd;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.db-meta-badge.night {
  background: rgba(124,58,237,.22);
  color: #c4b5fd;
}

.db-header-spacer { flex: 1; }

.db-header-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.db-hbtn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 5px 11px;
  font-size: .74rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .14s, color .14s;
  white-space: nowrap;
}
.db-hbtn:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── Setup tabs row ─────────────────────────────────────────────────────── */
.db-header-bottom {
  display: flex;
  align-items: center;
  padding: 0 14px 0 44px;
  gap: 4px;
  border-top: 1px solid rgba(255,255,255,.06);
  overflow-x: auto;
  scrollbar-width: none;
}
.db-header-bottom::-webkit-scrollbar { display: none; }

.db-tabs {
  display: flex;
  gap: 2px;
  align-items: stretch;
  min-height: 34px;
}
.db-tabs-hint {
  font-size: .72rem;
  color: #475569;
  padding: 8px 0;
}

.db-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  background: rgba(255,255,255,.04);
  border-radius: 8px 8px 0 0;
  border: 1px solid rgba(255,255,255,.07);
  border-bottom: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background .14s, color .14s;
  min-height: 34px;
}
.db-tab:hover { background: rgba(255,255,255,.09); color: #e2e8f0; }
.db-tab.active {
  background: #f8f6f2;
  color: #1e293b;
  border-color: rgba(255,255,255,.12);
}

.db-tab-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.db-tab-btns { display: none; gap: 2px; }
.db-tab:hover .db-tab-btns,
.db-tab.active .db-tab-btns { display: flex; }
.db-tab-btns button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: .72rem;
  padding: 1px 3px;
  opacity: .6;
  line-height: 1;
  border-radius: 3px;
}
.db-tab-btns button:hover { opacity: 1; background: rgba(0,0,0,.08); }

.db-add-tab {
  background: none;
  border: none;
  color: #475569;
  cursor: pointer;
  font-size: .74rem;
  font-weight: 800;
  padding: 0 8px;
  white-space: nowrap;
  align-self: center;
  transition: color .13s;
}
.db-add-tab:hover { color: #60a5fa; }

/* ── Body ────────────────────────────────────────────────────────────────── */
#db-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#db-sidebar {
  flex-shrink: 0;
  width: 248px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .22s ease, opacity .22s ease;
}
#db-sidebar.closed {
  width: 0;
  opacity: 0;
  pointer-events: none;
}
#db-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0 24px;
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
}

/* stats chips at top of sidebar */
.db-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px 4px;
}
.db-stat-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: #f1f5f9;
  color: #475569;
}
.db-stat-chip.secondary { background: #ede9fe; color: #6d28d9; }
.db-stat-chip.info      { background: #dbeafe; color: #1d4ed8; }
.db-stat-chip.cast      { background: #fce7f3; color: #be185d; }
.db-stat-chip.light     { /* color/bg set inline */ }

.db-loc-chip {
  font-size: .68rem;
  color: #64748b;
  padding: 0 12px 6px;
  font-weight: 600;
}

/* ── Section accordion ───────────────────────────────────────────────────── */
.db-section { border-bottom: 1px solid #f1f5f9; }

.db-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: .73rem;
  font-weight: 800;
  color: #334155;
  user-select: none;
  transition: background .12s;
}
.db-section-head:hover { background: #f8fafc; }
.db-section-head.open { color: #1e40af; }

.db-sec-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  color: #475569;
  border-radius: 10px;
  font-size: .58rem;
  font-weight: 800;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
}
.db-section-head.open .db-sec-count { background: #dbeafe; color: #1d4ed8; }
.db-sec-caret { margin-left: auto; font-size: .7rem; }

.db-section-body { padding: 4px 10px 10px; }

/* ── Cast chips ──────────────────────────────────────────────────────────── */
.db-char-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 4px;
  border-radius: 8px;
  margin-bottom: 3px;
  transition: background .12s;
}
.db-char-chip:hover { background: #f8fafc; }
.db-char-av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.db-char-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.db-char-name { font-size: .73rem; font-weight: 700; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-char-role { font-size: .6rem; color: #94a3b8; font-weight: 600; }

/* ── Shot rows ───────────────────────────────────────────────────────────── */
.db-shot-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  border-radius: 6px;
  font-size: .71rem;
  transition: background .1s;
}
.db-shot-row:hover { background: #f8fafc; }
.db-shot-row.covered { opacity: .45; }
.db-shot-row.covered .db-shot-desc { text-decoration: line-through; }

.db-shot-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: .6rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.db-shot-type {
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 4px;
  font-size: .58rem;
  font-weight: 800;
  padding: 1px 4px;
  flex-shrink: 0;
  letter-spacing: .03em;
}
.db-shot-desc {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #334155;
  font-weight: 600;
}
.db-shot-cover {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: .65rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, color .12s;
  padding: 0;
}
.db-shot-cover:hover { background: #d1fae5; border-color: #10b981; color: #10b981; }
.db-shot-row.covered .db-shot-cover { background: #d1fae5; border-color: #10b981; color: #10b981; }

/* ── Lighting card ───────────────────────────────────────────────────────── */
.db-light-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  margin-top: 2px;
}
.db-light-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  font-size: .7rem;
}
.db-light-k { color: #94a3b8; font-weight: 700; flex-shrink: 0; }
.db-light-v { color: #1e293b; font-weight: 700; text-align: right; }

/* ── Props ───────────────────────────────────────────────────────────────── */
.db-prop-list { display: flex; flex-wrap: wrap; gap: 4px; }
.db-prop-chip {
  display: inline-block;
  padding: 3px 8px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 5px;
  font-size: .65rem;
  font-weight: 700;
}

/* ── Scene note + setup notes textarea ───────────────────────────────────── */
.db-scene-note-text {
  font-size: .7rem;
  color: #64748b;
  line-height: 1.55;
  padding: 6px 0 8px;
  white-space: pre-wrap;
}
.db-notes-input {
  width: 100%;
  min-height: 90px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .73rem;
  line-height: 1.55;
  color: #334155;
  background: #f8fafc;
  resize: vertical;
  font-family: inherit;
  transition: border-color .14s;
}
.db-notes-input:focus { border-color: #2563eb; outline: none; background: #fff; }

/* ── Empty / nil states ──────────────────────────────────────────────────── */
.db-nil {
  font-size: .68rem;
  color: #94a3b8;
  line-height: 1.55;
  font-style: italic;
  padding: 2px 0 4px;
}
.db-empty-state {
  padding: 28px 20px;
  text-align: center;
  color: #94a3b8;
}
.db-empty-icon { font-size: 2rem; margin-bottom: 10px; }
.db-empty-state p { font-size: .74rem; line-height: 1.65; }

/* ── Canvas region ───────────────────────────────────────────────────────── */
#db-canvas-region {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--scc-bg, #1a1d2e);
  min-width: 0;
}

/* placeholder when binder not yet moved in */
#db-canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #475569;
  padding: 40px;
  text-align: center;
}
.db-ph-icon  { font-size: 2.8rem; }
.db-ph-title { font-size: .95rem; font-weight: 800; color: #64748b; }
.db-ph-sub   { font-size: .78rem; line-height: 1.65; max-width: 340px; color: #475569; }
.db-ph-sub strong { color: #93c5fd; }

/* ensure scc-binder fills canvas region completely and overrides inline display:none */
#db-canvas-region #scc-binder {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  flex: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  /* Light warm canvas — replaces the dark #1a1d2e navy */
  background: #f2ede4 !important;
}

/* Light warm canvas: override the CSS variable so the grid pattern
   picks up the new background and uses amber lines visible on cream. */
#db-canvas-region {
  --scc-bg:   #f2ede4;
  --scc-grid: rgba(160, 120, 50, 0.14);
  background: #f2ede4;
}

/* floor-plan and blocking panels — white cards floating over the canvas */
#db-canvas-region #cbs-fp-panel,
#db-canvas-region #cbs-blk-panel {
  background: #ffffff !important;
  color: #1e293b !important;
  box-shadow: 0 4px 24px rgba(0,0,0,.13) !important;
  border-radius: 14px !important;
  border: 1px solid #e5e7eb !important;
}

/* Panel toggle strip (added by db127PatchPanelHeader) */
.db127-panel-toggle {
  display: flex;
  border-radius: 9px;
  overflow: hidden;
  border: 2px solid #7c3aed;
  margin: 0 0 10px;
}
.db127-panel-toggle .db127-pt-active {
  flex: 1;
  padding: 7px 10px;
  background: #7c3aed;
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
}
.db127-panel-toggle .db127-pt-switch {
  flex: 1;
  padding: 7px 10px;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: .72rem;
  font-weight: 900;
  border: none;
  cursor: pointer;
  transition: background .15s;
}
.db127-panel-toggle .db127-pt-switch:hover { background: #ede9fe; }

/* ── Mobile / responsive ─────────────────────────────────────────────────── */
@media (max-width: 760px) {
  /* sidebar becomes a slide-over drawer */
  #db-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: 260px !important;
    box-shadow: 4px 0 24px rgba(0,0,0,.22);
    transition: transform .22s ease, opacity .22s ease;
    transform: translateX(0);
  }
  #db-sidebar.closed {
    width: 260px !important;
    transform: translateX(-100%);
    opacity: 1;
    pointer-events: none;
  }

  .db-brand-name { display: none; }
  .db-header-top { flex-wrap: nowrap; overflow-x: auto; gap: 7px; padding: 8px 10px; }
  #db-scene-select { max-width: 160px; }
  .db-hbtn { padding: 5px 8px; font-size: .68rem; }
  .db-header-bottom { padding-left: 10px; }

  .db-tab-name { max-width: 90px; }

  /* stack scene meta badges */
  .db-scene-meta { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .db-header-btns { display: none; }  /* rely on report button in sidebar on very small screens */
  #db-scene-select { max-width: 130px; }
}

/* ── Flash prevention ───────────────────────────────────────────────────────
   Give #spatial-app the Director's Board cream bg so there's never a dark
   flash before the board mounts.                                            */
#spatial-app {
  background: #f8f6f2 !important;
}
/* Hide the old Spatial Studio suite entirely — Director's Board replaces it */
#p100-spatial-suite {
  display: none !important;
}

/* ── Room / location tab bar ────────────────────────────────────────────────
   Floats at the top-centre of the canvas region.  Appears faint when only
   one room exists; fully visible once a second room is added.              */
#db-room-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 3px 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .10);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .68rem;
  font-weight: 700;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* When there's only 1 room: show faintly — user can still click + Room */
  opacity: 0.45;
  transition: opacity 0.2s ease;
  pointer-events: auto;
}
#db-room-bar:hover,
#db-room-bar.db-room-bar-multi {
  opacity: 1;
}
#db-room-bar .db-room-tab {
  padding: 4px 11px;
  border-radius: 14px;
  cursor: pointer;
  color: #475569;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
#db-room-bar .db-room-tab:hover:not(.active) {
  background: #f1f5f9;
  color: #1e293b;
}
#db-room-bar .db-room-tab.active {
  background: #7c3aed;
  color: #fff;
}
#db-room-bar .db-room-add {
  padding: 4px 10px;
  background: none;
  border: 1.5px dashed #94a3b8;
  border-radius: 14px;
  cursor: pointer;
  color: #64748b;
  font-size: .66rem;
  font-weight: 800;
  transition: border-color 0.15s, color 0.15s;
}
#db-room-bar .db-room-add:hover {
  border-color: #7c3aed;
  color: #7c3aed;
}

/* ── Set dress / floor plan piece labels ────────────────────────────────────
   phase-126 renders labels at .58rem inside .cbs-fp-piece.
   Boost these so set dress text is legible on the canvas.                   */
#db-canvas-region .cbs-fp-piece {
  font-size: .84rem !important;
  overflow: visible !important;
}
#db-canvas-region .cbs-fp-piece span:last-child {
  font-size: .74rem  !important;
  font-weight: 900   !important;
  color: #78350f     !important;
  letter-spacing: .01em;
  max-width: 100%;
  white-space: nowrap;
  padding: 0 3px;
  text-shadow: 0 0 4px rgba(242,237,228,0.9);  /* halo for legibility */
}
/* Props imported into blocking view — same treatment */
#db-canvas-region .db127-blk-prop-chip span {
  font-size: .72rem  !important;
  font-weight: 800   !important;
  color: #1e293b     !important;
}

/* ── Set piece delete button ────────────────────────────────────────────────
   Phase-127 injects a .db127-piece-del × button into each .cbs-fp-piece.
   Hidden by default; appears on hover via JS mouseenter/mouseleave.         */
#db-canvas-region .db127-piece-del {
  display: none;          /* shown on piece mouseenter via JS */
  position: absolute;
  top: -9px;
  right: -9px;
  width: 19px;
  height: 19px;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  z-index: 999;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  transition: background 0.1s, transform 0.1s;
  pointer-events: auto !important;
}
#db-canvas-region .db127-piece-del:hover {
  background: #b91c1c;
  transform: scale(1.15);
}

/* Highlight set pieces in blocking mode so they're obviously clickable anchors */
#db-canvas-region .cbs-fp-piece {
  transition: box-shadow 0.15s, transform 0.12s;
}
#db-canvas-region .cbs-fp-piece:hover {
  box-shadow: 0 0 0 2.5px #7c3aed, 0 3px 12px rgba(124,58,237,.25) !important;
  transform: scale(1.06);
  z-index: 50 !important;
}
