/* Estilos que o Tailwind (via CDN) não cobre: fundo, cartão, grid
   responsivo do workspace, indicador de etapas, checkerboard do preview
   e animações em CSS puro (sem biblioteca JS). */

:root {
  --brand-50: #eef4ff;
  --brand-100: #d9e6ff;
  --brand-400: #3b6ff2;
  --brand-500: #1d4ed8;
  --brand-600: #1a43c0;
  --brand-700: #16379e;
  --shadow-color: 222deg 60% 40%;
}

html, body {
  height: 100%;
}

body {
  background-color: #f6f8ff;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(26, 67, 192, 0.07) 1px, transparent 0);
  background-size: 28px 28px;
  overflow-x: hidden;
}

/* Manchas de cor suaves no fundo, puramente decorativas. */
.bg-blob {
  position: fixed;
  z-index: 0;
  border-radius: 9999px;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
}
.bg-blob--1 {
  top: -160px;
  left: -140px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #93b4ff 0%, transparent 70%);
}
.bg-blob--2 {
  bottom: -180px;
  right: -140px;
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, #ffd9c7 0%, transparent 70%);
}
.bg-blob--3 {
  top: 30%;
  right: -120px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, #c7f0e0 0%, transparent 70%);
  opacity: 0.3;
}

.main-shell {
  z-index: 1;
}

/* Marca no cabeçalho: logo do produto + contexto dinâmico do cliente. */
.editor-brand__link {
  outline-offset: 5px;
}
.editor-brand__link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-400) 30%, transparent);
}
.editor-brand__logo {
  width: clamp(128px, 15vw, 154px);
  height: auto;
}
.editor-brand__context {
  position: relative;
  display: flex;
  min-height: 34px;
  flex-direction: column;
  justify-content: center;
  margin-left: 14px;
  padding-left: 14px;
}
.editor-brand__context::before {
  content: "";
  position: absolute;
  width: 1px;
  inset: 2px auto 2px 0;
  background: #dbe1ea;
}
.editor-brand__label {
  margin: 0;
  color: var(--brand-600);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}
.editor-brand__tagline {
  max-width: 230px;
  margin: 0.3rem 0 0;
  overflow: hidden;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trust-chip {
  border: 1px solid rgba(26, 67, 192, 0.12);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
}

/* Contador ao vivo de artes geradas (topo do editor).
   Usa var(--brand-*) e não classes Tailwind estáticas de propósito: assim
   ele acompanha a cor de marca que o admin escolheu pra cada cliente,
   igual ao painel superior e aos botões. */
.live-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: center;
  border: 1px solid var(--brand-100, #d9e6ff);
  border-radius: 9999px;
  background: var(--brand-50, #eef4ff);
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--brand-700, #16379e);
}

.live-counter strong {
  font-weight: 800;
}

/* O ponto pulsante é o que comunica "isto está acontecendo agora" — sem
   ele o número parece um selo estático qualquer. */
.live-counter__dot {
  position: relative;
  display: block;
  height: 0.5rem;
  width: 0.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: var(--brand-500, #1d4ed8);
}

.live-counter__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: inherit;
  animation: live-pulse 2s ease-out infinite;
}

@keyframes live-pulse {
  0% { transform: scale(1); opacity: 0.55; }
  70% { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* Piscada curta quando o número sobe, pra a mudança ser percebida sem
   depender de a pessoa estar olhando exatamente pro contador. */
.live-counter--bumped {
  animation: live-bump 0.5s ease;
}

@keyframes live-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.card-panel {
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  box-shadow: 0 1px 2px hsl(var(--shadow-color) / 0.06), 0 24px 48px -20px hsl(var(--shadow-color) / 0.22);
}

/* O editor muda de proporção sem trocar de componente: 1:1 ou 9:16. */
.preview-surface {
  aspect-ratio: 1 / 1;
  transition: aspect-ratio 0.25s ease, border-radius 0.25s ease;
}
.preview-surface.is-story {
  aspect-ratio: 9 / 16;
  border-radius: 1.5rem;
}
.hero-preview {
  transition: max-width 0.25s ease;
}
.hero-preview.is-story {
  max-width: 152px;
}

/* Seletor de destino: decisão principal antes do upload. */
.format-option {
  position: relative;
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 1rem;
  background: #fff;
  text-align: left;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}
.format-option:hover {
  border-color: var(--brand-400);
  background: var(--brand-50);
}
.format-option:active {
  transform: scale(0.985);
}
.format-option:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-400) 30%, transparent);
  outline-offset: 2px;
}
.format-option.is-active {
  border-color: var(--brand-500);
  background: var(--brand-50);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-400) 18%, transparent);
}
.format-icon {
  display: inline-block;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 0.32rem;
  color: var(--brand-600);
  background: rgba(255, 255, 255, 0.78);
}
.format-icon--square {
  width: 30px;
  height: 30px;
}
.format-icon--story {
  width: 19px;
  height: 34px;
  margin-inline: 5px 6px;
}
.format-check {
  position: absolute;
  top: 7px;
  right: 8px;
  display: none;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--brand-600);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.format-option.is-active .format-check {
  display: flex;
}

