/* ── Admin: tela de configuração de modelos de etiqueta (full-screen) ──────── */

.etq-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.etq-admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1.5px solid var(--line-soft);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
  flex-shrink: 0;
}
.etq-admin-btn:hover {
  border-color: var(--brand-500);
  color: var(--brand-700);
  background: rgba(69, 98, 143, .10);
}

/* ── Sub-view de configuração (ocupa a área de conteúdo; sidebar permanece) ──── */
.etq-admin-screen {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  overflow: hidden;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  /* preenche a altura visível da área de conteúdo, com scroll interno próprio */
  height: calc(100dvh - 28px);
}
.etq-admin-screen.hidden { display: none; }

/* Topbar fixa no topo da sub-view */
.etq-as-topbar {
  flex-shrink: 0;
  padding: 16px 32px 14px;
  background: var(--bg-surface, #fff);
  border-bottom: 1px solid var(--line-soft);
}
.etq-as-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0;
  margin-bottom: 10px;
  transition: color .12s;
}
.etq-as-back:hover { color: var(--brand-700); }
.etq-as-titles { display: flex; flex-direction: column; gap: 2px; }
.etq-ap-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--brand-700, #132a72);
}
.etq-ap-sub { font-size: 13px; color: var(--text-secondary); margin: 0; }

/* Vistas (lista / editor) */
.etq-as-view { flex: 1; overflow-y: auto; min-height: 0; }
.etq-as-view.hidden { display: none; }

/* ── Lista de modelos (grid de cards ricos) ────────────────────────────────── */
.etq-as-list-wrap {
  max-width: 940px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}
