/* =====================================================================
   Mundo com José · Controle de estoque
   Tokens e componentes extraídos do design (Mundo com José - Estoque).
   ===================================================================== */

:root {
  --navy: #14244A;
  --navy-deep: #0F1B33;
  --blue: #1D4FA3;
  --blue-soft: #E1ECFF;
  --coral: #F2786A;
  --coral-dark: #E25C4B;
  --coral-soft: #FFE6E2;
  --green: #1F8A5B;
  --green-soft: #E6F5EE;
  --muted: #5A6B8C;
  --tab-off: #8C9AB5;
  --page: #EEF3FA;
  --page-outer: #E3EAF5;
  --card: #fff;
  --soft: #F3F6FC;
  --line: #EEF2F8;
  --line-strong: #D5DDEB;
  --line-dash: #C9D6EE;
  --danger: #B4432F;
  --warn: #C9621F;
  --warn-soft: #FFF0E0;
  --danger-soft: #FBE7E3;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 76px;
}

* { box-sizing: border-box; }

/* O atributo hidden precisa vencer qualquer display de componente.
   Sem isto, um container com display:flex continua ocupando a tela. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior-y: none;
}

body {
  background: var(--page-outer);
  font-family: Montserrat, system-ui, -apple-system, sans-serif;
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

input, button, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }

/* ---------------------------------------------------------------------
   Casca do app
   --------------------------------------------------------------------- */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--page);
  overflow: hidden;
}
@media (min-width: 481px) {
  #app { box-shadow: 0 0 60px rgba(20, 36, 74, 0.14); }
}

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
.scroll::-webkit-scrollbar { display: none; }

.page { padding: 12px 20px 0; display: flex; flex-direction: column; gap: 18px; }
.page--tight { gap: 14px; padding-top: 16px; }

.h1 { font-size: 26px; font-weight: 800; }
.h2 { font-size: 20px; font-weight: 700; }
.h3 { font-size: 15px; font-weight: 700; }
.sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row-between { display: flex; justify-content: space-between; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------------------------------------------------------------------
   Cabeçalho / logo
   --------------------------------------------------------------------- */
/* logo.png já vem aparado por tools/preparar-logo.ps1, então nada de recorte */
.brand { display: flex; justify-content: center; padding: 6px 0 2px; }
.brand img { width: 218px; height: auto; display: block; }
.brand-word {
  font-family: 'Dancing Script', cursive;
  font-size: 40px;
  color: var(--blue);
  line-height: 1;
  padding: 20px 0 6px;
}

/* ---------------------------------------------------------------------
   Cards de resumo
   --------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 20px; padding: 16px; }
.stat--primary { background: var(--blue); color: #fff; }
.stat-k { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat--primary .stat-k { color: #fff; opacity: 0.85; }
.stat-v { font-size: 21px; font-weight: 800; margin-top: 6px; }
.stat-v--green { color: var(--green); }
.stat-f { font-size: 12px; margin-top: 4px; color: var(--muted); }
.stat--primary .stat-f { color: #fff; opacity: 0.85; }

/* ---------------------------------------------------------------------
   Atalhos
   --------------------------------------------------------------------- */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button {
  border: 0; background: var(--card); border-radius: 18px; padding: 12px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--navy); font-size: 11.5px; font-weight: 600;
}
.quick-ico {
  width: 40px; height: 40px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.quick-ico--blue { background: var(--blue-soft); }
.quick-ico--coral { background: var(--coral-soft); }

/* ---------------------------------------------------------------------
   Carrossel "Acabando"
   --------------------------------------------------------------------- */
.hscroll {
  display: flex; gap: 10px; overflow-x: auto;
  margin: 0 -20px; padding: 0 20px;
  scrollbar-width: none;
}
.hscroll::-webkit-scrollbar { display: none; }

.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--coral); }
.h3-dot { display: flex; gap: 8px; align-items: center; }

