/* ============================================================
   JOVEM PAN — CENTRAL DE AUDIÊNCIA · Chat IA
   Direção: "Sala de Controle Editorial" — obsidiana, pulso
   vermelho como heartbeat, Barlow Condensed como voz.
   ============================================================ */

:root {
  --jp-red: #DD0510;
  --jp-red-dark: #B80410;
  --jp-red-hot: #FF1A2A;
  --bg-0: #060709;
  --bg-1: #0B0D10;
  --bg-2: #12151A;
  --bg-3: #191D24;
  --bg-4: #222732;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text-1: #F2F4F6;
  --text-2: #A8B3BD;
  --text-3: #7C8A96;
  --steel: #6C889D;
  --steel-dark: #376173;
  --positive: #4CAF50;
  --warning: #FFA726;
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow-red: 0 8px 32px rgba(221, 5, 16, 0.22);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-1);
  background: var(--bg-1);
  overflow: hidden;
}

::selection { background: var(--jp-red); color: #fff; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* Foco por teclado — feedback consistente em toda superfície interativa (a11y) */
:focus-visible { outline: 2px solid var(--jp-red-hot); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, .chip:focus-visible, .sb-link:focus-visible,
.icon-btn:focus-visible, a:focus-visible { outline: 2px solid var(--jp-red-hot); outline-offset: 2px; }
.auth-form input:focus-visible, #composer input:focus-visible { outline: none; }
/* botões de gradiente vermelho → anel branco (vermelho-sobre-vermelho some) */
.btn-primary:focus-visible, .btn-red:focus-visible,
#composer button[type="submit"]:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Grão sutil sobre tudo — atmosfera de estúdio */
#noise {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2A303B; border-radius: 6px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--steel-dark); }

.view { position: fixed; inset: 0; }

/* ============================================================
   Ponto vermelho "no ar"
   ============================================================ */
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--jp-red-hot); position: relative; flex: none;
}
.live-dot::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  border: 1px solid var(--jp-red-hot); opacity: 0;
  animation: livePing 2.2s ease-out infinite;
}
@keyframes livePing {
  0% { transform: scale(0.4); opacity: 0.9; }
  70%, 100% { transform: scale(1.5); opacity: 0; }
}

/* ============================================================
   AUTENTICAÇÃO (login / troca de senha)
   ============================================================ */
.view-auth {
  display: grid; place-items: center; overflow-y: auto;
  background:
    radial-gradient(1100px 640px at 50% -12%, rgba(221, 5, 16, 0.16), transparent 62%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 55%);
}
.view-auth::before {
  /* malha técnica de fundo, esvanecida */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(720px 520px at 50% 32%, rgba(0,0,0,0.8), transparent 75%);
  -webkit-mask-image: radial-gradient(720px 520px at 50% 32%, rgba(0,0,0,0.8), transparent 75%);
}

.auth-stage {
  position: relative; width: min(430px, calc(100vw - 48px));
  padding: 48px 0 40px; text-align: center;
}
.auth-glow {
  position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  width: 480px; height: 300px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(221, 5, 16, 0.28), transparent 72%);
  filter: blur(6px);
}
.auth-brand img { height: 92px; width: auto; margin: 0 auto 34px; filter: drop-shadow(0 6px 40px rgba(221, 5, 16, 0.45)); }

