/* components.css — componentes base (BEM-ish). Sempre tokens, nunca cor hardcoded. */

/* ════════ Botões ════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
.btn:hover  { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn--primary   { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--secondary { background: var(--bg); border-color: var(--border-strong); }
.btn--ghost     { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--bg-muted); box-shadow: none; }
.btn--danger    { background: var(--danger); border-color: var(--danger); color: var(--primary-text); }
.btn--success   { background: var(--success, #16a34a); border-color: var(--success, #16a34a); color: #fff; }
.btn--block     { width: 100%; }
/* "ou adicionar manualmente" (entrada manual recolhível na venda) */
.catalogo-manual > summary { cursor: pointer; color: var(--text-secondary); font-size: var(--text-sm); font-weight: var(--fw-medium); padding: 4px 0; list-style: none; }
.catalogo-manual > summary::-webkit-details-marker { display: none; }
.catalogo-manual > summary::before { content: '＋ '; }
.catalogo-manual[open] > summary::before { content: '－ '; }
.btn--sm        { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn--lg        { min-height: 52px; padding: 0 var(--space-6); font-size: var(--text-base); }

/* ════════ Card ════════ */
.card {
  padding: var(--space-5);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.card__title { font-size: var(--text-lg); font-weight: var(--fw-semibold); }

/* ════════ Field (label + input) ════════ */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field__label { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-secondary); }
.field__input,
.field__select,
.field__textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.field__textarea { min-height: 88px; resize: vertical; }
.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--success-bg);
}
.field__help  { font-size: var(--text-xs); color: var(--text-muted); }
.field__error { font-size: var(--text-xs); color: var(--danger); }
.field--inline { flex-direction: row; gap: var(--space-3); }

/* Campo de senha com botão "olhinho" */
.field__pass { position: relative; }
.field__pass .field__input { padding-right: 46px; }
.field__eye {
  position: absolute; top: 0; right: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
}
.field__eye:hover { color: var(--text); }

/* Linha "lembrar meus dados" */
.checkrow { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); cursor: pointer; }
.checkrow input { width: 18px; height: 18px; accent-color: var(--primary); }
.checkrow span { font-size: var(--text-sm); color: var(--text-secondary); }

/* Botão flutuante "Instalar app" — só nas telas públicas; some quando já instalado */
.ios-steps { margin: var(--space-3) 0 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: var(--space-3); color: var(--text-secondary); }
.ios-steps li { line-height: 1.45; }

/* Sino: badge de contagem */
.iconbtn--bell { position: relative; }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: var(--fw-bold); line-height: 1;
  color: #fff; background: var(--danger);
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 2px var(--bg);
}
/* Some de verdade quando não há notificação (o display acima vencia o atributo hidden). */
.notif-badge[hidden] { display: none; }

/* ════════ Modal de pagamento (Pix / Cartão) ════════ */
.pay-seg {
  display: flex; gap: 4px; background: var(--bg-muted);
  padding: 4px; border-radius: var(--radius-full); margin-bottom: var(--space-4);
}
.pay-seg__btn {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 10px 8px; border-radius: var(--radius-full);
  font-weight: var(--fw-bold); font-size: var(--text-sm); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, color .15s;
}
.pay-seg__btn.is-active { background: var(--neutral-0); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.pay-pane { min-height: 96px; }
.pay-loading { text-align: center; color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-5) var(--space-2); }
.pay-pix { text-align: center; }
.pay-pix__qr { width: 188px; height: 188px; margin: 0 auto var(--space-3); display: block; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.pay-pix__code {
  width: 100%; box-sizing: border-box; font: 12px/1.4 ui-monospace, monospace;
  padding: 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-muted); color: var(--ink); resize: none;
}
.pay-hint { text-align: center; color: var(--text-muted); font-size: var(--text-sm); margin-top: var(--space-2); }
#brick_card { margin: 0 auto; }

