/* =============================================================================
   ZEVS Store — Design System
   Theming por tenant via CSS variables (spec §46). O themeService injeta
   --color-primary/secondary/accent a partir das settings da empresa; o resto do
   sistema deriva dessas variáveis. Suporte a tema claro/escuro.
   ========================================================================== */

:root {
  /* Marca ZEVS (fallback / identidade da plataforma) */
  --zevs: #4f46e5;

  /* Cores do tenant (sobrescritas em runtime) */
  --color-primary: #0f172a;
  --color-secondary: #64748b;
  --color-accent: #2563eb;

  /* Superfícies / texto (tema claro) */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --ring: color-mix(in srgb, var(--color-accent) 40%, transparent);

  /* Estado */
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;

  /* Forma */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;

  --sidebar-w: 248px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .25rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
small { color: var(--muted); }

/* ---- Utilitários enxutos --------------------------------------------------- */
.hidden { display: none !important; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.spacer { flex: 1; }
.mt-0{margin-top:0}.mt-2{margin-top:8px}.mt-4{margin-top:16px}.mt-6{margin-top:24px}
.w-full{width:100%}

/* ---- Botões ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .92rem; cursor: pointer; transition: .15s ease;
  background: var(--surface-2); color: var(--text); white-space: nowrap;
}
.btn:hover { filter: brightness(0.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-dark { background: var(--color-primary); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.btn-block { width: 100%; }

/* ---- Formulários ----------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .85rem; color: var(--text); }
.input, .select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; transition: .15s;
}
.input:focus, .select:focus, textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--ring); }
.field .error { color: var(--danger); font-size: .8rem; min-height: 1em; }

/* ---- Cartões --------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px; }
.card-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.kpi .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.kpi .label { color: var(--muted); font-size: .85rem; }

/* ---- Badges ---------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.success { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }
.badge.danger { color: var(--danger); }
.badge.warning { color: var(--warning); }

/* ---- Tabela ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; min-width: 0; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.table th, table.table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.table tbody tr:hover { background: var(--surface-2); }

/* ---- Layout do app (sidebar + header) -------------------------------------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--color-primary); color: #e5e7eb; padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; font-weight: 800; color: #fff; }
.sidebar .brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--color-accent); display: grid; place-items: center; color: #fff; font-weight: 800; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: #cbd5e1; font-weight: 600; font-size: .9rem; cursor: pointer; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: color-mix(in srgb, var(--color-accent) 90%, black 0%); color: #fff; }
.nav-link .ico { width: 18px; text-align: center; }
.sidebar .nav-section { margin-top: 10px; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 8px 12px 2px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 10; }
.content { padding: 24px; }

/* ---- Telas públicas / auth ------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent),
  var(--bg); }
.auth-card { width: 100%; max-width: 420px; }

/* Fundo "blueprint" de roupas (tela de login). Uma camada escura por cima
   deixa o padrão sutil/opaco e mantém o card legível. */
.auth-wrap.auth-art {
  background:
    radial-gradient(1100px 560px at 20% -10%, color-mix(in srgb, var(--color-accent) 16%, transparent), transparent),
    linear-gradient(180deg, rgba(6,10,20,.60), rgba(6,10,20,.72)),
    url("../img/login-bg.svg") center / cover no-repeat,
    #0b1220;
}
.auth-wrap.auth-art .auth-card { box-shadow: 0 24px 60px rgba(0,0,0,.45); }

/* ---- Toast ----------------------------------------------------------------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--color-accent); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px 16px; min-width: 240px; max-width: 360px; animation: slidein .18s ease; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* ---- Modal ----------------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; padding: 20px; z-index: 80; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0,0,0,.25); width: 100%; max-width: 560px; max-height: 90vh; min-width: 0; display: flex; flex-direction: column; }
.modal.lg { max-width: 820px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; min-width: 0; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--muted); line-height: 1; }

/* ---- Toolbar / busca ------------------------------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 380px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.pdv-grid { display: grid; grid-template-columns: 1fr 380px; align-items: start; gap: 16px; }
@media (max-width: 860px) { .pdv-grid { grid-template-columns: 1fr; } }

/* ---- Loading / vazio ------------------------------------------------------- */
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--color-accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-screen { min-height: 60vh; display: grid; place-items: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ---- Vitrine (loja do cliente final) --------------------------------------- */
.store-hero { position: relative; padding: 56px 20px; text-align: center; color: #fff; overflow: hidden;
  background: linear-gradient(135deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 45%, var(--color-accent))); }
.store-hero.has-banner { background-size: cover; background-position: center; }
.store-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.45)); }
.store-hero > * { position: relative; z-index: 1; }
.store-hero .logo-badge { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 18px; background: #fff;
  display: grid; place-items: center; overflow: hidden; box-shadow: 0 10px 34px rgba(0,0,0,.28); }