.auth-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 54px);
  line-height: 1.02; letter-spacing: 7px; text-transform: uppercase;
  margin-bottom: 14px;
}
.auth-title .thin { font-weight: 200; color: var(--text-2); }
.auth-title .bold { font-weight: 700; color: #fff; }

.auth-sub {
  font-weight: 300; font-size: 15px; color: var(--text-2);
  max-width: 340px; margin: 0 auto 22px;
}

.live-chip {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
  letter-spacing: 3.5px; text-transform: uppercase; color: var(--text-2);
  border: 1px solid var(--line-strong); border-radius: 100px;
  padding: 7px 16px 7px 13px; margin-bottom: 34px;
  background: rgba(255, 255, 255, 0.02);
}

.auth-form { display: grid; gap: 14px; text-align: left; }
.auth-form label {
  display: grid; gap: 6px;
  font-family: var(--font-display); font-weight: 600; font-size: 11px;
  letter-spacing: 2px; text-transform: uppercase; color: var(--text-3);
}
.auth-form input {
  width: 100%; padding: 14px 16px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.015); border: 1px solid var(--line-strong);
  color: var(--text-1); font-size: 15px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.auth-form input:focus {
  border-color: var(--jp-red);
  box-shadow: 0 0 0 3px rgba(221, 5, 16, 0.18);
  background: var(--bg-3);
}

.form-error {
  font-size: 13.5px; color: #FF8189; background: rgba(221, 5, 16, 0.1);
  border: 1px solid rgba(221, 5, 16, 0.35); border-radius: var(--r-sm);
  padding: 10px 14px;
}

/* Checkbox dentro de auth-form: sobrepõe o grid/uppercase de .auth-form label. */
.auth-form label.check-inline {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-body); font-weight: 400; font-size: 13.5px;
  letter-spacing: 0; text-transform: none; color: var(--text-2);
  cursor: pointer;
}
.auth-form label.check-inline input[type="checkbox"] {
  width: auto; padding: 0; margin: 0; accent-color: var(--jp-red); cursor: pointer;
}

.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; }
.btn-link {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--text-3); font-size: 13px; text-decoration: underline;
  text-underline-offset: 3px; transition: color 0.15s;
}
.btn-link:hover:not(:disabled) { color: var(--text-1); }
.btn-link:disabled { opacity: 0.45; cursor: default; text-decoration: none; }

.btn-primary {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  letter-spacing: 3px; text-transform: uppercase; color: #fff;
  background: linear-gradient(135deg, var(--jp-red-hot), var(--jp-red-dark));
  border-radius: var(--r-sm); padding: 14px 24px; margin-top: 6px;
  box-shadow: var(--shadow-red);
  transition: transform 0.15s var(--ease), box-shadow 0.2s, filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 10px 40px rgba(221, 5, 16, 0.35); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { filter: grayscale(0.5) brightness(0.6); cursor: wait; box-shadow: none; }

.auth-foot {
  margin-top: 44px;
  font-family: var(--font-display); font-weight: 400; font-size: 11px;
  letter-spacing: 4px; color: var(--text-3); text-transform: uppercase;
}

/* Revelação escalonada */
.reveal { opacity: 0; animation: fadeUp 0.7s var(--ease) forwards; }
.reveal.d1 { animation-delay: 0.12s; }
.reveal.d2 { animation-delay: 0.24s; }
.reveal.d3 { animation-delay: 0.36s; }
.reveal.d4 { animation-delay: 0.52s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   SHELL — sidebar + main
   ============================================================ */
#view-shell { display: flex; background: var(--bg-1); }

#sidebar {
  width: 284px; flex: none; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--bg-0), #0A0C0F);
  border-right: 1px solid var(--line);
  padding: 22px 18px 18px;
  z-index: 40;
}

.sb-brand { display: flex; align-items: center; gap: 13px; padding: 2px 6px 22px; }
.sb-brand img { height: 34px; width: auto; }
.sb-brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  letter-spacing: 2.5px; line-height: 1.05; text-transform: uppercase;
}
.sb-brand-name span {
  display: block; font-weight: 300; font-size: 11.5px; letter-spacing: 3.5px;
  color: var(--jp-red-hot); margin-top: 3px;
}

.btn-outline {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  letter-spacing: 2.5px; text-transform: uppercase; color: var(--text-1);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.btn-outline:hover { border-color: var(--jp-red); background: rgba(221, 5, 16, 0.09); }

.sb-chats-wrap { margin-top: 24px; flex: 1; min-height: 0; overflow-y: auto; }
.sb-chats-wrap h4 {
  font-family: var(--font-display); font-weight: 600; font-size: 11px;
  letter-spacing: 3px; text-transform: uppercase; color: var(--text-3);
  padding: 0 6px 10px;
}
.sb-chats-empty { padding: 4px 6px; font-size: 13px; color: var(--text-3); }

.chat-item {
  position: relative; display: flex; align-items: center; gap: 4px;
  border-radius: var(--r-sm); margin-bottom: 2px;
  transition: background 0.16s;
}
.chat-item:hover { background: var(--bg-2); }
.chat-item.active { background: rgba(221, 5, 16, 0.11); }
.chat-item.active .chat-open { color: var(--text-1); }

.chat-open {
  flex: 1; min-width: 0; text-align: left;
  padding: 9px 4px 9px 10px; font-size: 13.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-more {
  flex: none; width: 26px; height: 26px; margin-right: 5px; border-radius: 7px;
  display: grid; place-items: center; color: var(--text-3);
  opacity: 0; transition: opacity 0.16s, background 0.16s, color 0.16s;
}
.chat-item:hover .chat-more,
.chat-more:focus-visible { opacity: 1; }
.chat-more:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-1); }
.chat-more svg { width: 14px; height: 14px; }

