/* Triune AV Planner — Tela 03 Builder de equipamento
   Mobile-first com expansão pra tablet/desktop. */

/* glyph do conector na pré-visualização (atualiza ao vivo) */
.bld-prev-badge-conn { display: flex; align-items: center; justify-content: center; }
.bld-prev-badge { display: flex; flex-direction: column; align-items: center; gap: 3px; }

.bld {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 58px - 60px);
}

.bld-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.bld-crumb {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}
.bld-crumb-back {
  font-size: 12.5px;
  font-weight: 300;
  color: var(--txt-3);
  text-decoration: none;
}
.bld-crumb-back:hover { color: var(--red); }
.bld-crumb-now {
  font-size: 17px;
  font-weight: 600;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bld-top-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* === SPLIT — mobile-first === */
.bld-split {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
  min-height: 0;
}
.bld-left,
.bld-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

@media (min-width: 900px) {
  .bld-split {
    display: grid;
    grid-template-columns: 1fr 480px;
    gap: 24px;
  }
  .bld-left {
    padding-right: 20px;
    border-right: 1px solid var(--line-2);
    gap: 20px;
  }
}

@media (min-width: 1280px) {
  .bld-split {
    grid-template-columns: 1fr 520px;
  }
}

.bld-section-lbl {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--txt-4);
  text-transform: uppercase;
}

/* === PREVIEW (estilo Patchify) === */
.bld-preview {
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 30px 18px;
}
.bld-prev-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.bld-prev-card {
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 240px;
  max-width: 320px;
}
.bld-prev-mfg {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.bld-prev-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.15;
  word-break: break-word;
}
.bld-prev-cat {
  font-size: 9.5px;
  color: rgba(255,255,255,0.4);
  margin-top: 6px;
  letter-spacing: 0.6px;
}
.bld-prev-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  padding: 0 8px;
}
.bld-prev-top    { margin-bottom: 4px; z-index: 2; }
.bld-prev-bottom { margin-top: 4px; z-index: 2; }
/* Espelhado: OUT (topo) nome+conector em cima, caixa junto ao card.
   IN (base) caixa junto ao card, conector+nome embaixo. */
.bld-prev-top .bld-prev-badge { flex-direction: column-reverse; }
.bld-prev-bottom .bld-prev-badge { flex-direction: column; }
.bld-prev-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  flex: 0 0 auto;
}
.bld-prev-badge-box {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.bld-prev-badge-lbl {
  font-size: 9px;
  color: var(--txt-3);
  max-width: 70px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === FORM === */
.field-color {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-color input[type="text"] { flex: 1; }
.field-color input[type="color"] {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-3);
  cursor: pointer;
  flex-shrink: 0;
}
.form-grid textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  color: var(--txt);
  font-family: inherit;
  font-size: 16px;     /* DEV6 */
  outline: none;
  resize: vertical;
  min-height: 60px;
  width: 100%;
}
.form-grid textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

/* === TABS (Entradas / Saídas) === */
.bld-tabs {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--line-3);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
  align-self: flex-start;
}
.bld-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--txt-3);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
}
.bld-tab.is-active { background: var(--bg-3); color: var(--txt); }
.bld-tab-count {
  font-size: 11px;
  color: var(--red);
  font-weight: 600;
}
.bld-tab:not(.is-active) .bld-tab-count { color: var(--txt-3); }

