/* Portal do assistente de marketing.
   Ideia visual: uma "mesa de criação". O compositor é o protagonista; o resto é calmo.
   --brand vem do .env (BRAND_COLOR) e é aplicado pelo app.js. */

:root {
  --ink: #16203A;          /* texto e barra lateral */
  --ink-soft: #4A5470;
  --ink-faint: #8A93AB;
  --canvas: #EEF1F7;       /* fundo da mesa */
  --paper: #FFFFFF;
  --line: #DCE1EC;
  --brand: #5B4BFF;
  --brand-ink: #FFFFFF;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, white);
  --sun: #FFC857;          /* destaque quente: avisos e marca padrão */
  --ok: #1F9D6B;
  --bad: #C2412D;

  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Figtree', 'Segoe UI', system-ui, sans-serif;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 9px;
  --shadow-desk: 0 1px 0 var(--line), 0 18px 40px -24px rgba(22, 32, 58, .35);
  --nav-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 0; border-radius: 999px; padding: .7rem 1.25rem; cursor: pointer;
  font-weight: 600; background: var(--ink); color: #fff; text-decoration: none;
  transition: transform .12s ease, background .2s ease;
}
.btn:hover { background: #24304f; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn.brand { background: var(--brand); color: var(--brand-ink); }
.btn.brand:hover { background: color-mix(in srgb, var(--brand) 85%, black); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--ink-faint); }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bad) 35%, white); }
.btn.small { padding: .45rem .9rem; font-size: .875rem; }

label.field { display: grid; gap: .35rem; font-weight: 600; font-size: .925rem; }
.field > span:first-child { font-weight: 600; font-size: .925rem; }
.field .hint { margin-left: .4rem; }
label.field .hint { font-weight: 400; color: var(--ink-soft); font-size: .85rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--paper);
  border-radius: var(--r-sm); padding: .65rem .8rem; font-weight: 400;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 4px var(--brand-soft); }
textarea { resize: vertical; min-height: 5rem; }
.form { display: grid; gap: 1rem; }
.form .row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.error-text { color: var(--bad); font-weight: 600; font-size: .925rem; }