.chat-rename {
  flex: 1; min-width: 0; margin: 4px 4px 4px 8px; padding: 5px 8px;
  border-radius: 7px; border: 1px solid var(--jp-red);
  background: var(--bg-0); color: var(--text-1); font-size: 13.5px;
}

.chat-menu {
  position: absolute; top: 100%; right: 6px; z-index: 60; min-width: 150px;
  display: grid; padding: 5px; border-radius: 10px;
  background: var(--bg-1); border: 1px solid var(--line-strong);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.75);
}
.chat-menu-item {
  text-align: left; padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--text-2);
}
.chat-menu-item:hover { background: var(--bg-2); color: var(--text-1); }
.chat-menu-item.danger:hover { color: #FF8189; background: rgba(221, 5, 16, 0.1); }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02);
  font-size: 13.5px; font-weight: 400; color: var(--text-2);
  transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.15s var(--ease);
}
.chip:hover {
  border-color: rgba(221, 5, 16, 0.55); color: var(--text-1);
  background: rgba(221, 5, 16, 0.08); transform: translateX(2px);
}

.sb-bottom { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 6px; }

.sb-user { display: flex; align-items: center; gap: 11px; padding: 6px 6px 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--steel-dark), #24404d);
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 1px;
}
.sb-user-info { min-width: 0; }
.sb-user-info strong {
  display: block; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.role-badge {
  display: inline-block; margin-top: 3px;
  font-family: var(--font-display); font-weight: 600; font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 2px 9px; border-radius: 100px;
  color: var(--text-2); border: 1px solid var(--line-strong);
}
.role-badge.role-superadmin { color: #fff; background: var(--jp-red); border-color: var(--jp-red); }
.role-badge.role-admin { color: #061019; background: var(--steel); border-color: var(--steel); }

.sb-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: var(--r-sm); text-decoration: none;
  font-size: 13.5px; color: var(--text-2);
  transition: background 0.18s, color 0.18s;
}
.sb-link:hover { background: var(--bg-2); color: var(--text-1); }
.sb-link svg { width: 16px; height: 16px; flex: none; opacity: 0.75; }
.sb-link.danger:hover { color: #FF8189; background: rgba(221, 5, 16, 0.08); }

/* ============================================================
   MAIN — topbar com heartbeat
   ============================================================ */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

#topbar {
  position: relative; flex: none;
  display: flex; align-items: center; gap: 14px;
  height: 62px; padding: 0 22px;
  background: rgba(11, 13, 16, 0.86); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

#btn-menu { display: none; padding: 8px; margin-left: -8px; border-radius: 8px; }
#btn-menu:hover { background: var(--bg-2); }
#btn-menu svg { width: 22px; height: 22px; display: block; }

.tb-title {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  letter-spacing: 3.5px; text-transform: uppercase;
  display: flex; align-items: center; gap: 14px; min-width: 0;
  margin-right: auto;
}
.tb-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 400; font-size: 11.5px; letter-spacing: 2.5px; color: var(--text-3);
}

/* Perguntas rápidas — menu à direita da barra superior */
.qa-wrap { position: relative; flex: none; }

.btn-qa {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-radius: 10px;
  border: 1px solid var(--line-strong);
  font-size: 13px; color: var(--text-2);
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.btn-qa:hover { border-color: rgba(221, 5, 16, 0.55); color: var(--text-1); background: rgba(221, 5, 16, 0.08); }
.btn-qa[aria-expanded="true"] { border-color: var(--jp-red); color: var(--text-1); }
.btn-qa .qa-caret { transition: transform 0.18s; }
.btn-qa[aria-expanded="true"] .qa-caret { transform: rotate(180deg); }

.qa-menu {
  position: absolute; top: calc(100% + 9px); right: 0; z-index: 60;
  min-width: 268px; max-width: 84vw; display: grid; gap: 2px; padding: 6px;
  border-radius: 12px; background: var(--bg-1); border: 1px solid var(--line-strong);
  box-shadow: 0 22px 48px -16px rgba(0, 0, 0, 0.8);
}
.qa-item {
  text-align: left; padding: 10px 12px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-2);
  transition: background 0.16s, color 0.16s;
}
.qa-item:hover, .qa-item:focus-visible { background: rgba(221, 5, 16, 0.1); color: var(--text-1); }

@media (max-width: 760px) {
  .qa-label { display: none; }
  .btn-qa { padding: 8px 10px; }
}

/* A assinatura: linha de pulso sob o topbar */
.heartbeat {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(221, 5, 16, 0.4), transparent);
  opacity: 0.35;
  transition: opacity 0.4s;
}
.heartbeat.active {
  opacity: 1;
  background:
    linear-gradient(90deg, transparent 0%, transparent 34%, rgba(255, 26, 42, 0.15) 42%, var(--jp-red-hot) 50%, rgba(255, 26, 42, 0.15) 58%, transparent 66%, transparent 100%),
    linear-gradient(90deg, transparent, rgba(221, 5, 16, 0.25), transparent);
  background-size: 320px 2px, 100% 2px;
  background-repeat: repeat-x;
  animation: hbScan 1.15s linear infinite;
  box-shadow: 0 0 14px rgba(255, 26, 42, 0.55);
}
@keyframes hbScan {
  from { background-position: -320px 0, 0 0; }
  to { background-position: calc(100% + 320px) 0, 0 0; }
}

.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ============================================================
   CHAT
   ============================================================ */
#messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 30px 22px 12px;
  scroll-behavior: smooth;
}
.msg-col { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; }