.etq-ap-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 16px;
}
.etq-ap-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1.5px solid var(--line-soft);
  border-radius: 14px;
  cursor: pointer;
  background: var(--bg-surface);
  width: 100%;
  text-align: left;
  color: var(--text-primary); /* corrige nome herdando branco do <button> */
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.etq-ap-card:hover {
  border-color: var(--brand-500);
  box-shadow: 0 6px 22px rgba(19, 42, 114, .12);
  transform: translateY(-2px);
}
/* Miniatura-silhueta da etiqueta */
.etq-ap-thumb {
  width: 94px;
  height: 66px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: #fff;
  overflow: hidden;
}
.etq-ap-thumb svg { width: 100%; height: 100%; display: block; }
/* Corpo do card */
.etq-ap-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.etq-ap-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.etq-ap-card-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.etq-ap-chip {
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  padding: 2px 8px;
  white-space: nowrap;
}
.etq-ap-chip-tpl {
  font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
  background: var(--brand-700, #132a72);
  color: #fff;
  letter-spacing: .5px;
}
.etq-ap-chip-setor[data-setor="corte-solda"] { background: #e8eefc; color: #1e3a8a; }
.etq-ap-chip-setor[data-setor="montagem"]    { background: #fdeede; color: #9a3412; }
.etq-ap-chip-setor[data-setor=""]            { background: var(--line-soft); color: var(--text-secondary); }
.etq-ap-card-meta { font-size: 12px; color: var(--text-secondary); }
.etq-ap-card-arr { color: var(--text-secondary); flex-shrink: 0; align-self: center; }

.etq-ap-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  border: 1.5px dashed var(--line-soft);
  border-radius: 14px;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.etq-ap-new-btn:hover { border-color: var(--brand-500); color: var(--brand-700); background: rgba(19, 42, 114, .03); }

/* ── Editor: 2 colunas (form scroll | preview grande fixo) ─────────────────── */
.etq-ap-back {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  font-family: inherit;
  font-size: 13px; color: var(--text-secondary);
  padding: 18px 32px 0;
  transition: color .12s;
}
.etq-ap-back:hover { color: var(--brand-700); }

.etq-as-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  gap: 28px;
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 32px 40px;
}

/* Coluna esquerda: formulário */
.etq-as-form-col { min-width: 0; }
.etq-ap-form { display: flex; flex-direction: column; }
/* Grupo "Identificação" — separa "que modelo é" dos "ajustes finos" */
.etq-ap-group {
  background: var(--bg-surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px 16px 2px;
  margin-bottom: 18px;
}
.etq-ap-group-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.etq-ap-group-title-loose { margin: 2px 0 12px; }
.etq-ap-field-row { display: grid; grid-template-columns: 1.3fr 1.3fr 84px; gap: 12px; }
.etq-ap-field-narrow input { text-align: center; }
.etq-ap-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.etq-ap-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.etq-ap-field input,
.etq-ap-field select {
  height: 38px;
  border: 1.5px solid var(--line-soft);
  border-radius: 8px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color .12s;
}
.etq-ap-field input:focus,
.etq-ap-field select:focus { outline: none; border-color: var(--brand-500); }

.etq-ap-section {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--bg-surface);
}
.etq-ap-section > summary {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-700, #132a72);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.etq-ap-section > summary::-webkit-details-marker { display: none; }
.etq-ap-sec-count { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.etq-adj-group { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 14px; }

/* Linha de ajuste padronizada: label (linha toda) + slider | número | unidade */
.etq-adj-row {
  display: grid;
  grid-template-columns: 1fr 64px auto;
  align-items: center;
  gap: 10px;
}
.etq-adj-row label { color: var(--text-secondary); font-size: 12px; grid-column: 1 / -1; margin-bottom: 1px; }
.etq-adj-row input[type="range"] {
  grid-column: 1;
  width: 100%;
  height: 6px;
  accent-color: var(--brand-500);
  cursor: pointer;
}
.etq-adj-num {
  grid-column: 2;
  width: 64px;
  height: 32px;
  border: 1.5px solid var(--line-soft);
  border-radius: 6px;
  padding: 0 6px;
  font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
  font-size: 13px;
  text-align: center;
  color: var(--text-primary);
  background: var(--bg-surface);
}
.etq-adj-num:focus { outline: none; border-color: var(--brand-500); }
.etq-adj-unit {
  grid-column: 3;
  font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Coluna direita: preview grande e fixo (sticky) */
.etq-as-prev-col {
  position: sticky;
  top: 14px;
  align-self: start;
  background: var(--bg-surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .05);
}
.etq-ap-prev-label {
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 12px;
}
.etq-ap-prev-box {
  aspect-ratio: 371 / 259;
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.etq-ap-prev-box svg { width: 100%; height: 100%; display: block; }
.etq-ap-prev-hint { font-size: 13px; color: var(--text-secondary); text-align: center; padding: 0 16px; margin: 0; line-height: 1.4; }
/* Estado vazio: silhueta do template + instrução */
.etq-ap-prev-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px;
}
.etq-ap-prev-silhueta { width: 68%; max-width: 230px; opacity: .9; }
.etq-ap-prev-silhueta svg { width: 100%; height: auto; display: block; }

/* Campo OP — agora ACIMA do preview e em destaque (é o gatilho) */
.etq-ap-prev-op {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.etq-ap-prev-op label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.etq-ap-prev-op input {
  width: 100%;
  height: 46px;
  border: 1.5px solid var(--line-soft);
  border-radius: 10px;
  padding: 0 14px;
  font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: border-color .12s, box-shadow .12s;
}
.etq-ap-prev-op input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(59, 91, 219, .12); }

/* Rodapé de ações (sticky no fundo da coluna do formulário, sempre visível) */
.etq-ap-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--line-soft);
  background: var(--md-sys-color-surface-container-low, #f6f7fa);
  z-index: 2;
}
.etq-ap-save-btn {
  background: var(--brand-700, #132a72);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 22px;
  height: 40px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .12s;
}
.etq-ap-save-btn:hover { opacity: .85; }
.etq-ap-cancel-btn {
  background: none;
  border: 1.5px solid var(--line-soft);
  border-radius: 8px;
  padding: 0 18px;
  height: 40px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color .12s;
}
.etq-ap-cancel-btn:hover { border-color: var(--brand-500); }
.etq-ap-delete-btn {
  background: none;
  border: 1.5px solid #fca5a5;
  border-radius: 8px;
  padding: 0 16px;
  height: 40px;
  font-family: inherit;
  font-size: 13px;
  color: #b91c1c;
  cursor: pointer;
  transition: background .12s;
}
.etq-ap-delete-btn:hover { background: rgba(185, 28, 28, .08); }

.etq-validation {
  margin: 16px 0 0;
  padding: 10px 14px;
  background: rgba(185, 28, 28, .08);
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 13px;
}

/* ── Responsivo: empilha preview abaixo do form em telas estreitas ─────────── */
@media (max-width: 1000px) {
  .etq-as-editor-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .etq-as-prev-col {
    position: static;
    order: -1; /* preview vai pro topo no mobile */
  }
  .etq-ap-prev-box { max-width: 420px; margin: 0 auto; }
}
