/* Theme Builder: grade de amostras de cor, popover de edicao, preview do
   background e toast. Complementa css/estilo.css (usa as mesmas variaveis);
   tudo com prefixo tb- para nao vazar para o resto do app. */

/* Os campos de texto da barra de configuracao precisam de mais espaco que o
   padrao de 110px do .campo-inline. */
#painelTema .campo-inline input[type="text"] { width: 220px; }

/* ----- Grade da paleta do tema ----- */
.tb-grade-paleta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 12px;
}
.tb-amostra {
  position: relative;
  height: 92px;
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .06);
  transition: transform .08s ease, box-shadow .08s ease;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: flex-end;
}
.tb-amostra:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}
.tb-oculta { display: none; }

.tb-rotulo {
  display: flex;
  height: 20%;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 7px 8px;
  backdrop-filter: blur(2px);
  font-family: "Consolas", "Courier New", monospace;
  pointer-events: none;
}
.tb-selo {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: #111;
  border: 1px solid rgba(0, 0, 0, .08);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.tb-btn-limpar {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(17, 17, 17, .45);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
  backdrop-filter: blur(2px);
}
.tb-btn-limpar:hover { background: rgba(17, 17, 17, .60); }

/* ----- Grade das cores do background ----- */
.tb-grade-bg {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  max-width: 560px;
}
.tb-amostra-bg {
  position: relative;
  height: 110px;
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .06);
  transition: transform .08s ease, box-shadow .08s ease;
  display: grid;
  grid-template-rows: 1fr auto;
}
.tb-amostra-bg:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}
.tb-bg-nome {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  color: #111;
  border: 1px solid rgba(0, 0, 0, .08);
  backdrop-filter: blur(2px);
  pointer-events: none;
  font-weight: 600;
}
.tb-bg-desc {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10.5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  color: #3b485c;
  border: 1px solid rgba(0, 0, 0, .06);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

/* ----- Preview (background + env) lado a lado ----- */
.tb-preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .tb-preview-grid { grid-template-columns: 1fr; }
}
.tb-coluna { min-width: 0; }
.tb-titulo-coluna {
  font-size: 12px;
  font-weight: 600;
  color: #3b485c;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tb-btn-mini { padding: 5px 10px; font-size: 12px; }
.tb-svg-host { width: 100%; max-width: 1100px; margin: 0 auto; }
.tb-svg-host svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
}
/* Mesmo visual escuro do .preview usado nos outros paineis. */
.tb-env {
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #1e293b;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  overflow: auto;
  max-height: 560px;
  white-space: pre;
  tab-size: 2;
}

/* ----- Popover de edicao de cor ----- */
.tb-pop {
  position: fixed;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .20);
  padding: 10px;
}
.tb-pop.mostrar { display: flex; }
/* Sobrescreve o estilo global de input (width 100%, padding, anel de foco). */
.tb-pop input[type="color"] {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--borda-input);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: none;
}
.tb-pop input[type="color"]:focus { border-color: var(--borda-input); box-shadow: none; }
.tb-pop input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.tb-pop input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.tb-pop-hex {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--borda-input);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  background: #fafafa;
  font-family: "Consolas", "Courier New", monospace;
}
.tb-pop-hex span { color: #9aa6b6; font-size: 13px; }
.tb-pop-hex input {
  border: none;
  outline: none;
  background: transparent;
  width: 78px;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--texto);
}
.tb-pop-hex input:hover,
.tb-pop-hex input:focus { border: none; box-shadow: none; }
.tb-pop-copiar {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.tb-pop-copiar svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ----- Toast ----- */
.tb-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 70;
}
.tb-toast.mostrar {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