.msg-row { display: flex; margin-bottom: 12px; animation: msgIn 0.32s var(--ease); }
.msg-row.from-user { justify-content: flex-end; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.bubble {
  max-width: min(78%, 620px);
  padding: 12px 16px; border-radius: var(--r-md);
  font-size: 15px; overflow-wrap: break-word;
}
.bubble strong { font-weight: 600; }
.bubble a { color: #7FB3D5; text-decoration: underline; text-underline-offset: 2px; }
.bubble pre, .bubble code {
  font-family: 'Consolas', 'Menlo', monospace; font-size: 13px;
  background: rgba(0, 0, 0, 0.35); border-radius: 6px;
}
.bubble pre { padding: 10px 12px; margin: 6px 0; overflow-x: auto; }
.bubble code { padding: 1px 6px; }

.from-bot .bubble {
  background: linear-gradient(180deg, #1B2028, var(--bg-3));
  border: 1px solid var(--line-strong);
  border-bottom-left-radius: 5px;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  white-space: pre-line;
  line-height: 1.5;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 6px 20px rgba(0, 0, 0, 0.28);
  animation-delay: 0.04s;
}
.from-user .bubble {
  background: linear-gradient(135deg, var(--jp-red) 0%, var(--jp-red-dark) 100%);
  border-bottom-right-radius: 5px;
  color: #fff;
  box-shadow: 0 4px 18px rgba(221, 5, 16, 0.28);
}

.msg-time {
  display: block; margin-top: 6px;
  font-family: var(--font-display); font-size: 10.5px; font-weight: 400;
  letter-spacing: 1.5px; opacity: 0.45;
}
.from-user .bubble .msg-time { opacity: 0.8; color: rgba(255, 255, 255, 0.85); }

/* Cartão de gráfico — papel claro sobre a obsidiana */
.bubble.card-image {
  background: #fff; border: none; padding: 10px;
  max-width: min(88%, 680px);
}
.bubble.card-image img { border-radius: 8px; cursor: zoom-in; width: 100%; }
.bubble.card-image .caption { color: #333; font-size: 13px; padding: 8px 6px 2px; }
.bubble.card-image .msg-time { color: #5a5a5a; padding: 0 6px; }

/* Chips de resposta rápida (botões do bot) — ação, não navegação: lift no hover */
.btn-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 16px; padding-left: 2px; max-width: min(88%, 680px); }
.btn-strip .chip {
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 9px 16px;
  background: rgba(221, 5, 16, 0.06);
  border-color: rgba(221, 5, 16, 0.28); color: var(--text-1);
  border-radius: 100px;
  transition: background 0.16s var(--ease), border-color 0.16s, transform 0.12s var(--ease), box-shadow 0.16s;
}
.btn-strip .chip:hover {
  background: var(--jp-red); border-color: var(--jp-red); color: #fff;
  transform: translateY(-1px); box-shadow: 0 4px 14px rgba(221, 5, 16, 0.25);
}
.btn-strip.used .chip { opacity: 0.35; pointer-events: none; }

/* Lista (dropdown) do bot */
.list-options { display: grid; gap: 6px; margin: 2px 0 14px; max-width: min(88%, 560px); }
.list-options .chip { border-radius: 10px; width: 100%; text-align: left; display: flex; justify-content: space-between; }
.list-options .chip small { color: var(--text-3); font-size: 12px; }

/* Indicador de digitação — VU meter */
.typing { display: inline-flex; align-items: flex-end; gap: 4px; height: 22px; padding: 14px 18px; }
.typing i {
  width: 4px; border-radius: 2px; background: var(--jp-red-hot);
  animation: vu 0.85s ease-in-out infinite alternate;
}
.typing i:nth-child(1) { height: 8px; animation-delay: 0s; }
.typing i:nth-child(2) { height: 16px; animation-delay: 0.12s; }
.typing i:nth-child(3) { height: 11px; animation-delay: 0.24s; }
.typing i:nth-child(4) { height: 18px; animation-delay: 0.36s; }
.typing i:nth-child(5) { height: 7px; animation-delay: 0.48s; }
@keyframes vu { from { transform: scaleY(0.35); opacity: 0.6; } to { transform: scaleY(1); opacity: 1; } }

/* Estado vazio */
#empty-state {
  position: absolute; inset: 62px 0 96px; display: grid; place-items: center;
  pointer-events: none; padding: 24px;
}
#empty-state .inner { text-align: center; max-width: 640px; pointer-events: auto; }
/* Bolha de boas-vindas: hierarquia de conversa, não de cartaz — ela ocupa o lugar
 * do hero antigo. A pele vem de `.from-bot .bubble` (a marca `from-bot` está no HTML). */
.greet-row {
  display: flex; gap: 12px; align-items: flex-start;
  text-align: left; margin-bottom: 26px;
}
.greet-mark {
  width: 34px; height: 34px; flex: 0 0 auto; opacity: 0.95;
  filter: drop-shadow(0 4px 30px rgba(221, 5, 16, 0.5));
}
/* Sem o teto de 78% de `.bubble`: aqui a largura já é limitada pelo `.inner`. */
.greet-bubble { max-width: none; min-width: 0; }
/* Enquanto o texto não chega (Function fria demora), some — uma caixa vazia com
 * borda e sombra por alguns segundos parece defeito. */
.greet-bubble:empty { display: none; }
#empty-state .chips { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
#empty-state .chips .chip::before { content: '›'; color: var(--jp-red-hot); font-weight: 700; margin-right: 2px; }

/* Compositor */
#composer-wrap { flex: none; padding: 10px 22px 20px; }
#composer {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: 8px 8px 8px 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#composer:focus-within { border-color: rgba(221, 5, 16, 0.6); box-shadow: 0 0 0 4px rgba(221, 5, 16, 0.12); }
#composer input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--text-1); font-size: 15px; padding: 8px 0;
}
#composer input::placeholder { color: var(--text-3); }
#composer button[type="submit"] {
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--jp-red-hot), var(--jp-red-dark));
  box-shadow: 0 4px 16px rgba(221, 5, 16, 0.35);
  transition: transform 0.15s var(--ease), filter 0.2s;
}
#composer button[type="submit"]:hover { filter: brightness(1.12); }
#composer button[type="submit"]:active { transform: scale(0.92); }
#composer button[type="submit"]:disabled { filter: grayscale(0.6) brightness(0.55); cursor: not-allowed; }
#composer button svg { width: 19px; height: 19px; }
.composer-hint {
  max-width: 860px; margin: 8px auto 0; text-align: center;
  font-size: 11.5px; color: var(--text-3); letter-spacing: 0.3px;
}

