/* ============================================================
   Design tokens — identidade "mercado de bairro"
   Azul (marca/confiança), amarelo (etiqueta de preço), vermelho
   (promoção/oferta). Ícones são SVG inline (js/icons.js) — nada
   de fonte de ícone externa, para nunca depender de um CDN.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --bg: #EEF2F9;
  --surface: #FFFFFF;
  --surface-sunken: #E4EAF5;
  --ink: #16233F;
  --ink-soft: #4E5D82;
  --ink-faint: #8892AF;

  --blue: #1955B0;
  --blue-dark: #0E3A82;
  --blue-darker: #082A61;
  --blue-tint: #E6EEFC;
  --yellow: #FFC42E;
  --yellow-dark: #8A5A00;
  --yellow-tint: #FFF4D8;
  --red: #E23B3B;
  --red-dark: #9C1F1F;
  --red-tint: #FCE6E6;

  --success: #1F8A54;
  --success-tint: #E4F5EB;

  --border: #DCE3F0;
  --border-strong: #BFCBE3;

  --wa-bubble: #DCF8C6;
  --wa-bg: #E9DFD3;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  /* Sombras em duas camadas (contato + difusa) — mais "premium" que uma borda plana */
  --shadow-xs: 0 1px 2px rgba(16, 35, 77, 0.06);
  --shadow-sm: 0 1px 2px rgba(16, 35, 77, 0.05), 0 4px 10px rgba(16, 35, 77, 0.06);
  --shadow-md: 0 2px 4px rgba(16, 35, 77, 0.06), 0 10px 24px rgba(16, 35, 77, 0.09);
  --shadow-lg: 0 8px 16px rgba(9, 26, 61, 0.12), 0 24px 48px rgba(9, 26, 61, 0.18);

  --font-display: 'Baloo 2', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0 0 4px; color: var(--blue-darker); letter-spacing: 0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16.5px; }
p { margin: 0 0 8px; }
a { color: var(--blue); font-weight: 600; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 13px; }
code { background: var(--surface-sunken); padding: 1px 6px; border-radius: 5px; font-family: var(--font-mono); font-size: 12.5px; color: var(--blue-darker); }

.icon { display: inline-block; vertical-align: -4px; flex-shrink: 0; }

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

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(175deg, var(--blue-darker) 0%, var(--blue-dark) 100%);
  color: #EAF0FC;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: relative;
}
.sidebar .brand {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700;
  color: #fff;
  padding: 6px 10px 4px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar .brand .icon { color: var(--yellow); }
.sidebar .brand-sub { font-family: var(--font-body); font-size: 11px; color: #7FA0DA; font-weight: 600; padding: 0 10px 20px; letter-spacing: 0.03em; }
.nav-group { margin-bottom: 4px; padding: 10px 0; }
.nav-group + .nav-group { border-top: 1px solid rgba(255,255,255,0.08); }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; color: #6E92D6; padding: 0 10px 8px; font-weight: 700; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px;
  color: #D2E0FA; text-decoration: none; font-size: 13.5px; font-weight: 600;
  margin-bottom: 2px; transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.nav-link .icon { color: #7797D4; transition: color 0.15s ease; }
.nav-link:hover { background: rgba(255,255,255,0.08); }
.nav-link:hover .icon { color: #fff; }
.nav-link.active { background: var(--yellow); color: var(--blue-darker); box-shadow: var(--shadow-xs); }
.nav-link.active .icon { color: var(--blue-darker); }
.sidebar-footer { margin-top: auto; padding: 14px 10px 4px; font-size: 12px; color: #7A9DDA; border-top: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 10px; }
.sidebar-footer .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.12); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 30px; background: var(--surface);
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(16, 35, 77, 0.04);
  position: relative; z-index: 5;
}
.topbar h1 { font-size: 21px; }
.content { padding: 26px 30px 64px; max-width: 1180px; width: 100%; animation: content-in 0.25s ease-out; }
@keyframes content-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .content { animation: none; } }

/* ---------- Buttons ---------- */
button, .btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 9px 17px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease, box-shadow 0.14s ease;
}
button:active, .btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(14, 58, 130, 0.15), 0 2px 6px rgba(14, 58, 130, 0.18); }
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 2px 4px rgba(14, 58, 130, 0.2), 0 4px 12px rgba(14, 58, 130, 0.22); }
.btn-secondary { background: var(--surface); color: var(--blue-darker); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--blue-tint); border-color: var(--blue); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-sunken); }
.btn-danger { background: var(--red-tint); color: var(--red-dark); border-color: #F3BEBE; }
.btn-danger:hover { background: #FBD4D4; }
.btn-accent { background: var(--yellow); color: var(--blue-darker); }
.btn-accent:hover { box-shadow: 0 0 0 3px var(--yellow-tint); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

/* ---------- Cards & sections ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin-bottom: 8px; font-weight: 700; }

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

/* ---------- Metric cards (dashboard) ---------- */
.metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 17px 19px 19px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.metric:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.metric::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--bar-color, var(--blue));
}
.metric-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--icon-bg, var(--blue-tint)); color: var(--icon-color, var(--blue));
  margin-bottom: 12px;
}
.metric .label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; font-weight: 600; }
.metric .value { font-family: var(--font-display); font-size: 32px; font-weight: 700; color: var(--ink); }
.metric .value.accent { color: var(--yellow-dark); }
.metric .value.primary { color: var(--blue); }
.metric .value.danger { color: var(--red); }
.metric.m-blue { --bar-color: var(--blue); --icon-bg: var(--blue-tint); --icon-color: var(--blue); }
.metric.m-yellow { --bar-color: var(--yellow); --icon-bg: var(--yellow-tint); --icon-color: var(--yellow-dark); }
.metric.m-red { --bar-color: var(--red); --icon-bg: var(--red-tint); --icon-color: var(--red-dark); }
.metric.m-success { --bar-color: var(--success); --icon-bg: var(--success-tint); --icon-color: var(--success); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=url], textarea, select {
  width: 100%; font-family: var(--font-body); font-size: 14px;
  padding: 9px 12px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
textarea { resize: vertical; min-height: 90px; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3.5px var(--blue-tint);
}
.field-hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; transition: background 0.15s; cursor: pointer;
}
.switch .track::after {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s; box-shadow: var(--shadow-xs);
}
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 700; padding: 9px 10px; border-bottom: 2px solid var(--border); }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.mono, .mono-text { font-family: var(--font-mono); font-size: 13px; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover td { background: var(--blue-tint); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warning { background: var(--yellow-tint); color: var(--yellow-dark); }
.badge-danger { background: var(--red-tint); color: var(--red-dark); }
.badge-neutral { background: var(--surface-sunken); color: var(--ink-soft); }
.badge-sale {
  background: var(--red); color: #fff; font-weight: 800; padding: 4px 11px;
  border-radius: 4px; font-size: 12px; box-shadow: var(--shadow-xs);
}

/* ---------- Empty / loading states ---------- */
.empty-state { text-align: center; padding: 52px 20px; color: var(--ink-soft); }
.empty-state .icon { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-sunken); color: var(--ink-faint); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; padding: 0; }
.empty-state .icon svg { width: 24px; height: 24px; }
.empty-state h3 { color: var(--blue-darker); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface-sunken) 25%, #eef3fc 37%, var(--surface-sunken) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); height: 16px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Toasts ---------- */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 500; }
.toast {
  background: var(--blue-darker); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-lg); min-width: 220px; font-weight: 500;
  animation: toast-in 0.18s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--red-dark); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9, 20, 45, 0.5); backdrop-filter: blur(1px);
  display: flex; align-items: center; justify-content: center; z-index: 400; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; padding: 24px; border-top: 5px solid var(--yellow);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.hidden { display: none !important; }

