/* ==========================================================================
   Blink Catalog — Design System
   Paleta extraída do Blink Controll (sidebar navy escura, azul primário,
   cards brancos arredondados, tiles de status coloridos).
   CSS próprio, sem build step (sem Tailwind/Node) — arquivo estático.
   ========================================================================== */

:root {
  /* Paleta Blink */
  --bc-primary: #2563eb;
  --bc-primary-dark: #1d4ed8;
  --bc-primary-light: #eff6ff;
  --bc-success: #16a34a;
  --bc-success-light: #f0fdf4;
  --bc-danger: #dc2626;
  --bc-danger-light: #fef2f2;
  --bc-purple: #9333ea;
  --bc-purple-light: #faf5ff;
  --bc-warning: #f59e0b;
  --bc-warning-light: #fffbeb;

  /* Sidebar */
  --bc-sidebar-bg: #0f172a;
  --bc-sidebar-bg-active: #1e293b;
  --bc-sidebar-text: #cbd5e1;
  --bc-sidebar-text-muted: #64748b;

  /* Superfícies */
  --bc-bg: #f1f5f9;
  --bc-card: #ffffff;
  --bc-border: #e2e8f0;

  /* Texto */
  --bc-text: #0f172a;
  --bc-text-muted: #64748b;
  --bc-text-soft: #94a3b8;

  /* Raio e sombra */
  --bc-radius-sm: 0.5rem;
  --bc-radius: 0.875rem;
  --bc-radius-lg: 1.25rem;
  --bc-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --bc-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Tema da loja: sobrescrito inline por tenant (cor principal / botão) */
.store-theme {
  --store-primary: var(--bc-primary);
  --store-button: var(--bc-primary);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bc-bg);
  color: var(--bc-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Layout do painel (app) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bc-sidebar-bg);
  color: var(--bc-sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.5rem 1.25rem;
  color: #fff;
}
.sidebar-brand .badge-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bc-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: #fff;
}
.sidebar-brand .brand-name { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.sidebar-brand .brand-sub { font-size: 0.7rem; color: var(--bc-sidebar-text-muted); }

.sidebar-store {
  background: var(--bc-sidebar-bg-active);
  border-radius: var(--bc-radius);
  padding: 0.65rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}
.sidebar-store strong { display: block; color: #fff; font-size: 0.85rem; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--bc-radius-sm);
  color: var(--bc-sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
}
.sidebar-nav a:hover { background: var(--bc-sidebar-bg-active); color: #fff; }
.sidebar-nav a.active { background: var(--bc-sidebar-bg-active); color: var(--bc-primary); }
.sidebar-nav a.active .icon { color: var(--bc-primary); }
.sidebar-nav .icon { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 0.75rem; margin-top: 0.75rem; }
.sidebar-footer a { color: var(--bc-sidebar-text-muted); font-size: 0.85rem; padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 0.6rem; }
.sidebar-footer a:hover { color: #fff; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--bc-card);
  border-bottom: 1px solid var(--bc-border);
  padding: 1rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 1.25rem; }
.topbar .subtitle { color: var(--bc-text-muted); font-size: 0.85rem; margin-top: 0.15rem; }
.topbar-right { display: flex; align-items: center; gap: 0.9rem; }
.user-chip { display: flex; align-items: center; gap: 0.6rem; background: var(--bc-bg); border-radius: var(--bc-radius); padding: 0.4rem 0.75rem; }
.user-chip .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bc-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; }
.user-chip .name { font-size: 0.82rem; font-weight: 600; }
.user-chip .role { font-size: 0.7rem; color: var(--bc-text-muted); }

.content { padding: 1.5rem; flex: 1; }

/* ---------- Cards / tiles ---------- */
.card {
  background: var(--bc-card);
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius-lg);
  box-shadow: var(--bc-shadow);
  padding: 1.25rem;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-header h2 { font-size: 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { display: flex; align-items: center; gap: 0.9rem; background: var(--bc-card); border: 1px solid var(--bc-border); border-radius: var(--bc-radius-lg); box-shadow: var(--bc-shadow); padding: 1.1rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.1rem; flex-shrink: 0; }
.stat-icon.blue { background: var(--bc-primary); }
.stat-icon.green { background: var(--bc-success); }
.stat-icon.purple { background: var(--bc-purple); }
.stat-icon.orange { background: var(--bc-warning); }
.stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.78rem; color: var(--bc-text-muted); margin-top: 0.15rem; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--bc-radius-sm);
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--bc-primary); color: #fff; }
.btn-primary:hover { background: var(--bc-primary-dark); }
.btn-outline { background: #fff; border-color: var(--bc-border); color: var(--bc-text); }
.btn-outline:hover { border-color: var(--bc-primary); color: var(--bc-primary); }
.btn-danger { background: var(--bc-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--bc-text-muted); }
.btn-ghost:hover { color: var(--bc-text); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* WhatsApp CTA */
.btn-whatsapp {
  background: #22c55e; color: #fff; border-radius: var(--bc-radius-sm);
  padding: 0.8rem 1.25rem; font-weight: 700; font-size: 0.95rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-whatsapp:hover { background: #16a34a; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--bc-text); }
.field .hint { font-size: 0.75rem; color: var(--bc-text-muted); margin-top: 0.3rem; }
.input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  background: #fff;
  color: var(--bc-text);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--bc-primary); box-shadow: 0 0 0 3px var(--bc-primary-light);
}
textarea.input { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; }
.color-input { display: flex; align-items: center; gap: 0.6rem; }
.color-input input[type=color] { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--bc-border); border-radius: var(--bc-radius-sm); background: #fff; }

/* Linha de característica (Campo + valores + remover) — layout próprio,
   não usa o grid genérico de .form-row para o campo de tags ter espaço. */
.spec-row { display: flex; align-items: flex-start; gap: 0.6rem; }
.spec-row > input[name="specs_key[]"] { flex: 0 0 160px; }
.spec-row > .tag-field { flex: 1; min-width: 0; }
.spec-row > button { flex: 0 0 auto; margin-top: 0.1rem; }
@media (max-width: 560px) {
  .spec-row { flex-wrap: wrap; }
  .spec-row > input[name="specs_key[]"] { flex: 1 1 100%; }
  .spec-row > .tag-field { flex: 1 1 100%; }
}

/* Campo de valores múltiplos (tags) — ex: RAM com 8GB, 12GB, 32GB */
.tag-field {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  min-height: 2.6rem;
  border: 1px solid var(--bc-border); border-radius: var(--bc-radius-sm);
  padding: 0.5rem 0.6rem;
  background: #fff; cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.tag-field:focus-within { border-color: var(--bc-primary); box-shadow: 0 0 0 3px var(--bc-primary-light); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--bc-primary); color: #fff;
  border-radius: 999px; padding: 0.3rem 0.4rem 0.3rem 0.85rem;
  font-size: 0.82rem; font-weight: 600; line-height: 1.2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}
.tag-chip-remove {
  width: 18px; height: 18px; border-radius: 50%; border: none; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.25); color: #fff;
  font-size: 0.8rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.tag-chip-remove:hover { background: var(--bc-danger); }
.tag-typer {
  flex: 1; min-width: 120px; border: none; outline: none;
  font-size: 0.875rem; padding: 0.3rem 0.1rem; background: transparent; color: var(--bc-text);
}
.tag-typer::placeholder { color: var(--bc-text-soft); }

/* ---------- Tabelas / listas ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; color: var(--bc-text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: .03em; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--bc-border); }
.table td { padding: 0.75rem; border-bottom: 1px solid var(--bc-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--bc-bg); }

/* ---------- Badges/status ---------- */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-success { background: var(--bc-success-light); color: var(--bc-success); }
.badge-danger { background: var(--bc-danger-light); color: var(--bc-danger); }
.badge-muted { background: var(--bc-bg); color: var(--bc-text-muted); }

/* ---------- Alertas ---------- */
.alert { border-radius: var(--bc-radius); padding: 0.75rem 1rem; font-size: 0.85rem; margin-bottom: 1rem; }
.alert-error { background: var(--bc-danger-light); color: var(--bc-danger); border: 1px solid #fecaca; }
.alert-success { background: var(--bc-success-light); color: var(--bc-success); border: 1px solid #bbf7d0; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bc-sidebar-bg); padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--bc-card); border-radius: var(--bc-radius-lg); box-shadow: var(--bc-shadow-md); padding: 2rem; }
.auth-brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.5rem; }
.auth-brand .badge-logo { width: 40px; height: 40px; border-radius: 10px; background: var(--bc-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.auth-brand .brand-name { font-weight: 700; font-size: 1.1rem; }
.auth-title { font-size: 1.1rem; margin-bottom: 0.25rem; }
.auth-sub { color: var(--bc-text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.auth-foot { text-align: center; font-size: 0.85rem; color: var(--bc-text-muted); margin-top: 1.25rem; }

/* ---------- Página pública (catálogo/produto) ---------- */
.public-header {
  position: relative;
  background: var(--store-primary, var(--bc-primary));
  color: #fff;
  padding: 1.75rem 1.25rem 2.25rem;
  text-align: center;
}
/* Com banner, a altura acompanha a largura da tela numa proporção fixa
   (3:1), com limites mín/máx — evita a imagem ficar "esticada e cortada"
   numa faixa fininha em telas largas, ou espremida demais no celular. */
.public-header.has-banner {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 3 / 1;
  min-height: 170px;
  max-height: 320px;
  padding: 1.25rem;
  background-size: cover;
  background-position: center;
  box-sizing: border-box;
}
.public-header.has-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.public-header > * { position: relative; }
.public-header .store-logo { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; margin: 0 auto 0.75rem; background: rgba(255,255,255,0.15); }
.public-header h1 { font-size: 1.15rem; }
.public-header .catalog-title { font-size: 0.85rem; opacity: 0.9; margin-top: 0.2rem; }

.public-body { max-width: 720px; margin: -1.25rem auto 0; padding: 0 1rem 2.5rem; }

.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; margin-top: 1rem; }
@media (min-width: 640px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }

.product-card { background: var(--bc-card); border-radius: var(--bc-radius); box-shadow: var(--bc-shadow); overflow: hidden; }
.product-card .thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--bc-bg); }
.product-card .info { padding: 0.65rem 0.75rem; }
.product-card .name { font-size: 0.82rem; font-weight: 600; line-height: 1.25; margin-bottom: 0.25rem; }
.product-card .price { font-size: 0.85rem; font-weight: 700; color: var(--store-primary, var(--bc-primary)); }

.share-bar { display: flex; justify-content: flex-end; margin-top: 0.75rem; }

.product-gallery { border-radius: var(--bc-radius-lg); overflow: hidden; background: var(--bc-card); box-shadow: var(--bc-shadow); }
.product-gallery .main-photo { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--bc-bg); }
.product-gallery .thumbs { display: flex; gap: 0.5rem; padding: 0.6rem; overflow-x: auto; }
.product-gallery .thumbs img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; border: 2px solid transparent; cursor: pointer; flex-shrink: 0; }
.product-gallery .thumbs img.active { border-color: var(--store-primary, var(--bc-primary)); }

.product-detail-card { background: var(--bc-card); border-radius: var(--bc-radius-lg); box-shadow: var(--bc-shadow); padding: 1.25rem; margin-top: 1rem; }
.product-detail-card .price { font-size: 1.5rem; font-weight: 700; color: var(--store-primary, var(--bc-primary)); margin: 0.4rem 0 1rem; }
.spec-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 0.6rem; margin: 1rem 0; }
.spec-item { background: var(--bc-bg); border-radius: var(--bc-radius-sm); padding: 0.55rem 0.7rem; }
.spec-item .k { font-size: 0.68rem; color: var(--bc-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.spec-item .v { font-size: 0.85rem; font-weight: 600; }

.cta-row { display: flex; gap: 0.6rem; margin-top: 1.25rem; flex-wrap: wrap; }
.cta-row .btn-whatsapp, .cta-row .btn-outline { flex: 1; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bc-text-muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .app-shell { position: relative; }
  .topbar .menu-toggle { display: inline-flex; }
}
@media (min-width: 901px) {
  .topbar .menu-toggle { display: none; }
}
.menu-toggle { background: none; border: none; font-size: 1.25rem; color: var(--bc-text); padding: 0.4rem; }

/* ---------- Pré-visualização de imagens antes do envio ---------- */
/* Card "Adicionar fotos" (dropzone clicável, estilo Marketplace) */
.upload-dropzone {
  position: relative;
  display: block;
  border: 2px dashed var(--bc-border);
  border-radius: var(--bc-radius-lg);
  background: var(--bc-bg);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease;
}
.upload-dropzone:hover { border-color: var(--bc-primary); background: var(--bc-primary-light); }
.upload-dropzone.disabled { opacity: 0.5; pointer-events: none; }
.upload-dropzone .upload-icon { color: var(--bc-text-soft); margin-bottom: 0.4rem; display: flex; justify-content: center; position: relative; z-index: 1; }
.upload-dropzone .upload-icon .icon-svg { width: 32px; height: 32px; }
.upload-dropzone .upload-text { font-weight: 600; font-size: 0.9rem; color: var(--bc-text); position: relative; z-index: 1; }
.upload-dropzone .upload-hint { font-size: 0.75rem; color: var(--bc-text-muted); margin-top: 0.25rem; position: relative; z-index: 1; }
.upload-dropzone:has(img) .upload-hint {
  color: #fff; background: rgba(15,23,42,.65); padding: 0.15rem 0.5rem; border-radius: 999px; display: inline-block;
}

/* Fileira de imagens (novas pendentes e/ou já salvas) lado a lado */
.image-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }
.image-row-item { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--bc-border); background: var(--bc-bg); flex-shrink: 0; }
.image-row-item img { width: 100%; height: 100%; object-fit: cover; }
.image-row-item .img-move-actions {
  position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: space-between; padding: 3px;
  opacity: 0; transition: opacity .15s ease;
  background: linear-gradient(to top, rgba(15,23,42,.6), transparent 65%);
}
.image-row-item:hover .img-move-actions,
.image-row-item:focus-within .img-move-actions { opacity: 1; }
.img-move-btn, .img-remove-btn {
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(15, 23, 42, 0.75); color: #fff; border: none;
  font-size: 0.75rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.img-move-btn:hover { background: var(--bc-primary); }
.img-remove-btn { position: absolute; top: 3px; right: 3px; font-size: 0.85rem; }
.img-remove-btn:hover { background: var(--bc-danger); }
.image-row-item .img-cover-badge {
  position: absolute; top: 3px; left: 3px; background: var(--bc-primary); color: #fff;
  font-size: 0.6rem; font-weight: 700; padding: 1px 5px; border-radius: 4px;
}

/* ---------- Ícones inline ---------- */
.icon-svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn .icon-svg { width: 16px; height: 16px; }
.stat-icon .icon-svg { width: 20px; height: 20px; }
.menu-toggle .icon-svg { width: 20px; height: 20px; }
.empty-state .icon-svg { width: 40px; height: 40px; color: var(--bc-text-soft); }

@media (max-width: 640px) {
  .content { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