/* Indicador de etapas */
.step-pill {
  padding: 0.3rem 0.8rem;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  font-weight: 600;
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.step-pill--active {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(26, 67, 192, 0.6);
}
.step-pill--done {
  background: var(--brand-50);
  color: var(--brand-600);
}
.step-pill--done::before {
  content: "✓ ";
}
.step-sep {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: #e2e8f0;
  transition: background-color 0.3s ease;
}
#step1.step-pill--done + .step-sep,
#step1.step-pill--active + .step-sep {
  background: var(--brand-400);
}
#step2.step-pill--done + .step-sep,
#step2.step-pill--active + .step-sep {
  background: var(--brand-400);
}

.checkerboard {
  background-image: linear-gradient(45deg, #eee 25%, transparent 25%),
    linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%),
    linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.dropzone {
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}
.dropzone.drag-active {
  border-color: var(--brand-500);
  background-color: var(--brand-50);
  transform: scale(1.01);
}
.dropzone.has-file {
  border-style: solid;
  border-color: #34d399;
  background-color: #ecfdf5;
}
.dropzone.has-file .dropzone-icon {
  color: #059669;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fade-in-up 0.35s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fade-in 0.2s ease-out;
}

.btn-press {
  transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.btn-press:active:not(:disabled) {
  transform: scale(0.98);
}

.generate-btn {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
}
.generate-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px -10px rgba(26, 67, 192, 0.55);
}

.frame-option {
  min-width: 0;
  border-radius: 0.9rem;
  text-align: left;
  transition: transform 0.15s ease, color 0.15s ease;
}
.frame-option:hover {
  transform: translateY(-2px);
}
.frame-option:active {
  transform: scale(0.98);
}
.frame-option:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-400) 30%, transparent);
  outline-offset: 3px;
}
.frame-option__preview {
  position: relative;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  border-radius: 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.frame-option:hover .frame-option__preview {
  box-shadow: 0 10px 20px -10px rgba(15, 23, 42, 0.25);
}
.frame-option.is-active .frame-option__preview {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 2px var(--brand-100);
}
.frame-option__name {
  display: block;
  margin-top: 0.45rem;
  overflow: hidden;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.frame-option.is-active .frame-option__name {
  color: var(--brand-700);
}
.frame-selected-badge {
  background: var(--brand-500);
}

.terms-box {
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.terms-box:has(input:checked) {
  border-color: var(--brand-500);
  background-color: var(--brand-50);
}

.spin {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pop {
  0% { transform: scale(0.9); opacity: 0; }
  60% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); }
}
.pop-in {
  animation: pop 0.25s ease-out;
}

/* Zoom slider — visual mais "produto" do que o range nativo cru */
input[type="range"]#zoomSlider {
  height: 6px;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--brand-400), #dbe4ff);
  appearance: none;
  -webkit-appearance: none;
}
input[type="range"]#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: #fff;
  border: 3px solid var(--brand-600);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}
input[type="range"]#zoomSlider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: #fff;
  border: 3px solid var(--brand-600);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}

/* Os blobs decorativos são `position: fixed` com offsets negativos de até
   -180px e até 460px de largura. Em tela estreita eles ultrapassam a
   viewport e alguns navegadores mobile passam a permitir arrasto lateral.
   A correção anterior era `overflow-x: hidden` no <body>, mas isso
   transforma o body em contêiner de rolagem — comportamento que varia
   entre navegadores Android e pode atrapalhar a rolagem vertical da
   página, justamente onde aparece a etapa seguinte depois do upload.
   Some com o enfeite no celular: resolve o overflow na origem, não tem
   efeito colateral em rolagem, e ainda economiza uma camada de blur de
   80px por frame num aparelho fraco. */
@media (max-width: 767px) {
  .bg-blob {
    display: none;
  }
}

@media (max-width: 520px) {
  #formatPicker {
    grid-template-columns: 1fr;
  }
  .format-option {
    min-height: 64px;
    gap: 0.55rem;
    padding: 0.65rem;
  }
}

/* No celular, o mockup de Story repete o que o preview do topo já mostra
   grande — a mesma arte vertical, duas vezes, empurrando o botão de gerar
   pra fora da tela. No desktop o mockup fica ao lado e ajuda a visualizar
   como a arte aparece no feed, então continua visível lá.
   A classe .is-story é aplicada por updateFormatUI() em app.js; o mockup
   do WhatsApp (formato perfil) continua aparecendo no celular porque
   mostra algo que o preview não mostra: a foto recortada em círculo. */
@media (max-width: 767px) {
  #socialPreview.is-story {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
