/* ── motor-shell — janela do iframe  v2 ─────────────────────────────────── */
/*
  Copiar para o projeto mãe junto ao brand.css (tokens --radius, --bg-*, etc.)
  Isolar dentro de .motor-shell na página do motor; não altera o resto do site.
*/

.motor-shell {
  /* tokens internos — sobrescreva na página se necessário */
  --sh-h:    36px;   /* altura do chrome */
  --sh-btn:  26px;   /* tamanho dos botões */
  --sh-icon: 14px;   /* tamanho dos ícones SVG — TODOS iguais */
  --sh-dot:   9px;   /* semáforo */
  --sh-r:    var(--radius, 6px);

  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--sh-r) + 2px);
  background: var(--bg-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

/* ─── barra de chrome ───────────────────────────────────────────────────── */

.motor-shell__chrome {
  display: flex;
  align-items: center;
  height: var(--sh-h);
  padding: 0 6px;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--bg-tertiary, hsl(85 15% 10%)) 80%, var(--bg-secondary) 20%);
  user-select: none;
}

/* ─── semáforo decorativo ───────────────────────────────────────────────── */

.motor-shell__traffic {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.motor-shell__traffic span {
  display: block;
  width:  var(--sh-dot);
  height: var(--sh-dot);
  border-radius: 50%;
}

.motor-shell__traffic span:nth-child(1) { background: hsl(  0 60% 52% / 0.85); }
.motor-shell__traffic span:nth-child(2) { background: hsl( 38 82% 50% / 0.85); }
.motor-shell__traffic span:nth-child(3) { background: hsl(142 48% 43% / 0.85); }

/* ─── aba com título ────────────────────────────────────────────────────── */

.motor-shell__tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 160px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--bg-primary);
}

.motor-shell__tab-dot {
  display: block;
  width:  6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: hsl(var(--primary));
  opacity: 0.85;
}

.motor-shell__tab-title {
  font-family: var(--font-heading, inherit);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── toolbar de ações ──────────────────────────────────────────────────── */

.motor-shell__toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}

.motor-shell__sep {
  display: block;
  width: 1px;
  height: 14px;
  background: var(--border-color);
  margin: 0 3px;
  opacity: 0.6;
  flex-shrink: 0;
}

/* ─── botão ─────────────────────────────────────────────────────────────── */

.motor-shell__btn {
  /* tamanho fixo — todos idênticos */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width:  var(--sh-btn);
  height: var(--sh-btn);
  padding: 0;

  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease, transform 0.06s ease;
}

/*
  Força tamanho e estilo de todos os ícones SVG.
  display:block remove espaço de linha-base;
  width/height sobrescrevem qualquer atributo no elemento SVG.
*/
.motor-shell__btn svg {
  display: block;
  flex-shrink: 0;
  width:  var(--sh-icon);
  height: var(--sh-icon);
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  overflow: visible;
  pointer-events: none;
}

.motor-shell__btn:hover:not(:disabled) {
  background: var(--elevate-1, rgba(255, 255, 255, 0.07));
  color: var(--text-primary);
  border-color: var(--border-subtle, var(--border-color));
}

.motor-shell__btn:active:not(:disabled) {
  background: var(--elevate-2, rgba(255, 255, 255, 0.12));
  transform: scale(0.91);
}

.motor-shell__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.motor-shell__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--ring, 85 35% 45%) / 0.4);
}

.motor-shell__btn--danger:hover:not(:disabled) {
  color: var(--danger-text, hsl(0 70% 62%));
  background: hsl(0 60% 45% / 0.12);
  border-color: hsl(0 55% 45% / 0.3);
}

/* ─── refresh: swap ícone ↔ mini NexusGen loader ───────────────────────── */

/* estado normal: mostra ícone, esconde loader */
.motor-shell__btn[data-motor-action="refresh"] .ms-btn-loader { display: none; }
.motor-shell__btn[data-motor-action="refresh"] .ms-btn-icon   { display: block; }

/* is-loading: esconde ícone, exibe mini loader NexusGen */
.motor-shell__btn[data-motor-action="refresh"].is-loading .ms-btn-icon   { display: none; }
.motor-shell__btn[data-motor-action="refresh"].is-loading .ms-btn-loader {
  display: block;
  /* reseta tamanho — geo-pl tem 3rem por padrão, aqui precisa de --sh-icon */
  width:  var(--sh-icon) !important;
  height: var(--sh-icon) !important;
  /* reseta herança do .motor-shell__btn svg para não quebrar os rings */
  stroke:        unset !important;
  stroke-width:  unset !important;
  stroke-linecap:  unset !important;
  stroke-linejoin: unset !important;
  animation: none !important;
}

/* rings do mini loader: herdam stroke de style.css, não do btn */
.motor-shell__btn[data-motor-action="refresh"] .ms-btn-loader circle {
  stroke-width: 20;    /* valor do viewBox 240×240 — escala certo */
  fill: none;
  stroke-linecap: round;
}

/* ─── viewport / área do iframe ─────────────────────────────────────────── */

.motor-shell__viewport {
  position: relative;
  min-height: 480px;
  background: var(--bg-primary);
}

.motor-shell__viewport iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.motor-shell__viewport iframe.is-ready {
  opacity: 1;
}

/* ─── responsivo ────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
  .motor-shell__traffic { display: none; }
  .motor-shell__tab     { max-width: 90px; }
}