/* ---------- WhatsApp preview (cores reais do WhatsApp, propositalmente) ---------- */
.wa-preview { background: var(--wa-bg); border-radius: var(--radius-md); padding: 14px; background-image: linear-gradient(rgba(255,255,255,0.35), rgba(255,255,255,0.35)); }
.wa-preview-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding-bottom: 8px; }
.wa-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.wa-preview-header .wa-name { font-weight: 700; font-size: 13.5px; }
.wa-preview-header .wa-status { font-size: 11px; color: var(--ink-soft); }
.wa-bubble { background: var(--wa-bubble); border-radius: 8px; padding: 9px 11px; font-size: 13.5px; white-space: pre-wrap; max-width: 92%; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,0.08); font-family: var(--font-body); }
.wa-time { display: block; text-align: right; font-size: 10px; color: #4f7a56; margin-top: 4px; }

/* ---------- Flow tree (visual builder) ---------- */
.flow-tree { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 10px 0; }
.flow-node { background: var(--blue-tint); border: 2px solid var(--blue); border-radius: var(--radius-md); padding: 10px 16px; font-size: 13.5px; font-weight: 700; text-align: center; min-width: 160px; color: var(--blue-darker); }
.flow-node.entry { border-color: var(--yellow); background: var(--yellow-tint); color: var(--yellow-dark); }
.flow-connector { width: 2px; height: 20px; background: var(--border-strong); }
.flow-branches { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.flow-branch { display: flex; flex-direction: column; align-items: center; }
.flow-option-node { background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; min-width: 128px; text-align: center; cursor: pointer; font-weight: 600; transition: border-color 0.12s ease, background 0.12s ease; }
.flow-option-node:hover { border-color: var(--blue); background: var(--blue-tint); }

/* ---------- Login page (layout corporativo em duas colunas) ---------- */
.login-wrap { min-height: 100vh; display: flex; background: var(--bg); }
.login-hero {
  flex: 1 1 46%; max-width: 560px; background: linear-gradient(155deg, var(--blue-darker) 0%, var(--blue) 100%);
  display: flex; flex-direction: column; justify-content: center; padding: 56px 60px; color: #fff;
  position: relative; overflow: hidden;
}
.login-hero::after { content: ''; position: absolute; right: -70px; bottom: -70px; width: 260px; height: 260px; border-radius: 50%; background: var(--yellow); opacity: 0.12; }
.login-hero-icon { width: 54px; height: 54px; border-radius: 14px; background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; color: var(--yellow); margin-bottom: 22px; }
.login-hero h2 { color: #fff; font-size: 26px; margin-bottom: 12px; line-height: 1.3; }
.login-hero p { color: #C6D8F5; font-size: 14.5px; max-width: 380px; line-height: 1.6; }
.login-hero-list { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 14px; }
.login-hero-list li { display: flex; align-items: center; gap: 12px; color: #DCE8FB; font-size: 13.5px; font-weight: 500; }
.login-hero-list .icon { color: var(--yellow); }
.login-form-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; background: var(--surface); }
.login-card { width: 100%; max-width: 356px; }
.login-card .brand-mark { font-family: var(--font-display); font-size: 23px; font-weight: 700; color: var(--blue-darker); margin-bottom: 4px; display: flex; align-items: center; gap: 9px; }
.login-card .brand-mark .icon { color: var(--blue); }
@media (max-width: 760px) {
  .login-hero { display: none; }
  .login-form-panel { background: var(--bg); }
  .login-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 32px; border-top: 5px solid var(--yellow); }
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; gap: 10px; align-items: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.icon-btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