/* ---------- tela de entrada */
.auth {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.auth-art {
  background: var(--ink); color: #fff; padding: clamp(2rem, 6vw, 5rem);
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art .logo { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; display: flex; align-items: center; gap: .6rem; }
.auth-art .logo i { width: 14px; height: 14px; border-radius: 4px; background: var(--brand); display: inline-block; }
.auth-art h1 { font-size: clamp(2.4rem, 5.5vw, 4.4rem); max-width: 12ch; color: #fff; }
.auth-art .lead { color: #C5CCE0; max-width: 38ch; margin-top: 1rem; font-size: 1.1rem; }
.auth-demo { margin-top: 2.5rem; display: grid; gap: .75rem; max-width: 420px; }
.auth-demo .bubble { font-size: .95rem; }
.auth-demo .bubble.me { background: var(--brand); color: var(--brand-ink); }
.auth-demo .bubble.ai { color: var(--ink); }
.auth-panel { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: min(420px, 100%); display: grid; gap: 1.5rem; }
.tabs { display: flex; gap: .25rem; background: #fff; padding: .3rem; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; padding: .55rem 1rem; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.tabs button[aria-selected=true] { background: var(--ink); color: #fff; }

/* ---------- casca do app */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100dvh; }
.nav {
  background: var(--ink); color: #C5CCE0; padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 1.75rem;
  position: sticky; top: 0; height: 100dvh;
}
.nav .logo { font-family: var(--font-display); font-weight: 800; color: #fff; font-size: 1.2rem; padding: 0 .6rem; display: flex; gap: .55rem; align-items: center; }
.nav .logo i { width: 12px; height: 12px; border-radius: 3px; background: var(--brand); display: inline-block; }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.nav a {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border-radius: 12px;
  color: #C5CCE0; text-decoration: none; font-weight: 500;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a[aria-current=page] { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a[aria-current=page] svg { color: var(--sun); }
.nav .me { margin-top: auto; padding: .75rem; border-radius: 14px; background: rgba(255, 255, 255, .05); font-size: .9rem; }
.nav .me strong { color: #fff; display: block; }
.nav .me button { margin-top: .5rem; background: none; border: 0; color: #C5CCE0; padding: 0; cursor: pointer; text-decoration: underline; }

main { padding: clamp(1.25rem, 3vw, 2.5rem); max-width: 1100px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; justify-content: space-between; margin-bottom: 1.5rem; }
.page-head p { margin-top: .35rem; }

.banner {
  display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1.1rem; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--sun) 28%, white); margin-bottom: 1.25rem; font-weight: 500;
}
.banner svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }

/* ---------- criar: a mesa */
.desk { display: grid; gap: 1.25rem; }
.feed { display: grid; gap: 1rem; }
.feed-empty {
  border: 2px dashed var(--line); border-radius: var(--r-lg); padding: 1.75rem; display: grid; gap: 1rem;
}
.ideas { display: flex; flex-wrap: wrap; gap: .5rem; }
.ideas button {
  border: 0; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line); border-radius: 999px;
  padding: .45rem .9rem; cursor: pointer; font-size: .9rem; text-align: left;
}
.ideas button:hover { box-shadow: inset 0 0 0 1.5px var(--brand); }

.bubble { max-width: 760px; padding: .9rem 1.1rem; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { margin-left: auto; background: var(--ink); color: #fff; border-bottom-right-radius: 6px; }
.bubble.ai { background: var(--paper); box-shadow: var(--shadow-desk); border-bottom-left-radius: 6px; }
.bubble.ai.err { background: color-mix(in srgb, var(--bad) 8%, white); box-shadow: none; color: var(--bad); }
.bubble .meta { display: flex; gap: .75rem; align-items: center; margin-top: .75rem; white-space: normal; flex-wrap: wrap; }
.bubble .meta .tag { font-size: .8rem; color: var(--ink-faint); }
.bubble.ai.has-img { white-space: normal; width: fit-content; padding: .6rem; }
.bubble.ai.has-img .meta { margin: .6rem .3rem .2rem; }
.bubble img { border-radius: 12px; margin-top: .25rem; width: 520px; max-width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--canvas); }
.typing { display: inline-flex; gap: 5px; padding: .3rem 0; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer {
  position: sticky; bottom: 1rem; background: var(--paper); border-radius: var(--r-lg); padding: 1rem;
  box-shadow: 0 0 0 1.5px var(--line), 0 24px 48px -28px rgba(22, 32, 58, .5); display: grid; gap: .8rem;
}
.composer-top { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.mode { display: inline-flex; background: var(--canvas); padding: .25rem; border-radius: 999px; }
.mode button { border: 0; background: transparent; border-radius: 999px; padding: .45rem 1rem; cursor: pointer; font-weight: 600; color: var(--ink-soft); display: inline-flex; gap: .4rem; align-items: center; }
.mode button svg { width: 18px; height: 18px; }
.mode button[aria-pressed=true] { background: var(--brand); color: var(--brand-ink); }
.brand-pick { display: inline-flex; align-items: center; gap: .5rem; }
.brand-pick select { width: auto; border-radius: 999px; padding: .45rem 2rem .45rem .9rem; }
.swatches { display: inline-flex; }
.swatches i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; margin-left: -5px; display: inline-block; box-shadow: 0 0 0 1px var(--line); }
.swatches i:first-child { margin-left: 0; }
.toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; font-weight: 500; cursor: pointer; padding: .35rem .7rem; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); }
.toggle input { accent-color: var(--brand); }
.toggle:has(input:checked) { box-shadow: inset 0 0 0 1.5px var(--brand); background: var(--brand-soft); }
.toggle:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.composer textarea { border: 0; padding: .25rem .2rem; min-height: 3.2rem; max-height: 14rem; resize: none; font-size: 1.05rem; }
.composer textarea:focus { box-shadow: none; }
.composer-bottom { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.usage-line { font-size: .85rem; color: var(--ink-faint); }

/* ---------- post pronto + publicar */
.post-card {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start;
  background: var(--paper); border-radius: var(--r-lg); padding: 1rem; box-shadow: var(--shadow-desk); max-width: 1000px;
}
.post-media { display: grid; gap: .6rem; }
.post-media img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: var(--canvas); }
.post-media .meta { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.post-media .tag { font-size: .8rem; color: var(--ink-faint); }
.publish { display: grid; gap: .6rem; }
.publish.compact { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.publish textarea { font-size: .97rem; line-height: 1.5; }
.pub-actions-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pub-box { display: grid; gap: .75rem; padding: .9rem; border-radius: var(--r-md); background: var(--canvas); }
.channels { border: 0; margin: 0; padding: 0; display: grid; gap: .45rem; }
.channels legend { margin-bottom: .35rem; }
.channel, .channel.static { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: 12px; background: var(--paper); cursor: pointer; box-shadow: inset 0 0 0 1.5px var(--line); }
.channel.static { cursor: default; }
.channel:has(input:checked) { box-shadow: inset 0 0 0 2px var(--brand); }
.channel input { accent-color: var(--brand); }
.channel img, .ch-dot { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; }
.ch-dot { display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 700; font-family: var(--font-display); }
.channel-list { display: grid; gap: .5rem; }
.when { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.when input[type=datetime-local] { width: auto; }
.pub-ok { font-weight: 600; color: #13633f; }
@media (max-width: 860px) { .post-card { grid-template-columns: 1fr; } }

/* ---------- marcas */
.brand-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.brand-card {
  background: var(--paper); border-radius: var(--r-md); padding: 1.1rem; display: grid; gap: .8rem;
  box-shadow: inset 0 0 0 1.5px var(--line); text-align: left; border: 0; cursor: pointer;
}
.brand-card:hover { box-shadow: inset 0 0 0 1.5px var(--ink-faint); }
.brand-card .top { display: flex; gap: .8rem; align-items: center; }
.logo-box { width: 56px; height: 56px; border-radius: 12px; background: var(--canvas); display: grid; place-items: center; overflow: hidden; flex: none; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; color: var(--ink-faint); }
.logo-box img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--canvas); color: var(--ink-soft); }
.pill.sun { background: color-mix(in srgb, var(--sun) 45%, white); color: #6b4a00; }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, white); color: #13633f; }
.pill.bad { background: color-mix(in srgb, var(--bad) 12%, white); color: #8c2a1b; }
.code-inline { font-family: var(--font-body); font-weight: 600; background: var(--canvas); padding: .05rem .45rem; border-radius: 6px; }

.panel { background: var(--paper); border-radius: var(--r-lg); padding: clamp(1.1rem, 3vw, 1.75rem); box-shadow: var(--shadow-desk); }
.color-list { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.color-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .3rem .25rem .25rem; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); background: #fff; }
.color-chip input[type=color] { width: 28px; height: 28px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; }
.color-chip input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.color-chip input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.color-chip span { font-size: .82rem; font-weight: 600; min-width: 4.6em; }
.color-chip button { border: 0; background: none; cursor: pointer; color: var(--ink-faint); padding: 0 .3rem; font-size: 1.1rem; line-height: 1; }
.logo-drop { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.logo-drop .logo-box { width: 96px; height: 96px; background-image: linear-gradient(45deg, #e9ecf3 25%, transparent 25%), linear-gradient(-45deg, #e9ecf3 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e9ecf3 75%), linear-gradient(-45deg, transparent 75%, #e9ecf3 75%); background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: space-between; }

/* ---------- histórico */
.filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.filters button { border: 0; padding: .4rem .9rem; border-radius: 999px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line); cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.filters button[aria-pressed=true] { background: var(--ink); color: #fff; box-shadow: none; }
.history { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
.h-item { background: var(--paper); border-radius: var(--r-md); overflow: hidden; box-shadow: inset 0 0 0 1.5px var(--line); display: grid; }
.h-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.h-item .body { padding: .9rem 1rem 1rem; display: grid; gap: .5rem; }
.h-item .ask { font-weight: 600; }
.h-item .answer { white-space: pre-wrap; color: var(--ink-soft); font-size: .92rem; max-height: 9.5em; overflow: hidden; position: relative; }
.h-item .answer.open { max-height: none; }
.h-item .foot { display: flex; gap: .5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: .82rem; color: var(--ink-faint); }

/* ---------- telegram e plano */
.split { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.big-code { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.6rem, 8vw, 3.6rem); letter-spacing: .12em; color: var(--ink); }
.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .5rem; }
.meter { display: grid; gap: .35rem; }
.meter .bar { height: 10px; border-radius: 999px; background: var(--canvas); overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.meter .bar i.full { background: var(--bad); }
.plans { display: grid; gap: .75rem; }
.plan-row { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; padding: .9rem 1rem; border-radius: var(--r-md); box-shadow: inset 0 0 0 1.5px var(--line); }
.plan-row.current { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand-soft); }
.plan-row strong { font-family: var(--font-display); font-size: 1.1rem; }
.plan-row .price { font-family: var(--font-display); font-weight: 700; }

/* ---------- admin */
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--shadow-desk); }
table { border-collapse: collapse; width: 100%; min-width: 860px; font-size: .92rem; }
th, td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--ink-soft); background: #F8F9FC; }
td select, td input { padding: .35rem .5rem; font-size: .88rem; }
td select { min-width: 8.5rem; }
td input[type=date] { min-width: 9.5rem; }
.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat { background: var(--paper); border-radius: var(--r-md); padding: .8rem 1.1rem; box-shadow: inset 0 0 0 1.5px var(--line); min-width: 140px; }
.stat b { font-family: var(--font-display); font-size: 1.6rem; display: block; }

/* ---------- toast */
#toast {
  position: fixed; left: 50%; bottom: 1.5rem; background: var(--ink); color: #fff;
  padding: .75rem 1.2rem; border-radius: 999px; font-weight: 600; transition: transform .25s ease, visibility .25s; z-index: 50; max-width: calc(100% - 2rem);
  transform: translate(-50%, calc(100% + 3rem)); visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- celular */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: auto; padding: 2rem 1.25rem 2.5rem; }
  .auth-demo { display: none; }
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 20; padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom));
    flex-direction: row; gap: 0;
  }
  .nav .logo, .nav .me { display: none; }
  .nav ul { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .nav a { flex-direction: column; gap: .15rem; font-size: .72rem; padding: .45rem .2rem; text-align: center; }
  main { padding-bottom: 6.5rem; }
  .composer { position: static; box-shadow: 0 0 0 1.5px var(--line); }
  .composer-bottom .btn { flex: 1; }
  .mobile-top { display: flex !important; }
}
.mobile-top { display: none; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.mobile-top .logo { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; display: flex; gap: .5rem; align-items: center; }
.mobile-top .logo i { width: 12px; height: 12px; border-radius: 3px; background: var(--brand); display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