/* Central de notificações (lista do sino) */
.notif-list { display: flex; flex-direction: column; gap: var(--space-1); }
.notif-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  width: 100%; text-align: left;
  padding: var(--space-3); border: none; background: transparent;
  border-radius: var(--radius-lg);
}
.notif-item.is-link { cursor: pointer; }
.notif-item.is-link:hover { background: var(--bg-muted); }
.notif-item__icon {
  flex-shrink: 0; width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  color: var(--primary); background: var(--bg-subtle, var(--bg-muted));
}
.notif-item__icon--trista, .notif-item__icon--trial, .notif-item__icon--vence { color: var(--warning); }
.notif-item__icon--parcela { color: var(--accent, var(--danger)); }
.notif-item__icon--aniversario { color: var(--mod-pink); }
.notif-item__icon--comunicado { color: var(--secondary); }
.notif-item__icon--ativa { color: var(--primary); }
.notif-item__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-item__title { font-weight: var(--fw-semibold); color: var(--ink); }
.notif-item__text { font-size: var(--text-sm); color: var(--text-secondary); }
.notif-item__time { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* Lista do modal de convite de notificações (push.js) */
.push-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.push-list li { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.push-list li > span:first-child { font-size: 1.25em; flex-shrink: 0; }

/* Campo "Cliente" como botão que abre a busca (vendas.js) */
.cliente-picker { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; cursor: pointer; color: var(--ink); }
.cliente-picker__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cliente-picker .icon { flex-shrink: 0; color: var(--text-muted); }

/* Tela cheia de busca (campo fixo no topo, resultados roláveis — não some sob o teclado) */
.search-screen {
  position: fixed; top: 0; left: 0; right: 0;
  height: 100%;            /* sobrescrito via JS pela altura do visualViewport */
  z-index: 2500;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.search-screen__bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: var(--space-2);
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-2)) var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.search-screen__bar .iconbtn { flex-shrink: 0; }
.search-screen__input { flex: 1; }
.search-screen__count {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs); color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.search-screen__list {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--space-2) var(--space-3) var(--space-8);
}
/* Cestinha fixa no rodapé da busca: mostra qtd + total ao vivo (não precisa sair da tela) */
.search-screen__cart {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4) calc(env(safe-area-inset-bottom, 0px) + var(--space-3));
  border-top: 1px solid var(--border); background: var(--surface, var(--bg));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}
.search-screen__cart.is-bump { animation: cart-bump 0.35s ease; }
@keyframes cart-bump { 0%, 100% { transform: scale(1); } 35% { transform: scale(1.06); } }
.ss-cart__info { display: flex; align-items: center; gap: 8px; font-weight: var(--fw-semibold); color: var(--ink); }
.ss-cart__info .icon { color: var(--primary); }
.ss-cart__total { color: var(--primary); }
/* Bolinha que "voa" do botão Inserir até a cestinha */
.fly-dot {
  position: fixed; z-index: 3000; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: var(--radius-full); background: var(--primary); pointer-events: none; opacity: 0.95;
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.55s ease;
}

/* Faixa "Nova versão disponível" (aparece a cada deploy, some ao atualizar) */
.update-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(140px + var(--safe-bottom));   /* acima do FAB (que vai até ~124px) */
  z-index: 1500;
  display: flex; align-items: center; gap: var(--space-2);
  max-width: calc(100vw - 24px);
  white-space: nowrap;                         /* 1 linha, não embola */
  padding: 6px 6px 6px 14px;
  color: #fff; background: var(--ink);
  border-radius: var(--radius-full);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  font-size: var(--text-sm); font-weight: var(--fw-semibold);
}
.update-banner .btn { background: var(--primary); color: var(--primary-text); border: none; white-space: nowrap; }

/* Botão flutuante do WhatsApp (telas públicas) */
.wa-fab {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  width: 56px; height: 56px;
  display: none;
  align-items: center; justify-content: center;
  color: #fff; background: #25D366;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 49;
}
.wa-fab svg { width: 30px; height: 30px; }
body[data-view="home"] .wa-fab,
body[data-view="login"] .wa-fab,
body[data-view="cadastro"] .wa-fab { display: flex; }
@media all and (display-mode: standalone) { .wa-fab { right: 16px; } }

.install-fab {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--primary-text);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 50;
}
body.is-installable[data-view="home"]     .install-fab,
body.is-installable[data-view="login"]    .install-fab,
body.is-installable[data-view="cadastro"] .install-fab { display: inline-flex; }
@media all and (display-mode: standalone) { .install-fab { display: none !important; } }

/* ════════ Topbar ════════ */
.topbar {
  position: sticky;
  top: 0; z-index: var(--z-dropdown);
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 760px;
  margin: 0 auto;
  padding: calc(var(--space-4) + var(--safe-top)) var(--space-4) var(--space-4);
  background: var(--bg-subtle);
}
.topbar__brand { display: flex; align-items: center; gap: var(--space-2); color: var(--text); }
.topbar__logo  { width: 32px; height: 32px; border-radius: var(--radius-md); }
.topbar__name  { font-size: var(--text-lg); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); }
.topbar__actions { display: flex; align-items: center; gap: var(--space-2); }