/* === LISTA DE PORTAS === */
.bld-ports {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.bld-port-row {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "name bi del"
    "sels sels sels";
  gap: 8px;
  align-items: center;
}
.bld-port-drag { display: none; } /* mobile esconde — drag funcional vem em entrega futura */

.bld-port-name {
  grid-area: name;
  background: transparent;
  border: 1px solid transparent;
  color: var(--txt);
  font-family: var(--font-mono);
  font-size: 13px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  outline: none;
  width: 100%;
  min-width: 0;
}
.bld-port-name:focus, .bld-port-name:hover {
  background: var(--bg-3);
  border-color: var(--line);
}

.bld-port-selects {
  grid-area: sels;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
/* Wrapper agora é só layout — os comboboxes custom têm border próprio */
.bld-port-sel {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.bld-port-sel .cb { width: 100%; }
.bld-port-sel .cb-btn { height: 36px; }
.bld-port-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

.bld-bi-toggle {
  grid-area: bi;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--txt-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bld-bi-toggle:hover { color: var(--txt-2); }
.bld-bi-toggle.is-active {
  background: rgba(243,156,18,0.13);
  border-color: rgba(243,156,18,0.4);
  color: var(--warn);
}

.bld-port-del {
  grid-area: del;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--txt-4);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bld-port-del:hover { color: var(--err); background: var(--red-soft); border-color: var(--red-line); }

/* Desktop: linha mais compacta (1 linha só).
   Selects ganham MUITO mais espaço (minmax 240px) pra os comboboxes de
   conector/sinal não cortarem o texto ("R..." / "H..." / "E..." → RJ45/HDMI). */
@media (min-width: 900px) {
  .bld-port-row {
    grid-template-columns: 14px minmax(80px, 0.7fr) minmax(240px, 1.6fr) 36px 36px;
    grid-template-areas: "drag name sels bi del";
    padding: 8px 10px;
  }
  .bld-port-drag { display: block; color: var(--txt-4); cursor: grab; grid-area: drag; }
  .bld-port-selects { grid-template-columns: 1fr 1fr; }
}

.bld-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--txt-3);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}

/* === ADD + BATCH === */
.bld-add-group {
  display: flex;
  gap: 6px;
}
.bld-add-port {
  flex: 1;
  height: 40px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--red);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}
.bld-add-port:hover { background: var(--red-soft); border-color: var(--red); }
.bld-batch-port {
  height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--txt-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.bld-batch-port:hover { border-color: var(--red); color: var(--red); }

.bld-batch-form {
  display: grid;
  gap: 14px;
}

.bld-info {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 11px 13px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: var(--txt-3);
  font-size: 11.5px;
  line-height: 1.5;
  font-weight: 300;
}
.bld-info svg { color: var(--info); flex-shrink: 0; margin-top: 2px; }

/* === COMBO JACK (porta com 2 conectores: XLR + P10, etc) === */
/* O slot do conector pode conter [primário] [+] [alt] [×] quando combo ativo.
   Visualmente fica como "XLR + P10" lado a lado, deixando claro que a porta
   física aceita os dois. Só faz sentido pra áudio analógico (R1.1 cross-compat). */
.bld-port-sel-conn {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.bld-port-sel-conn .cb { flex: 1; min-width: 0; }
.bld-combo-plus {
  font-size: 13px; font-weight: 700; color: var(--txt-4);
  flex-shrink: 0;
}
.bld-combo-add, .bld-combo-rm {
  display: inline-flex; align-items: center; justify-content: center;
  height: 26px; padding: 0 8px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  color: var(--txt-3);
  font: inherit; font-size: 10.5px; font-weight: 500;
  cursor: pointer; flex-shrink: 0;
  transition: color .12s, border-color .12s, background .12s;
}
.bld-combo-add:hover { color: var(--red); border-color: var(--red); }
.bld-combo-rm {
  width: 26px; padding: 0;
  font-size: 14px; line-height: 1;
  border-style: solid; border-color: var(--line-2);
}
.bld-combo-rm:hover { color: var(--err); border-color: var(--err); background: var(--red-soft); }

.bld-port-row.is-combo {
  border-color: rgba(46,204,113,0.35);
  background: linear-gradient(to right, var(--bg), rgba(46,204,113,0.04));
}

/* Preview badge — combo mostra dois glyphs com "+" entre eles */
.bld-prev-badge-conn-combo {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 4px;
  background: rgba(46,204,113,0.12);
  border: 1px solid rgba(46,204,113,0.3);
  border-radius: 4px;
}
.bld-prev-badge-plus { font-size: 10px; color: var(--txt-3); font-weight: 700; }

/* Gênero (♂/♀) no canto do badge de sinal */
.bld-prev-badge-box { position: relative; }
.bld-prev-badge-gen {
  position: absolute; top: -5px; right: -5px;
  width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; line-height: 1;
  border: 1.5px solid var(--bg-deep);
}
.bld-prev-badge-gen-male   { background: #3498DB; color: #fff; }
.bld-prev-badge-gen-female { background: #E91E63; color: #fff; }
.bld-prev-badge.is-combo .bld-prev-badge-lbl::after {
  content: ' · combo';
  color: #2ECC71; font-size: 8.5px;
}

/* Acessórios do equipamento (lista nome + qtd) */
.acc-hint { font-weight: 400; color: var(--txt-4); font-size: 10.5px; text-transform: none; letter-spacing: 0; }
.acc-list { display: flex; flex-direction: column; gap: 6px; }
.acc-row { display: grid; grid-template-columns: 1fr 68px 30px; gap: 6px; align-items: center; }
.acc-row .acc-nome, .acc-row .acc-qtd { height: 34px; padding: 0 9px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-md); color: var(--txt); font-size: 13px; }
.acc-row .acc-qtd { text-align: center; }
.acc-del { height: 30px; width: 30px; display: flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--line-2); border-radius: var(--r-md); color: var(--txt-3); cursor: pointer; }
.acc-del:hover { color: var(--red); border-color: var(--red); }