.low-card {
  flex: none; width: 132px; border: 0; background: var(--card); border-radius: 18px;
  padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 8px;
  color: var(--navy);
}
.low-thumb {
  width: 112px; height: 84px; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: var(--blue);
}
.low-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; height: 32px; overflow: hidden; }
.low-qty { font-size: 11.5px; font-weight: 700; }

/* ---------------------------------------------------------------------
   Listas em card branco
   --------------------------------------------------------------------- */
.list { background: var(--card); border-radius: 20px; padding: 4px 14px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

.badge {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.badge--in { background: var(--blue-soft); color: var(--blue); }
.badge--out { background: var(--coral-soft); color: var(--coral-dark); }

.grow { flex: 1; min-width: 0; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-main { font-size: 13.5px; font-weight: 600; }
.t-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.t-right { text-align: right; flex: none; }
.t-qty { font-size: 13.5px; font-weight: 700; }

.empty { text-align: center; padding: 40px 0; color: var(--muted); font-size: 14px; }
.empty--sm { padding: 30px 0; }

/* ---------------------------------------------------------------------
   Produto (linha da lista de estoque)
   --------------------------------------------------------------------- */
.prod {
  border: 0; background: var(--card); border-radius: 20px; padding: 10px;
  display: flex; gap: 12px; align-items: center; text-align: left;
  color: var(--navy); width: 100%;
}
.prod-thumb {
  width: 64px; height: 64px; border-radius: 14px; overflow: hidden; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: var(--blue);
}
.prod-thumb img, .low-thumb img, .pick-thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prod-name { font-size: 14px; font-weight: 700; }
.prod-meta { font-size: 11.5px; color: var(--muted); }
.prod-price { display: flex; gap: 8px; align-items: baseline; margin-top: 2px; flex-wrap: wrap; }
.prod-price b { font-size: 14px; font-weight: 800; color: var(--blue); }
.prod-cost { font-size: 11px; color: var(--muted); }
.prod-cost i { color: var(--green); font-weight: 700; font-style: normal; }

.qty-badge {
  flex: none; min-width: 46px; height: 46px; border-radius: 14px; padding: 0 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.qty-badge b { font-size: 16px; font-weight: 800; line-height: 1; }
.qty-badge span { font-size: 9.5px; font-weight: 600; margin-top: 2px; }
.qty--ok { background: var(--green-soft); color: var(--green); }
.qty--low { background: var(--warn-soft); color: var(--warn); }
.qty--out { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------------
   Clientes
   --------------------------------------------------------------------- */
.client-row {
  width: 100%; border: 0; background: none; display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--navy);
}
.client-row:last-child { border-bottom: 0; }
.avatar {
  width: 42px; height: 42px; border-radius: 21px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.avatar--a { background: var(--coral-soft); color: var(--coral-dark); }
.avatar--b { background: var(--blue-soft); color: var(--blue); }
.avatar--lg { width: 58px; height: 58px; border-radius: 29px; font-size: 19px; }

/* ---------------------------------------------------------------------
   Controles
   --------------------------------------------------------------------- */
.input {
  height: 46px; border-radius: 14px; border: 0; background: var(--card);
  padding: 0 16px; font-size: 14px; color: var(--navy); width: 100%;
}
.input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.input--bordered { border: 1px solid var(--line-strong); background: #fff; height: 48px; font-size: 15px; padding: 0 14px; }
.input--sm { height: 44px; font-size: 14px; }
.input--mini { width: 78px; height: 34px; border-radius: 12px; border: 1px solid var(--line-strong); padding: 0 10px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chip {
  flex: none; border: 0; border-radius: 12px; height: 34px; padding: 0 12px;
  font-size: 12.5px; font-weight: 600; background: var(--soft); color: var(--navy);
}
.chip--round { border-radius: 20px; background: #fff; }
.chip.is-on { background: var(--blue); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
  border: 0; height: 54px; border-radius: 18px; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
}
.btn--primary { background: var(--blue); color: #fff; }
.btn--coral { background: var(--coral); color: #fff; }
.btn--soft { background: var(--blue-soft); color: var(--blue); }
.btn--green { background: var(--green); color: #fff; }
.btn--sm { height: 50px; border-radius: 16px; font-size: 14px; }
.btn--pill { height: 40px; border-radius: 14px; padding: 0 14px; font-size: 13px; width: auto; }
.btn[disabled] { opacity: 0.55; }

.btn-link { border: 0; background: none; font-weight: 700; font-size: 13px; color: var(--blue); }
.btn-link--danger { color: var(--danger); }
.btn-link--muted { color: var(--muted); font-size: 12.5px; text-decoration: underline; padding: 8px; }

/* ---------------------------------------------------------------------
   Barra de abas + FAB
   --------------------------------------------------------------------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 10px 8px var(--safe-b);
  background: var(--card); border-top: 1px solid var(--page-outer);
  display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: start;
  z-index: 3;
}
.tab {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 4px 0; color: var(--tab-off);
}
.tab.is-on { color: var(--blue); }
.fab-wrap { display: flex; justify-content: center; }
.fab {
  width: 58px; height: 58px; margin-top: -26px; border-radius: 29px;
  border: 5px solid var(--page); background: var(--coral); color: #fff;
  font-size: 28px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(242, 120, 106, 0.4);
  transition: transform 0.18s;
}
.fab.is-open { transform: rotate(45deg); }

.fab-menu {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  display: flex; flex-direction: column; gap: 8px; width: 230px;
  animation: fade 0.15s; z-index: 5;
}
.fab-menu button {
  border: 0; background: var(--card); border-radius: 16px; height: 52px; padding: 0 16px;
  font-size: 14px; font-weight: 700; text-align: left; color: var(--navy);
}
.fab-menu .is-in { color: var(--blue); }
.fab-menu .is-out { color: var(--coral-dark); }

/* ---------------------------------------------------------------------
   Sheet
   --------------------------------------------------------------------- */
.backdrop { position: absolute; inset: 0; background: rgba(15, 27, 51, 0.4); animation: fade 0.2s; z-index: 4; }
.backdrop--light { background: rgba(15, 27, 51, 0.35); animation: fade 0.15s; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  max-height: 92%; overflow-y: auto; scrollbar-width: none;
  background: var(--card); border-radius: 30px 30px 0 0;
  padding: 10px 20px calc(34px + var(--safe-b));
  animation: up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet::-webkit-scrollbar { display: none; }
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 14px; }
.sheet-body { display: flex; flex-direction: column; gap: 14px; }
.sheet-body--lg { gap: 16px; }

.hero {
  height: 220px; border-radius: 22px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; font-weight: 800; color: var(--blue);
}
.hero img { width: 100%; height: 100%; object-fit: cover; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--coral); text-transform: uppercase; letter-spacing: 0.08em; }

.mini-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.mini { background: var(--soft); border-radius: 16px; padding: 12px; }
.mini--green { background: var(--green-soft); }
.mini-k { font-size: 11px; color: var(--muted); font-weight: 600; }
.mini--green .mini-k { color: var(--green); }
.mini-v { font-size: 15px; font-weight: 800; margin-top: 4px; }
.mini-f { font-size: 11px; color: var(--green); margin-top: 2px; }

.dashed { border: 1.5px dashed var(--line-dash); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.photo-drop {
  height: 170px; border-radius: 22px; overflow: hidden; position: relative;
  background: var(--soft); border: 1.5px dashed var(--line-dash);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 700;
}
.photo-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-drop .swap {
  position: absolute; right: 10px; bottom: 10px; background: rgba(15, 27, 51, 0.7);
  color: #fff; border-radius: 10px; padding: 6px 10px; font-size: 12px;
}

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 16px; padding: 4px; }
.seg button { border: 0; height: 42px; border-radius: 12px; font-weight: 700; font-size: 14px; background: transparent; color: var(--muted); }
.seg .is-on-in { background: #fff; color: var(--blue); }
.seg .is-on-out { background: #fff; color: var(--coral-dark); }

.picked { display: flex; gap: 12px; align-items: center; background: var(--soft); border-radius: 18px; padding: 10px; }
.pick-thumb {
  width: 52px; height: 52px; border-radius: 12px; overflow: hidden; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--blue);
}
.pick-list { max-height: 230px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; scrollbar-width: none; }
.pick-list::-webkit-scrollbar { display: none; }
.pick-row {
  border: 0; background: var(--soft); border-radius: 14px; padding: 8px;
  display: flex; gap: 10px; align-items: center; text-align: left; color: var(--navy);
}

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 42px; height: 42px; border-radius: 14px; border: 0; background: var(--soft); font-size: 20px; font-weight: 700; color: var(--blue); }
.stepper b { width: 48px; text-align: center; font-size: 20px; font-weight: 800; }

.summary { background: var(--soft); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.summary-row b { font-weight: 700; }
.summary-total {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1px solid #DCE4F2; padding-top: 10px; margin-top: 2px;
}
.summary-total span { font-size: 14px; font-weight: 700; color: var(--navy); }
.summary-total b { font-size: 22px; font-weight: 800; color: var(--blue); }

.note { background: #FFF6E8; border-radius: 14px; padding: 12px 14px; font-size: 13px; color: #7A5418; }
.buy-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }

.wa-preview { background: #E7F6E0; border-radius: 18px; padding: 14px; }
.wa-bubble {
  background: #fff; border-radius: 12px 12px 12px 4px; padding: 12px;
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap;
  max-height: 240px; overflow-y: auto; color: var(--navy);
}
.toggle-row {
  border: 0; background: var(--soft); border-radius: 14px; height: 48px; padding: 0 14px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 600; color: var(--navy); width: 100%;
}
.track { width: 44px; height: 26px; border-radius: 13px; position: relative; display: block; background: #C9D3E4; transition: background 0.15s; }
.track.is-on { background: var(--green); }
.track i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 10px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: left 0.15s; }
.track.is-on i { left: 21px; }

/* ---------------------------------------------------------------------
   Toast / status de sincronização
   --------------------------------------------------------------------- */
.toast {
  position: absolute; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; border-radius: 14px; padding: 12px 16px;
  font-size: 13px; font-weight: 700; box-shadow: 0 10px 30px rgba(15, 27, 51, 0.25);
  animation: toast 0.2s; z-index: 9; max-width: calc(100% - 40px); text-align: center;
}
.toast--err { background: var(--danger); }

.syncbar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 11.5px; font-weight: 700; padding: 6px 12px; flex: none;
  background: #FFF0E0; color: var(--warn);
}
.syncbar--off { background: var(--navy-deep); color: #fff; }

/* ---------------------------------------------------------------------
   Splash
   --------------------------------------------------------------------- */
#splash {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-family: 'Dancing Script', cursive;
  font-size: 38px;
  color: var(--blue);
}

/* ---------------------------------------------------------------------
   Login
   --------------------------------------------------------------------- */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  gap: 18px; padding: 32px 24px calc(32px + var(--safe-b)); max-width: 420px; margin: 0 auto;
}
.auth h1 { font-family: 'Dancing Script', cursive; font-size: 40px; color: var(--blue); margin: 0; line-height: 1; text-align: center; }
.auth p { font-size: 14px; color: var(--muted); text-align: center; margin: 0; line-height: 1.5; }
.auth .input { background: #fff; }
.auth-err { background: var(--danger-soft); color: var(--danger); border-radius: 14px; padding: 12px 14px; font-size: 13px; font-weight: 600; }
.auth-ok { background: var(--green-soft); color: var(--green); border-radius: 14px; padding: 12px 14px; font-size: 13px; font-weight: 600; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); }

.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; font-weight: 600; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }

.btn--google {
  background: #fff; color: var(--navy);
  border: 1px solid var(--line-strong);
  box-shadow: 0 1px 2px rgba(20, 36, 74, 0.06);
}
.btn--google svg { flex: none; }

/* ---------------------------------------------------------------------
   Animações
   --------------------------------------------------------------------- */
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