.store-hero .logo-badge img { width: 100%; height: 100%; object-fit: cover; }
.store-hero h1 { font-size: 2.3rem; margin: 0 0 10px; letter-spacing: -.02em; color: #fff; }
.store-hero p { margin: 0 auto; max-width: 580px; font-size: 1.02rem; opacity: .95; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; }
.chip { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: .85rem; font-weight: 600; cursor: pointer; transition: .15s; }
.chip:hover { border-color: var(--color-accent); color: var(--color-accent); }
.chip.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

.store-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
@media (max-width: 900px) { .store-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px) { .store-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }

.store-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; padding: 0; text-align: left; color: var(--text);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.store-card:hover { transform: translateY(-5px); box-shadow: 0 16px 34px rgba(16,24,40,.16); border-color: transparent; }
/* Foto centralizada e inteira sobre fundo fixo neutro (padronização — Opção 1).
   A mesma cor do padding do Cloudinary (#f2f3f5) deixa a emenda invisível. */
.store-card .thumb { aspect-ratio: 3 / 4; width: 100%; object-fit: contain; background: #f2f3f5; display: block; }
.store-card .noimg { aspect-ratio: 3 / 4; display: grid; place-items: center; font-size: 2.4rem;
  background: linear-gradient(135deg, var(--surface-2), var(--border)); color: var(--muted); }
.store-card .info { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.store-card .cat { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.store-card .pname { font-weight: 700; line-height: 1.3; }
.store-card .price { margin-top: 6px; font-weight: 800; font-size: 1.08rem; color: var(--color-accent); }
.store-card .soldout { position: relative; }
.store-card .tag-soldout { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.7); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 4px 8px; border-radius: 6px; z-index: 1; }
.store-card .tag-promo { position: absolute; top: 10px; left: 10px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 800; padding: 4px 9px; border-radius: 6px; z-index: 1; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.store-card .price .old { text-decoration: line-through; color: var(--muted); font-weight: 600; font-size: .82em; margin-right: 5px; }

.store-footer { margin-top: 52px; padding: 32px 20px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.store-footer .row { justify-content: center; flex-wrap: wrap; gap: 18px; }
.store-footer a { color: var(--color-accent); font-weight: 600; }
@media (max-width: 640px) {
  .store-hero { padding: 40px 18px; }
  .store-hero h1 { font-size: 1.85rem; }
  .store-hero .logo-badge { width: 72px; height: 72px; }
}

/* ---- Grid de colunas (base) ------------------------------------------------ */
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Backdrop do menu lateral no mobile (só aparece quando a sidebar abre). */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }

/* ---- Responsivo ------------------------------------------------------------ */
@media (min-width: 861px) {
  #menuBtn { display: none; } /* no desktop a sidebar fica sempre visível */
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; z-index: 40; height: 100vh;
             width: var(--sidebar-w); transform: translateX(-100%);
             box-shadow: 0 12px 40px rgba(0,0,0,.45); }
  /* Abertura instantânea pela classe (sem transition/animation: 100% confiável). */
  .sidebar.open { transform: translateX(0); }

  /* Topbar do app: condensa para caber no celular. */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar h2 { font-size: 1.05rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .badge { display: none; }         /* nome do usuário (só desktop) */
  .content { padding: 16px 14px; }

  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

  /* Cabeçalho da vitrine/área do cliente: quebra em 2 linhas em vez de estourar. */
  .store-topbar { height: auto !important; flex-wrap: wrap; padding: 10px 12px !important; row-gap: 8px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none !important; }     /* rótulos que somem no mobile (botões viram ícone) */
  .card-body { padding: 16px; }
  /* Modal no celular: alinha ao topo e deixa o OVERLAY rolar (evita cortar
     cabeçalho/rodapé no iOS, onde 90vh conta a barra de endereço) e nunca
     ultrapassa a largura da tela. */
  .modal-overlay { padding: 10px; align-items: start; overflow-y: auto; }
  .modal, .modal.lg { max-width: 100%; max-height: none; }
  .modal-body { padding: 16px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; }
  .toolbar .search { max-width: none; }
  h1 { font-size: 1.35rem; }
  .kpi .value { font-size: 1.45rem; }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr !important; }
}

/* ── Linha do tempo do pedido (conta do cliente) ───────────────────────────── */
.timeline{display:flex;gap:4px;justify-content:space-between;margin:4px 0 8px}
.tl-step{flex:1;text-align:center;position:relative;opacity:.45}
.tl-step.done{opacity:1}
.tl-step:not(:first-child)::before{content:"";position:absolute;top:14px;left:-50%;width:100%;height:3px;background:var(--border);z-index:0}
.tl-step.done:not(:first-child)::before{background:var(--color-primary,#16a34a)}
.tl-dot{position:relative;z-index:1;width:30px;height:30px;line-height:26px;margin:0 auto;border-radius:50%;background:var(--surface,#fff);border:2px solid var(--border);font-size:.9rem}
.tl-step.done .tl-dot{border-color:var(--color-primary,#16a34a)}
.tl-step.current .tl-dot{box-shadow:0 0 0 4px rgba(37,99,235,.18)}
.tl-label{font-size:.72rem;margin-top:4px;line-height:1.2}
.tl-note{padding:10px 12px;border-radius:8px;background:rgba(220,38,38,.08);color:var(--danger,#dc2626);font-weight:600;font-size:.9rem}
/* Parcelamento (chamariz) na vitrine */
.parcela{font-size:.78rem;color:var(--color-primary,#2563eb);margin-top:2px;font-weight:600}

/* Botão "Carregar mais" da vitrine (paginação) */
.store-more { display:flex; justify-content:center; margin-top:30px; }
.store-more .btn { padding:12px 30px; font-weight:700; border-radius:100px; }