/* ============================================================
   ADMIN — usuários
   ============================================================ */
#panel-admin { overflow-y: auto; padding: 30px 22px 40px; }
.admin-col { max-width: 1020px; margin: 0 auto; }

.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-head h2 {
  font-family: var(--font-display); font-weight: 200; font-size: 38px;
  letter-spacing: 3px; text-transform: uppercase; line-height: 1;
}
.admin-head h2 strong { font-weight: 700; }
.admin-head .sub { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.admin-head-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.admin-head-actions .check-inline {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  color: var(--text-2); font-size: 13px;
}
.admin-head-actions .check-inline input { accent-color: var(--jp-red); cursor: pointer; }
.admin-head-actions .check-inline.locked { opacity: 0.5; cursor: default; }
#admin-mfa-hint { color: var(--text-3); font-size: 12.5px; margin: -14px 0 20px; }
.u-mfa {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 99px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  background: rgba(27, 148, 173, 0.16); color: #6FD3E8; border: 1px solid rgba(27, 148, 173, 0.35);
}

.btn-red {
  font-family: var(--font-display); font-weight: 700; font-size: 13.5px;
  letter-spacing: 2.5px; text-transform: uppercase; color: #fff;
  background: linear-gradient(135deg, var(--jp-red-hot), var(--jp-red-dark));
  border-radius: var(--r-sm); padding: 11px 20px;
  box-shadow: var(--shadow-red);
  transition: filter 0.2s, transform 0.15s var(--ease);
}
.btn-red:hover { filter: brightness(1.1); }
.btn-red:active { transform: scale(0.97); }

.table-wrap {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-md); overflow-x: auto;
}
table.users { width: 100%; border-collapse: collapse; min-width: 760px; }
table.users thead { background: rgba(255, 255, 255, 0.02); }
table.users th {
  font-family: var(--font-display); font-weight: 600; font-size: 11px;
  letter-spacing: 2.5px; text-transform: uppercase; color: var(--text-3);
  text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap; position: sticky; top: 0; background: var(--bg-2); z-index: 1;
}
table.users td { padding: 13px 18px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.users tr:last-child td { border-bottom: none; }
table.users tbody tr { transition: background 0.15s; }
table.users tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.012); }
table.users tbody tr:hover { background: rgba(221, 5, 16, 0.045); }
table.users .u-nome { font-weight: 600; }
table.users .u-email { color: var(--text-2); font-size: 13.5px; }
table.users td.num { font-variant-numeric: tabular-nums; color: var(--text-2); }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-2);
}
.status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--positive); }
.status-pill.off { color: var(--text-3); }
.status-pill.off::before { background: var(--text-3); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-2); transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-4); color: var(--text-1); }
.icon-btn.danger:hover { background: rgba(221, 5, 16, 0.14); color: #FF8189; }
.icon-btn svg { width: 16px; height: 16px; }

.admin-empty { padding: 44px; text-align: center; color: var(--text-3); }

/* ============================================================
   DASHBOARDS — PowerEmbedded
   ============================================================ */
/* #panel-pbi herda a coluna flexível de `.panel`: barra fixa em cima, palco elástico. */
.pbi-bar {
  flex: none; display: flex; align-items: center; gap: 14px;
  padding: 10px 22px; border-bottom: 1px solid var(--line);
}
.pbi-tabs { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.pbi-tab {
  white-space: nowrap; padding: 7px 15px; border-radius: 100px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.02);
  font-size: 13px; color: var(--text-2);
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.pbi-tab:hover { border-color: rgba(221, 5, 16, 0.55); color: var(--text-1); background: rgba(221, 5, 16, 0.08); }
.pbi-tab.active {
  color: #fff; border-color: var(--jp-red);
  background: linear-gradient(135deg, var(--jp-red-hot), var(--jp-red-dark));
  box-shadow: 0 4px 14px rgba(221, 5, 16, 0.28);
}

.pbi-actions { flex: none; display: flex; align-items: center; gap: 8px; }
/* A saída para nova aba fica sempre aqui — ver o comentário do CSP no chat.js. */
.pbi-actions .btn-ghost, .pbi-msg .btn-ghost {
  border: 1px solid var(--line-strong); text-decoration: none; padding: 9px 15px;
}

.pbi-stage { position: relative; flex: 1; min-height: 0; background: var(--bg-0); }
#pbi-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.pbi-msg {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  text-align: center; padding: 32px; color: var(--text-2);
}
.pbi-msg p { max-width: 470px; font-size: 15px; }
.pbi-msg-acoes { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
/* Cadastro pendente no fornecedor não é defeito: cartão sóbrio, sem o vermelho de erro. */
.pbi-msg.recado p {
  color: var(--text-1); background: var(--bg-2);
  border: 1px solid var(--line-strong); border-left: 3px solid var(--steel);
  border-radius: var(--r-md); padding: 18px 22px; text-align: left;
}

.pbi-config-list { display: grid; gap: 2px; max-height: 46vh; overflow-y: auto; margin-top: 16px; }
.pbi-config-list .check-inline {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 14px;
}
.pbi-config-list .check-inline:hover { background: var(--bg-3); color: var(--text-1); }
.pbi-config-list input[type="checkbox"] {
  width: 16px; height: 16px; flex: none; accent-color: var(--jp-red); cursor: pointer;
}

/* ============================================================
   MODAIS
   ============================================================ */
.modal-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 5, 7, 0.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(460px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 28px;
  animation: modalIn 0.28s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(22px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal h3 {
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 20px;
}
.modal .auth-form { gap: 12px; }
.modal .auth-form select {
  width: 100%; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--bg-3); border: 1px solid var(--line-strong);
  color: var(--text-1); outline: none;
}
.modal .auth-form select:focus { border-color: var(--jp-red); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.btn-ghost {
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  letter-spacing: 2px; text-transform: uppercase; color: var(--text-2);
  padding: 11px 18px; border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--text-1); background: var(--bg-3); }
.modal p.confirm-text { color: var(--text-2); font-size: 14.5px; }
.modal p.confirm-text strong { color: var(--text-1); }

/* ============================================================
   LIGHTBOX / TOASTS
   ============================================================ */
#lightbox {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  background: rgba(3, 4, 5, 0.88); backdrop-filter: blur(8px);
  padding: 28px; cursor: zoom-out; animation: fadeIn 0.18s ease;
}
#lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 10px; background: #fff; padding: 8px; }

#toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 130; display: grid; gap: 8px; width: min(420px, calc(100vw - 40px));
}
.toast {
  background: var(--bg-3); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--jp-red);
  border-radius: 10px; padding: 12px 16px; font-size: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.3s var(--ease);
}
.toast.ok { border-left-color: var(--positive); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 920px) {
  #btn-menu { display: block; }
  #sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform 0.3s var(--ease);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5);
    width: min(304px, 84vw);
  }
  #view-shell.drawer-open #sidebar { transform: translateX(0); }
  #drawer-scrim {
    position: fixed; inset: 0; z-index: 35;
    background: rgba(4, 5, 7, 0.6); backdrop-filter: blur(3px);
    animation: fadeIn 0.25s ease;
  }
  .bubble { max-width: 88%; }
  #messages { padding: 22px 14px 8px; }
  #composer-wrap { padding: 8px 14px 14px; }
  .composer-hint { display: none; }
  /* depois de `.bubble { max-width: 88% }` acima, senão a saudação encolhe no celular */
  .greet-bubble { max-width: none; }
  .tb-title { font-size: 15px; letter-spacing: 2px; }
  .tb-status { display: none; }
  .pbi-bar { padding: 8px 14px; gap: 10px; }
  /* No celular o rótulo comeria a barra inteira; sobra a seta. O nome do link para
   * leitor de tela vem do aria-label, que não depende do texto visível. */
  .pbi-actions .pbi-aba-label { display: none; }
  .pbi-actions .btn-ghost { padding: 9px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; }
}
