/* assets/css/public.css — site público (chat) */
:root {
  --bg: #f9f8f6;
  --sb: #f3f2ef;
  --sb-hover: #e9e7e3;
  --sb-active: #e6e4e0;
  --card: #ffffff;
  --line: #e4e2dd;
  --text: #1d1d1b;
  --muted: #74726d;
  --soft: #8d8b86;
  --user-bubble: #eceae6;
  --accent: #1a8cff;
  --accent-soft: #eaf3ff;
  --err: #d23b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --radius: 26px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1d; --sb: #191917; --sb-hover: #262624; --sb-active: #2c2c29; --card: #2a2a27; --line: #3a3a36;
    --text: #ecebe8; --muted: #a3a19b; --soft: #8a8882; --user-bubble: #34342f; --accent: #4ba3ff; --accent-soft: #1f3247;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body.pub {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.grow { flex: 1; }
.muted { color: var(--muted); }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- barra lateral ---------- */
.sb {
  width: 316px; flex: none; background: var(--sb); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 8px 10px; transition: margin-left .2s ease;
}
.app.collapsed .sb { margin-left: -316px; }
.sb-top { display: flex; align-items: center; padding: 4px 10px 14px; min-height: 40px; }
.brand { font-weight: 650; font-size: 15px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-icons { display: flex; gap: 2px; }
.ic {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; border-radius: 10px; color: var(--text);
}
.ic:hover { background: var(--sb-hover); }
.ic:focus-visible, .new-chat:focus-visible, .conv:focus-visible, .send:focus-visible, .private:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sb-search { padding: 0 6px 10px; }
.sb-search input {
  width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px; padding: 8px 10px; font: inherit; outline: none;
}
.new-chat {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: var(--sb-active); border-radius: 14px;
  padding: 10px 12px; font-size: 16px; text-align: left;
}
.new-chat:hover { background: var(--sb-hover); }
.sb-label { color: var(--soft); font-size: 15px; padding: 26px 11px 8px; }
.conv-list { flex: 1; overflow-y: auto; padding-right: 2px; }
.conv {
  display: flex; align-items: center; gap: 4px; width: 100%; border: 0; background: none; text-align: left; border-radius: 10px;
  padding: 0 4px 0 11px; min-height: 40px; font-size: 16px;
}
.conv:hover, .conv.sel { background: var(--sb-hover); }
.conv .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 9px 0; }
.conv .more { opacity: 0; width: 30px; height: 30px; }
.conv:hover .more, .conv.sel .more, .conv .more:focus-visible { opacity: 1; }
.conv-empty { color: var(--soft); font-size: 14px; padding: 4px 11px; }
.conv-menu {
  position: fixed; z-index: 40; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 4px; min-width: 160px;
}
.conv-menu button, .user-menu button, .user-menu a {
  display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 8px; text-align: left;
  color: var(--text); text-decoration: none; font-size: 14.5px;
}
.conv-menu button:hover, .user-menu button:hover, .user-menu a:hover { background: var(--sb-hover); }
.conv-menu .danger, .user-menu .danger { color: var(--err); }

.sb-bottom { border-top: 1px solid transparent; padding-top: 8px; position: relative; }
.auth-btns { display: flex; gap: 8px; padding: 4px; }
.auth-btns button { flex: 1; border-radius: 12px; padding: 9px 10px; border: 1px solid var(--line); background: var(--card); font-size: 14.5px; }
.auth-btns .primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.me {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; border-radius: 12px; padding: 8px 10px; text-align: left;
}
.me:hover { background: var(--sb-hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #5b6cff; color: #fff; font-weight: 650; font-size: 14px; flex: none;
}
.me .who { flex: 1; min-width: 0; line-height: 1.25; }
.me .who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who small { color: var(--soft); }
.user-menu {
  position: absolute; bottom: 58px; left: 4px; right: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 4px; z-index: 30;
}
.user-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- área principal ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar { display: flex; align-items: center; gap: 6px; padding: 18px 28px 6px; min-height: 64px; }
.private {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 12px; border-radius: 12px; font-size: 16px; color: var(--muted); font-weight: 500;
}
.private:hover { background: var(--sb-hover); }
.private[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.only-mobile, .show-collapsed { display: none; }
.app.collapsed .show-collapsed { display: inline-grid; }

.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 20px 20px 40px; transition: opacity .25s ease; }
.hero.typing { opacity: 0; pointer-events: none; }
.hero-in { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.hero-icon { width: 64px; height: 64px; object-fit: contain; }
.hero h1 { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -.015em; line-height: 1.2; }
.main.chatting .hero { display: none; }

.thread { display: none; flex: 1; overflow-y: auto; padding: 8px 20px 24px; scroll-behavior: smooth; }
.main.chatting .thread { display: block; }
.msg { max-width: 760px; margin: 0 auto 22px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--user-bubble); border-radius: 20px; padding: 10px 16px; max-width: 80%; white-space: pre-wrap; word-wrap: break-word; }
.msg.ai .bubble { padding: 4px 2px; max-width: 100%; word-wrap: break-word; }
.msg.ai .bubble p { margin: 0 0 .7em; }
.msg.ai .bubble p:last-child { margin-bottom: 0; }
.msg.ai .bubble code { background: var(--user-bubble); border-radius: 6px; padding: 1px 5px; font-size: .92em; }
.msg.ai .acts { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg.ai:hover .acts, .msg.ai:focus-within .acts { opacity: 1; }
.msg.ai .acts .ic { width: 30px; height: 30px; color: var(--muted); }
.msg.ai .acts svg { width: 17px; height: 17px; }
.msg.err .bubble { color: var(--err); }
.typing span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--soft); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }
.private-banner { max-width: 760px; margin: 0 auto 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- caixa de mensagem ---------- */
.composer {
  width: min(940px, calc(100% - 40px)); margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 12px 10px 22px; display: flex; flex-direction: column; gap: 6px; flex: none;
  margin-bottom: max(22px, env(safe-area-inset-bottom));
}
.main.chatting .composer { margin-bottom: 4px; width: min(800px, calc(100% - 40px)); }
.composer textarea {
  border: 0; outline: none; resize: none; background: none; color: var(--text); font: inherit; font-size: 17px; line-height: 1.5;
  max-height: 220px; min-height: 28px; padding: 0 8px 0 0;
}
.composer textarea::placeholder { color: var(--soft); }
.composer-row { display: flex; align-items: center; gap: 6px; margin-left: -12px; }
.composer-row .ic { color: var(--text); }
.composer-row .ic:hover { background: var(--sb); }
.model-chip { font-weight: 600; font-size: 15px; padding: 6px 10px; border-radius: 10px; color: var(--text); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-mic.rec { color: var(--err); background: #fdecec; }
.send {
  width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.send svg { width: 24px; height: 24px; stroke-width: 2.2; }
.send .i-arrow, .send .i-stop { display: none; }
.send.has-text { background: var(--text); color: var(--bg); }
.send.has-text .i-wave { display: none; }
.send.has-text .i-arrow { display: block; }
.send.busy { background: var(--text); color: var(--bg); }
.send.busy .i-wave, .send.busy .i-arrow { display: none; }
.send.busy .i-stop { display: block; }
.send.voice { background: var(--accent); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(26, 140, 255, .35); } 50% { box-shadow: 0 0 0 10px rgba(26, 140, 255, 0); } }
.foot-note { display: none; text-align: center; color: var(--soft); font-size: 12.5px; margin: 6px 0 max(12px, env(safe-area-inset-bottom)); }
.main.chatting .foot-note { display: block; }
.conv-empty a { color: var(--accent); }

.guest-hint { margin: 10px 6px 0; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.45; }
.guest-hint a { color: var(--accent); font-weight: 500; }

/* ---------- janelas (entrar, criar conta, perfil) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 20, 18, 0); display: grid; place-items: center; padding: 20px;
  transition: background .2s ease; overflow-y: auto;
}
.modal.in { background: rgba(20, 20, 18, .42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: min(420px, 100%); background: var(--card); color: var(--text); border-radius: 24px; padding: 30px 28px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .06); border: 1px solid var(--line);
  opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .2s ease, transform .2s ease; margin: auto;
}
.modal.in .modal-card { opacity: 1; transform: none; }
.modal-card h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.modal-x { position: absolute; top: 14px; right: 14px; color: var(--muted); }

.auth-head { text-align: center; margin-bottom: 20px; }
.auth-logo { width: 56px; height: 56px; object-fit: contain; display: block; margin: 0 auto 12px; }
.auth-sub { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }
.tabs { display: flex; background: var(--sb); border-radius: 14px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; border: 0; background: none; padding: 9px; border-radius: 11px; font-weight: 550; color: var(--muted); transition: background .15s, color .15s; }
.tab.sel { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.note { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: 14px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13.5px; font-weight: 550; color: var(--text); }
.field em { font-style: normal; font-weight: 400; color: var(--soft); }
.field .hint { color: var(--soft); font-size: 12.5px; }
.field input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 13px; padding: 12px 14px;
  font: inherit; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 4px var(--accent-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pw { position: relative; }
.pw input { padding-right: 46px; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; border-radius: 10px;
  display: grid; place-items: center; color: var(--soft);
}
.eye:hover { background: var(--sb); color: var(--text); }
.eye.on { color: var(--accent); }
.btn-primary, .btn-secondary {
  position: relative; border: 0; border-radius: 13px; padding: 13px; font-weight: 600; font-size: 15.5px; transition: transform .05s, opacity .15s;
}
.btn-primary { background: var(--text); color: var(--bg); margin-top: 4px; }
.btn-secondary { background: var(--sb); color: var(--text); border: 1px solid var(--line); padding: 11px; }
.btn-primary:active, .btn-secondary:active { transform: scale(.99); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .7; cursor: wait; }
.loading { color: transparent !important; }
.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--soft); border-top-color: var(--text); animation: spin .7s linear infinite;
}
.btn-primary.loading::after { border-color: rgba(127, 127, 127, .5); border-top-color: var(--bg); }
@keyframes spin { to { transform: rotate(360deg); } }
.switch { text-align: center; margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.switch a { color: var(--accent); font-weight: 550; text-decoration: none; }
.switch a:hover { text-decoration: underline; }
.err { color: var(--err); font-size: 14px; margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: rgba(210, 59, 59, .08); }

/* perfil */
.profile-card { width: min(460px, 100%); }
.pf-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; padding-right: 30px; }
.avatar.big { width: 64px; height: 64px; font-size: 24px; background: linear-gradient(135deg, #5b6cff, #1a8cff 55%, #19c2b5); }
.pf-id { min-width: 0; }
.pf-id h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-id p { margin: 3px 0 0; color: var(--muted); font-size: 14.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.pf-stats div { background: var(--sb); border-radius: 14px; padding: 12px 8px; text-align: center; min-width: 0; }
.pf-stats b { display: block; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-stats span { font-size: 12px; color: var(--muted); }
.pf-admin { display: grid; gap: 8px; margin-bottom: 16px; }
.pf-admin a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); text-decoration: none; color: var(--text);
  transition: background .15s, border-color .15s;
}
.pf-admin a:hover { background: var(--sb); border-color: var(--accent); }
.pf-admin svg { color: var(--accent); }
.pf-admin span { display: flex; flex-direction: column; line-height: 1.3; }
.pf-admin small { color: var(--muted); font-size: 12.5px; }
.pf-sec { border-top: 1px solid var(--line); padding: 4px 0; }
.pf-sec summary {
  cursor: pointer; list-style: none; padding: 12px 2px; font-weight: 600; display: flex; justify-content: space-between; align-items: center;
}
.pf-sec summary::-webkit-details-marker { display: none; }
.pf-sec summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--soft); border-bottom: 2px solid var(--soft); transform: rotate(45deg); transition: transform .2s; margin-right: 4px; }
.pf-sec[open] summary::after { transform: rotate(-135deg); }
.pf-sec form { padding: 2px 0 14px; }
.btn-logout {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 8px; border: 1px solid var(--line); background: none;
  color: var(--err); border-radius: 13px; padding: 11px; font-weight: 600;
}
.btn-logout:hover { background: rgba(210, 59, 59, .07); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  z-index: 60; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.sb-backdrop { display: none; }

/* ---------- celular ---------- */
@media (max-width: 820px) {
  .sb { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 300px; margin-left: -300px; box-shadow: var(--shadow); }
  .app.open .sb { margin-left: 0; }
  .app.open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .3); }
  .app.collapsed .sb { margin-left: -300px; }
  .only-mobile { display: inline-grid; }
  .show-collapsed, .app.collapsed .show-collapsed { display: none; }
  #btn-collapse { display: none; }
  .topbar { padding: 10px 10px 4px; min-height: 52px; }
  .hero { padding: 16px 16px 30px; }
  .hero-in { gap: 10px; }
  .hero-icon { width: 46px; height: 46px; }
  .hero h1 { font-size: 25px; }
  .composer, .main.chatting .composer { width: calc(100% - 16px); padding: 12px 8px 8px 16px; border-radius: 22px; }
  .composer { margin-bottom: max(8px, env(safe-area-inset-bottom)); }
  .thread { padding: 8px 14px 18px; }
  .msg.user .bubble { max-width: 88%; }
  .private span { display: none; }
  .modal { padding: 0; place-items: end stretch; }
  .modal-card, .profile-card {
    width: 100%; max-height: 94dvh; overflow-y: auto; border-radius: 26px 26px 0 0; padding: 26px 20px max(22px, env(safe-area-inset-bottom));
    transform: translateY(40px); border-bottom: 0;
  }
  .modal-card::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: -12px auto 16px; }
  .row2 { grid-template-columns: 1fr; }
  .pf-stats b { font-size: 16px; }
  .auth-logo { width: 46px; height: 46px; }
}
