/* ═══════════════════════════════════════════
 * CREATIVE.CSS — Motor de Criação
 * ═══════════════════════════════════════════ */

/* ─── Shell override ─── */
.creative-main {
  padding: 0 !important;
  /* Ocupa exatamente a área do main-content sem overflow */
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── Layout 2 colunas ─── */
.creative-layout {
  display: grid;
  grid-template-columns: clamp(300px, 35%, 440px) 1fr;
  /* Ocupa toda a altura disponível dentro do main */
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ═══════════════════════════════════════════
 * PAINEL DE FERRAMENTAS
 * ═══════════════════════════════════════════ */

.creative-tools {
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* min-height:0 é obrigatório para filhos de grid/flex rolarem */
  min-height: 0;
}

/* AJUSTE FASE 1: Ocultar handle no desktop por padrão */
#sheet-handle, .bottom-sheet-handle {
  display: none;
}

.creative-tools-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md) var(--space-lg);
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.creative-tools-scroll::-webkit-scrollbar { width: 3px; }
.creative-tools-scroll::-webkit-scrollbar-track { background: transparent; }
.creative-tools-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
}

.creative-tools-scroll .section-divider {
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.creative-tools-scroll .section-divider:last-of-type {
  border-bottom: none;
}

/* ─── Formato de saída — 3 chips lado a lado ─── */
.format-selector-row {
  display: flex;
  gap: var(--space-xs);
}

.format-chip-sm {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color var(--transition-fast),
    color var(--transition-fast),
    background var(--transition-fast);
  white-space: nowrap;
}

.format-chip-sm svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.format-chip-sm.is-active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(255,176,32,0.08);
}

/* ─── Identidade visual ─── */
.creative-identity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.font-preview {
  margin-top: var(--space-xs);
  font-size: 12px;
  color: var(--text-muted);
  padding: 5px 8px;
  background: var(--bg-base);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* ─── Cores ─── */
.creative-colors-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.color-input-wrapper input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
}

.color-hex {
  font-size: 12px;
  padding: 6px 8px;
}

/* ─── Asset actions ─── */
.asset-actions {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.asset-actions .btn {
  flex: 1;
  font-size: 11px;
  padding: 6px 8px;
  gap: 4px;
}

.asset-actions .btn svg {
  width: 13px;
  height: 13px;
}

/* ─── Botão gerar ─── */
.btn-generate {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  letter-spacing: 0.04em;
  margin-top: var(--space-xs);
  margin-bottom: var(--space-lg);
}

/* ═══════════════════════════════════════════
 * CANVAS
 * ═══════════════════════════════════════════ */

.canvas-container {
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  overflow: hidden;
  min-height: 0;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

#canvas-area {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
}

.format-1-1 {
  aspect-ratio: 1/1;
  max-height: 58vh;
  max-width: min(500px, 90%);
  width: 100%;
}

.format-4-5 {
  aspect-ratio: 4/5;
  max-height: 62vh;
  max-width: min(360px, 80%);
  width: 100%;
}

.format-9-16 {
  aspect-ratio: 9/16;
  max-height: 68vh;
  max-width: min(280px, 55%);
  width: 100%;
}

.canvas-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: var(--space-xl);
}

/* ─── Toolbar do canvas ─── */
.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: rgba(12,12,12,0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 7px var(--space-md);
  flex-shrink: 0;
}

.format-chips {
  display: flex;
  gap: var(--space-xs);
}

/* Botão Baixar */
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: not-allowed;
  opacity: 0.35;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-download svg {
  width: 13px;
  height: 13px;
}

.btn-download:not([disabled]) {
  cursor: pointer;
  opacity: 1;
  color: var(--accent-secondary);
  border-color: var(--accent-secondary);
  background: rgba(255,75,75,0.08);
}

.btn-download:not([disabled]):hover {
  background: rgba(255,75,75,0.18);
}

/* ═══════════════════════════════════════════
 * MOBILE  ≤ 1024px
 * ═══════════════════════════════════════════ */

@media (max-width: 1024px) {

  .creative-main {
    /* No mobile o main-content já tem height: calc(100dvh - 64px) */
    height: 100%;
    overflow: hidden;
  }

  .creative-layout {
    /* Empilha verticalmente: canvas em cima, gaveta embaixo */
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  /* Canvas ocupa área fixa no topo */
  .canvas-container {
    flex: 0 0 auto;
    height: calc(100% - 52px); /* espaço para o handle da gaveta */
    padding: var(--space-md) var(--space-md) var(--space-sm);
    justify-content: center;
  }

  #canvas-area {
    border-radius: var(--radius-lg) !important;
  }

  /* Toolbar fica estática abaixo do canvas */
  .canvas-toolbar {
    position: static;
    flex-shrink: 0;
  }

  /* ── Gaveta ── */
  .creative-tools {
    position: fixed;
    bottom: 64px; /* acima do nav-bottom */
    left: 0;
    right: 0;
    max-height: 75dvh;
    /* AJUSTE FASE 1: transform usa translateY mas a ativação será por .is-active */
    transform: translateY(calc(100% - 48px));
    transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-panel);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid rgba(255,176,32,0.2); /* borda amarela discreta */
    border-right: none;
    z-index: 95; /* acima do nav (100 não, para não cobrir) */
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -4px 32px rgba(0,0,0,0.6);
  }

  /* AJUSTE FASE 1: Alterado de .is-expanded para .is-active */
  .creative-tools.is-active {
    transform: translateY(0);
  }

  /* Handle — amarelo e discreto */
  #sheet-handle, .bottom-sheet-handle {
    display: block; /* Visível no mobile */
    width: 36px;
    height: 3px;
    background: rgba(255,176,32,0.4);
    border-radius: var(--radius-pill);
    margin: 12px auto 8px;
    cursor: pointer;
    flex-shrink: 0;
    /* Área de toque generosa */
    position: relative;
  }

  .bottom-sheet-handle::before {
    content: '';
    position: absolute;
    inset: -14px -40px;
  }

  .creative-tools-scroll {
    flex: 1;
    overflow-y: auto;
    max-height: calc(75dvh - 48px);
    padding: var(--space-sm) var(--space-lg) var(--space-2xl);
    scrollbar-width: none;
    min-height: 0;
  }

  .creative-tools-scroll::-webkit-scrollbar {
    display: none;
  }

  /* Identidade e cores: coluna única */
  .creative-identity-grid,
  .creative-colors-row {
    grid-template-columns: 1fr;
  }

  /* Chips de formato: mantém linha */
  .format-selector-row {
    flex-direction: row;
    gap: var(--space-xs);
  }
}