/* ════════ Bottom-nav ════════ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-dropdown);
  display: flex;
  justify-content: space-around;
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav__item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex: 1;
  min-height: 56px;
  padding: var(--space-2) var(--space-1);
  font-size: 11px;
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease);
}
.bottom-nav__item.is-active { color: var(--primary); font-weight: var(--fw-semibold); }
.bottom-nav__item span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 340px) { .bottom-nav__item span { font-size: 10px; } }

/* ════════ Section header ════════ */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.section-header__title { font-size: var(--text-2xl); }

/* ════════ Badge / status ════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--space-2);
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  border-radius: var(--radius-full);
}
.badge--success { color: var(--success); background: var(--success-bg); }
.badge--warning { color: var(--warning); background: var(--warning-bg); }
.badge--info    { color: var(--info);    background: var(--info-bg); }
.badge--danger  { color: var(--danger);  background: var(--danger-bg); }
.badge--muted   { color: var(--text-muted); background: var(--bg-muted); }

/* ════════ Lista de registros ════════ */
.list { display: flex; flex-direction: column; gap: var(--space-2); }
.list__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.list__item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.list__main  { flex: 1; min-width: 0; }
.list__title { font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list__sub   { font-size: var(--text-sm); color: var(--text-muted); }
.list__value { font-weight: var(--fw-semibold); font-family: var(--font-mono); white-space: nowrap; }

/* ════════ Avatar inicial ════════ */
.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  font-size: var(--text-sm); font-weight: var(--fw-bold);
  color: var(--primary-text); background: var(--primary);
  border-radius: var(--radius-full);
}
.avatar--birthday { background: var(--mod-pink); }

/* ════════ Empty state ════════ */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-12) var(--space-4);
  text-align: center; color: var(--text-muted);
}
.empty .icon { width: 40px; height: 40px; color: var(--text-subtle); }

/* ════════ Skeleton ════════ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--neutral-200) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: skeleton 1.4s ease infinite;
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ════════ FAB (botão flutuante de nova venda) ════════ */
.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(72px + var(--safe-bottom));
  z-index: var(--z-dropdown);
  display: flex; align-items: center; gap: var(--space-2);
  height: 52px; padding: 0 var(--space-5);
  font-weight: var(--fw-semibold);
  color: var(--primary-text); background: var(--primary);
  border: none; border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  transition: transform var(--duration-fast) var(--ease);
}
.fab:hover { transform: translateY(-2px); }
@media (min-width: 1024px) { .fab { bottom: var(--space-6); } }

/* ════════ Toast ════════ */
#toast-root {
  position: fixed;
  top: var(--space-4); right: var(--space-4);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-3);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--space-3);
  min-width: 260px; max-width: 360px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateX(100%);
  transition: all var(--duration) var(--ease-out);
  pointer-events: auto;
}
.toast.is-visible { opacity: 1; transform: translateX(0); }
.toast--success { border-left-color: var(--success); }
.toast--success .icon { color: var(--success); }
.toast--error   { border-left-color: var(--danger); }
.toast--error .icon { color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast--warning .icon { color: var(--warning); }
.toast--info    { border-left-color: var(--info); }
.toast--info .icon { color: var(--info); }
.toast__message { flex: 1; font-size: var(--text-sm); }
.toast__close   { background: none; border: none; color: var(--text-muted); padding: 0; }

@media (max-width: 639px) {
  /* acima do bottom-nav (64px) + FAB (~52px) pra não cobrir o botão de ação */
  #toast-root { top: auto; bottom: calc(128px + var(--safe-bottom)); left: var(--space-4); right: var(--space-4); }
  .toast { min-width: 0; max-width: none; }
}

/* ════════ Modal / bottom-sheet ════════ */
.modal {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity var(--duration) var(--ease);
}
.modal.is-visible { opacity: 1; }
.modal__overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal__panel {
  position: relative;
  width: 100%; max-width: 480px;
  max-height: 92dvh; overflow-y: auto;
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + var(--safe-bottom));
  background: var(--bg);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: var(--shadow-2xl);
  transform: translateY(100%);
  transition: transform var(--duration) var(--ease-out);
}
.modal.is-visible .modal__panel { transform: translateY(0); }
.modal__title { font-size: var(--text-xl); margin-bottom: var(--space-4); }
.modal__body  { margin-bottom: var(--space-5); }
.modal__actions { display: flex; gap: var(--space-3); }
.modal__actions .btn { flex: 1; }

@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal__panel { border-radius: var(--radius-2xl); transform: translateY(16px) scale(0.98); }
  .modal.is-visible .modal__panel { transform: translateY(0) scale(1); }
}
