/* Prospex — identidade visual Base do E-commerce (basedoecommerce.com.br) */
@font-face {
  font-family: "Radeny";
  src: url("../fonts/Radeny.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #09090B;
  --surface: #18181B;
  --surface-2: #1F1F23;
  --border: #27272A;
  --text: #FFFFFF;
  --muted: #9CA3AF;
  --primary: #D1F277;
  --primary-ink: #09090B;
  --secondary: #06DBF3;
  --success: #61CE70;
  --danger: #F87171;
  --warning: #FBBF24;

  --font: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Radeny", "Sora", sans-serif;
  --r-sm: 8px;
  --r-md: 15px;
  --r-pill: 25px;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Títulos em Radeny (fonte de display da marca; só tem peso 400). Texto padrão em Sora. */
h1, h2, h3 { margin: 0 0 .5rem; font-family: var(--display); font-weight: 400; letter-spacing: .01em; line-height: 1.15; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
h1 svg, h2 svg, h3 svg { width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; color: var(--primary); }
.display { font-family: var(--display); font-weight: 400; letter-spacing: .01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.accent { color: var(--primary); }
.cyan { color: var(--secondary); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 16px;
}
.sidebar .brand { display: block; padding: 0 8px 24px; }
.sidebar .brand img { width: 170px; height: auto; display: block; }
.sidebar .brand span { display: block; margin-top: 8px; font-family: var(--display); font-size: 18px; letter-spacing: .04em; color: var(--primary); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 600;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary); color: var(--primary-ink); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .me { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar .me form { display: inline; }

.main { padding: 32px clamp(16px, 3vw, 40px); min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.page-head p { margin: 0; }
.topbar { display: none; }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
.stack > * + * { margin-top: 16px; }

.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.kpi .value { font-family: var(--display); font-size: 2.4rem; line-height: 1.1; margin-top: 6px; }
.kpi .value.accent { color: var(--primary); }
.kpi .hint { color: var(--muted); font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: #3F3F46; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #DDF795; }
.btn.secondary { background: transparent; border-color: var(--secondary); color: var(--secondary); }
.btn.danger { background: transparent; border-color: #7F1D1D; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.pill { border-radius: var(--r-pill); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn[disabled], .btn.htmx-request { opacity: .6; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; font: 14px var(--font);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(6, 219, 243, .15); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; font-size: 14px; margin: 0; }
.check input { accent-color: var(--primary); width: 16px; height: 16px; }
.field { margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.seg-marca_fabricante { color: var(--primary); border-color: rgba(209, 242, 119, .35); }
.badge.seg-sem_ecommerce { color: var(--secondary); border-color: rgba(6, 219, 243, .35); }
.badge.seg-ecommerce_fraco { color: #C4B5FD; border-color: rgba(196, 181, 253, .35); }
.badge.seg-outro { color: var(--muted); }
.badge.st-ok, .badge.st-fechado { color: var(--success); }
.badge.st-erro, .badge.st-perdido { color: var(--danger); }
.badge.st-rodando { color: var(--secondary); }
.badge.st-fila { color: var(--warning); }

.score {
  display: inline-grid; place-items: center;
  min-width: 40px; height: 26px; padding: 0 8px;
  border-radius: var(--r-pill); font-weight: 700; font-size: 13px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.score.hi { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.score.mid { color: var(--secondary); border-color: rgba(6, 219, 243, .4); }

/* Tabelas */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .name { font-weight: 600; color: var(--text); }
td .sub { color: var(--muted); font-size: 12px; }
.icons { display: flex; gap: 8px; color: var(--muted); }
.icons svg { width: 16px; height: 16px; }
.icons .on { color: var(--secondary); }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; color: var(--muted); }

/* Barras do dashboard */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row { color: var(--text); }
.bar-row:hover { text-decoration: none; }
.bar-row .track { display: block; height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars.alt .fill { background: var(--secondary); }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.bar-row:hover .fill { filter: brightness(1.12); }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.kcol { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; min-height: 300px; display: flex; flex-direction: column; }
.kcol.over { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.kcol header { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 10px; font-family: var(--display); font-size: 15px; font-weight: 400; }
.kcol header .count { font-family: var(--font); }
.kcol header .count { color: var(--muted); font-weight: 600; font-size: 12px; }
.kcards { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.kcard { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: grab; }
.kcard:hover { border-color: #3F3F46; }
.kcard.dragging { opacity: .4; }
.kcard .t { font-weight: 600; display: block; color: var(--text); margin-bottom: 4px; }
.kcard .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 8px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 1px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--secondary); }
.timeline li.k-whatsapp::before { background: var(--primary); }
.timeline li.k-nota::before { background: var(--muted); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .what { white-space: pre-wrap; }

/* Dados do lead */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Alertas */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.alert { padding: 12px 16px; border-radius: var(--r-sm); border: 1px solid; font-weight: 500; }
.alert.ok { border-color: rgba(97, 206, 112, .4); background: rgba(97, 206, 112, .08); color: #A7F3B0; }
.alert.erro { border-color: rgba(248, 113, 113, .4); background: rgba(248, 113, 113, .08); color: #FCA5A5; }
.alert.aviso { border-color: rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .08); color: #FDE68A; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#toasts .alert { background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: fade 4s forwards; }
@keyframes fade { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .display { font-size: 1.6rem; color: var(--text); display: block; margin-bottom: 6px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(97, 206, 112, .2); }
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, .2); }
details summary { cursor: pointer; color: var(--secondary); font-weight: 600; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--secondary); border-right-color: transparent; border-radius: 50%; animation: rot .8s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .hero {
  padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(600px 400px at 15% 85%, rgba(209, 242, 119, .14), transparent 70%),
    radial-gradient(500px 360px at 85% 15%, rgba(6, 219, 243, .12), transparent 70%),
    var(--surface);
  border-right: 1px solid var(--border);
}
.auth .hero img { width: 200px; }
.auth .hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(2.2rem, 4vw, 3.4rem); line-height: 1.05; max-width: 12ch; }
.auth .hero h1 em { font-style: normal; color: var(--primary); }
.auth .form { display: grid; place-items: center; padding: 32px 16px; }
.auth .form .card { width: min(400px, 100%); padding: 32px; }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .6); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30; }
  .topbar img { height: 28px; }
  .main { padding: 20px 16px; }
  .grid.side { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth .hero { padding: 32px 16px; min-height: 0; gap: 24px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .bar-row { grid-template-columns: 100px 1fr 36px; }
  .hide-sm { display: none; }
}

/* Dicas (tooltips) dos campos */
label .tip, h2 .tip, h3 .tip { margin-left: 4px; }
.tip {
  position: relative; display: inline-grid; place-items: center;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--secondary);
  font: 700 10px/1 var(--font); cursor: help; vertical-align: 1px; text-transform: none; letter-spacing: 0;
}
.tip:hover, .tip:focus { border-color: var(--secondary); outline: none; }
.tip::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: 280px; padding: 10px 12px;
  background: #27272A; color: var(--text); border: 1px solid #3F3F46; border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  font: 400 12px/1.45 var(--font); text-align: left; white-space: normal;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s ease; z-index: 60;
}
.tip.tip-right::after { left: 0; transform: none; }
.tip.tip-left::after { left: auto; right: 0; transform: none; }
.tip:hover::after, .tip:focus::after { opacity: 1; visibility: visible; }
.hint { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .tip::after { max-width: 220px; } }
