/* ===========================================================
   EzStore — Folha de estilo principal
   Mobile-first, tema claro/escuro via [data-theme], cores
   personalizáveis por --bg e --accent (injetadas inline).
   =========================================================== */

:root {
  --accent: #6366f1;
  --accent-contrast: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .12);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .08);
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Tema claro (padrão) ---- */
:root,
[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --input-bg: #ffffff;
}

/* ---- Tema escuro ---- */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --input-bg: #0f172a;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page-bg, var(--bg));
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- Cabeçalho ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.02em;
}
.brand .logo-badge {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: grid; place-items: center;
  font-weight: 900;
}
.nav { display: flex; align-items: center; gap: 6px; }
.nav a {
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .92rem;
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--accent); }

/* botão de tema */
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 1.1rem;
}
.theme-toggle:hover { background: var(--surface-2); }

/* ---- Botões ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform .04s ease, filter .15s ease;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 22px; font-size: 1.02rem; }
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--surface-2); filter: none; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: #ef4444; }
.btn-wa { background: #25d366; color: #052e16; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---- Cards / superfícies ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }

.section-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0;
}
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

/* ---- Formulários ---- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.textarea { min-height: 90px; resize: vertical; }
.hint { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 56px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 3px;
}

/* ---- Flash ---- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-weight: 600;
  font-size: .92rem;
  border: 1px solid transparent;
}
.flash-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.flash-info    { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
[data-theme="dark"] .flash-success { background: #14331f; color: #86efac; border-color: #14532d; }
[data-theme="dark"] .flash-error   { background: #3b1414; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .flash-info    { background: #14233b; color: #93c5fd; border-color: #1e3a8a; }

/* ---- Layout de páginas ---- */
.page { padding: 26px 0 80px; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-premium { background: linear-gradient(135deg, #f59e0b, #f43f5e); color: #fff; border: none; }
.badge-free { background: var(--surface-2); }

/* ---- Grid de produtos ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
/* Vitrine pública: sempre 2 produtos por linha */
.product-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.store-wrap { max-width: 640px; margin: 0 auto; }
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
  display: flex;
  flex-direction: column;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.product-thumb {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  background: var(--surface-2);
}
.product-thumb.placeholder {
  display: grid; place-items: center;
  color: var(--text-muted);
  font-size: 2rem;
}
.product-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name { font-weight: 700; font-size: .98rem; line-height: 1.3; }
.product-price { color: var(--accent); font-weight: 800; font-size: 1.05rem; }

/* amostras de cor */
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}

/* chips de opção (seleção na loja) */
.opt-group { margin-bottom: 16px; }
.opt-label { font-weight: 700; font-size: .85rem; margin-bottom: 8px; display: block; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--text);
}
.chip .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 1px var(--border); }

/* ---- Loja pública: cabeçalho da loja ---- */
.store-hero {
  text-align: center;
  padding: 30px 16px 16px;
  color: var(--text);
}
.store-avatar {
  width: 84px; height: 84px;
  border-radius: 22px;
  margin: 0 auto 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: grid; place-items: center;
  font-size: 2rem; font-weight: 900;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.store-name { font-size: 1.6rem; font-weight: 800; margin: 0; letter-spacing: -.02em; }

/* ---- Galeria de imagens (modal da vitrine) ---- */
.gallery-main {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-2);
}
.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.gthumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: .7;
}
.gthumb.active { border-color: var(--accent); opacity: 1; }
.gthumb:hover { opacity: 1; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: 18px 18px 0 0;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  position: sticky; top: 0;
  background: var(--surface);
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  z-index: 1;
}
.modal-body { padding: 18px; }
.modal-foot {
  position: sticky; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  display: grid; gap: 10px;
}
.close-x {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: var(--text-muted); line-height: 1;
}

/* ---- Hero da landing ---- */
.hero {
  text-align: center;
  padding: 60px 16px 30px;
}
.hero h1 {
  font-size: 2.3rem;
  font-weight: 900;
  letter-spacing: -.03em;
  margin: 0 0 14px;
  line-height: 1.1;
}
.hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 560px; margin: 0 auto 26px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 40px 0;
}
.feature { padding: 22px; }
.feature .ico { font-size: 1.8rem; margin-bottom: 8px; }
.feature h3 { margin: 0 0 6px; font-size: 1.05rem; }
.feature p { margin: 0; color: var(--text-muted); font-size: .92rem; }

/* tabela de preços */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin: 30px 0; }
.plan { padding: 26px; text-align: center; position: relative; }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.plan .price { font-size: 2.4rem; font-weight: 900; margin: 10px 0; }
.plan .price small { font-size: .9rem; font-weight: 600; color: var(--text-muted); }
.plan ul { list-style: none; padding: 0; margin: 18px 0; text-align: left; }
.plan li { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.plan li:before { content: "✓ "; color: #22c55e; font-weight: 800; }

/* ---- Utilidades ---- */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--border); border: none; margin: 18px 0; }
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty .ico { font-size: 3rem; margin-bottom: 10px; }

/* auth */
.auth-wrap {
  min-height: calc(100vh - 60px);
  display: grid; place-items: center;
  padding: 30px 16px;
}
.auth-card { width: 100%; max-width: 420px; }

/* ---- Responsivo ---- */
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; }
  .hero h1 { font-size: 3rem; }
}
@media (max-width: 480px) {
  .nav a { padding: 8px 9px; font-size: .85rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}

/* barra fixa de ação (mobile) na loja pública */
.sticky-cta {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  z-index: 40;
}

/* prompt de instalação PWA */
#installBar {
  display: none;
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); border-radius: 999px;
  padding: 8px 8px 8px 16px; align-items: center; gap: 12px; z-index: 60;
  max-width: calc(100% - 24px);
}
#installBar.show { display: flex; }
