/* Painel + Chat — visual novo (design_handoff_radi_reports/RADI Painel.dc.html
   e RADI Chat.dc.html). Usa os mesmos tokens de cor/tipografia do relatório
   v2 (radi-theme-v2.css), com prefixo próprio (rp-) por serem telas
   diferentes (app interno, não documento exportável). */

/* Paleta MoodLabs — extraída direto do SVG oficial do logo (cores exatas,
   não aproximadas): cream #F3EDE3, ink #161311, pink #FF3D9C, azul #5C7BB8,
   verde #2D6A4F. teal1/teal2/pink1/pink2 mantêm os nomes antigos (usados em
   dezenas de regras abaixo) mas agora apontam pros tokens da marca nova. */
:root {
  --rp-paper: #F3EDE3;
  --rp-card: #FFFFFF;
  --rp-border: #E4DCCD;
  --rp-border-strong: #D2C6B2;
  --rp-ink: #161311;
  --rp-ink-soft: #5B534B;
  --rp-ink-dim: #8C8276;
  --rp-teal1: #161311;
  --rp-teal2: #322B24;
  --rp-pink1: #FF3D9C;
  --rp-pink2: #FF8AC4;
  --rp-blue: #5C7BB8;
  --rp-green: #2D6A4F;
  --rp-up: #2D6A4F;
  --rp-down: #B33B3B;
}

/* Faixa de assinatura MoodLabs (rosa → azul → verde), o mesmo gradiente do
   topo do site — usada como detalhe de marca no header do painel/chat. */
.rp-brand-bar { height: 4px; background: linear-gradient(90deg, var(--rp-pink1), var(--rp-blue) 58%, var(--rp-green)); }
.rp-brand-logo { display: flex; align-items: center; gap: 10px; }
.rp-brand-logo svg { flex-shrink: 0; }

/* ---------- Gate de senha (auth.js) ---------- */

#auth-gate {
  position: fixed; inset: 0; background: var(--rp-teal1);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.auth-box { background: #fff; border-radius: 12px; padding: 32px 36px; width: 300px; text-align: center; font-family: 'DM Sans', sans-serif; }
.auth-box h2 { font-family: 'Space Grotesk', sans-serif; font-size: 15px; margin: 0 0 4px; color: var(--rp-ink); }
.auth-box p { font-size: 13px; color: var(--rp-ink-soft); margin: 0 0 16px; }
.auth-box form { display: flex; flex-direction: column; gap: 8px; }
.auth-box input { padding: 9px 11px; border: 1px solid var(--rp-border-strong); border-radius: 6px; font-size: 13px; font-family: 'DM Sans', sans-serif; }
.auth-box input:focus { outline: none; border-color: var(--rp-pink1); }
.auth-box button { background: var(--rp-pink1); color: #fff; border: none; border-radius: 6px; padding: 10px 14px; cursor: pointer; font-weight: 600; font-family: 'DM Sans', sans-serif; margin-top: 4px; }
.auth-box button:disabled { opacity: .6; cursor: not-allowed; }
.auth-error { color: var(--rp-down) !important; margin-top: 10px !important; margin-bottom: 0 !important; font-size: 12px !important; }
.auth-switch { font-size: 12px !important; margin-top: 16px !important; margin-bottom: 0 !important; }
.auth-switch a { color: var(--rp-pink1); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

body.rp-body {
  margin: 0;
  background: #F3EDE3;
  font-family: 'DM Sans', sans-serif;
  color: var(--rp-ink);
}
.rp-body * { box-sizing: border-box; }
.rp-body a { color: var(--rp-pink1); text-decoration: none; }
.rp-body a:hover { color: #D6207F; }
.rp-body ::placeholder { color: var(--rp-ink-dim); }

/* ---------- Painel ---------- */

.rp-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 0 0 80px; }

.rp-header {
  width: 100%;
  padding: 40px 48px 56px;
  background: linear-gradient(115deg, var(--rp-teal1), var(--rp-teal2)),
              radial-gradient(ellipse 620px 360px at 100% 0%, var(--rp-pink1), transparent 62%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.rp-header-eyebrow { font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: .22em; opacity: .75; margin-bottom: 10px; }
.rp-header-title { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 28px; text-transform: uppercase; line-height: 1.15; margin-top: 22px; }
.rp-header-title span { color: var(--rp-pink2); }
.rp-header-sub { font-size: 13.5px; opacity: .85; margin-top: 8px; max-width: 560px; line-height: 1.6; }

.rp-body-wrap { width: 100%; max-width: 980px; padding: 0 40px; margin-top: -24px; }

/* ---------- Resumo (topo do painel) ---------- */

.rp-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 32px; }
.rp-summary-card { background: var(--rp-card); border: 1px solid var(--rp-border); border-radius: 14px; padding: 22px 24px; box-shadow: 0 8px 20px rgba(22,19,17,.06); display: flex; align-items: center; gap: 16px; }
.rp-summary-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--rp-paper); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.rp-summary-value { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 24px; color: var(--rp-ink); line-height: 1.2; }
.rp-summary-label { font-family: 'DM Mono', monospace; font-size: 10.5px; letter-spacing: .06em; color: var(--rp-ink-soft); text-transform: uppercase; margin-top: 4px; }
.rp-summary-sub { font-size: 12.5px; color: var(--rp-ink-dim); margin-top: 3px; }
@media (max-width: 640px) { .rp-summary-grid { grid-template-columns: 1fr; } }

.rp-tabs { display: flex; gap: 10px; background: var(--rp-card); border: 1px solid var(--rp-border); border-radius: 14px; padding: 8px; box-shadow: 0 12px 30px rgba(22,19,17,.12); margin-bottom: 28px; }
.rp-tab { flex: 1; text-align: center; padding: 13px; border-radius: 9px; font-weight: 700; font-size: 14px; cursor: pointer; transition: .15s; color: var(--rp-ink-soft); }
.rp-tab.active { background: #161311; color: #fff; }

.rp-panel-card { background: var(--rp-card); border: 1px solid var(--rp-border); border-radius: 16px; padding: 30px; box-shadow: 0 10px 26px rgba(22,19,17,.08); }

.rp-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 24px; }
.rp-field-label { font-size: 11px; letter-spacing: .08em; color: var(--rp-ink-soft); font-family: 'DM Mono', monospace; font-weight: 600; margin-bottom: 6px; }
.rp-input, .rp-select {
  width: 100%; padding: 12px 14px; border-radius: 9px; border: 1px solid var(--rp-border-strong);
  background: #fff; font-size: 14.5px; color: var(--rp-ink); font-family: 'DM Sans', sans-serif;
}

.rp-source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.rp-source-card { padding: 16px; border-radius: 10px; border: 1px solid var(--rp-border); background: #fff; cursor: pointer; transition: .15s; }
.rp-source-card.active { border: 2px solid var(--rp-pink1); background: rgba(255,61,156,.08); }
.rp-source-title { font-weight: 700; font-size: 14.5px; color: var(--rp-ink); margin-bottom: 3px; }
.rp-source-sub { font-size: 12px; color: var(--rp-ink-soft); }

.rp-dropzone { border: 2px dashed var(--rp-border-strong); border-radius: 12px; padding: 26px; text-align: center; color: var(--rp-ink-soft); margin-bottom: 14px; position: relative; }
.rp-dropzone-label { font-size: 14px; font-weight: 600; color: var(--rp-ink); }
.rp-dropzone-sub { font-size: 11.5px; color: var(--rp-ink-dim); margin-top: 4px; }
.rp-dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.rp-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.rp-thumb { width: 64px; }
.rp-thumb-img { width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--rp-border); background-size: cover; background-position: center; background-color: var(--rp-paper); display: flex; align-items: center; justify-content: center; font-family: 'DM Mono', monospace; font-size: 9px; color: var(--rp-ink-dim); overflow: hidden; }
.rp-thumb-name { font-size: 9.5px; color: var(--rp-ink-dim); text-align: center; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rp-context { margin-bottom: 20px; }
.rp-context-label { display: block; font-size: 12px; font-weight: 600; color: var(--rp-ink); margin-bottom: 6px; }
.rp-context-label span { font-weight: 400; color: var(--rp-ink-dim); }
.rp-context-input { width: 100%; box-sizing: border-box; border: 1px solid var(--rp-border-strong); border-radius: 10px; padding: 10px 12px; font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--rp-ink); background: var(--rp-card); resize: vertical; }
.rp-context-input:focus { outline: none; border-color: #FF3D9C; }

.rp-btn-primary {
  width: 100%; padding: 16px; border: none; border-radius: 10px; font-weight: 700; font-size: 15px;
  font-family: 'DM Sans', sans-serif; cursor: pointer; color: #fff;
  background: linear-gradient(120deg, var(--rp-teal1), var(--rp-teal2));
}
.rp-btn-primary:disabled { cursor: not-allowed; background: #D8CBB6; opacity: .6; }

.rp-gallery-group { margin-bottom: 32px; }
.rp-gallery-group-title { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 18px; color: var(--rp-ink); text-transform: uppercase; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid var(--rp-border-strong); }
@media (max-width: 720px) { .rp-field-grid, .rp-source-grid { grid-template-columns: 1fr; } }
.rp-gallery-list { display: flex; flex-direction: column; background: var(--rp-card); border: 1px solid var(--rp-border); border-radius: 14px; overflow: hidden; box-shadow: 0 8px 20px rgba(22,19,17,.06); }
.rp-gallery-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--rp-border); transition: background .15s; }
.rp-gallery-row:last-child { border-bottom: none; }
.rp-gallery-row:hover { background: rgba(22,19,17,.03); }
.rp-gallery-row-meta { font-size: 13px; color: var(--rp-ink); font-family: 'DM Mono', monospace; min-width: 160px; }
.rp-gallery-status { flex-shrink: 0; font-size: 10.5px; font-family: 'DM Mono', monospace; letter-spacing: .04em; padding: 3px 9px; border-radius: 100px; background: var(--rp-border); color: var(--rp-ink-soft); }
.rp-gallery-status.status-published { background: rgba(22,19,17,.12); color: var(--rp-teal1); }
.rp-gallery-status.status-finalized { background: rgba(255,61,156,.12); color: #FF3D9C; }
.rp-gallery-actions { margin-left: auto; display: flex; gap: 14px; }
.rp-gallery-actions a { font-size: 12.5px; font-weight: 600; color: #FF3D9C; text-decoration: none; }
.rp-gallery-actions a:hover { text-decoration: underline; }
.rp-gallery-actions a.rp-gallery-del { color: var(--rp-ink-dim); font-weight: 400; }
.rp-gallery-actions a.rp-gallery-del:hover { color: var(--rp-down); }
.rp-gallery-empty { color: var(--rp-ink-dim); font-size: 13px; padding: 20px 0; }
@media (max-width: 600px) { .rp-gallery-row { flex-wrap: wrap; } .rp-gallery-actions { margin-left: 0; } }

.rp-banner { max-width: 900px; margin: 0 auto 16px; padding: 12px 18px; border-radius: 8px; font-size: 13px; }
.rp-banner.error { background: #FBEAEA; color: var(--rp-down); border: 1px solid #EDC2C2; }
.rp-banner.success { background: #E4EFE6; color: var(--rp-up); border: 1px solid #BFDAC6; }

/* ---------- Chat ---------- */

.rp-chat-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.rp-chat-header {
  padding: 18px 32px;
  background: linear-gradient(115deg, var(--rp-teal1), var(--rp-teal2)),
              radial-gradient(ellipse 620px 300px at 100% 0%, var(--rp-pink1), transparent 62%);
  color: #fff; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 12px; flex-wrap: wrap;
}
.rp-chat-back { color: rgba(255,255,255,.75); font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: .1em; }
.rp-chat-title { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 19px; text-transform: uppercase; margin-top: 4px; }
.rp-chat-title span { color: var(--rp-pink2); }
.rp-chat-sub { font-family: 'DM Mono', monospace; font-size: 11px; opacity: .75; margin-top: 2px; }
.rp-btn-final { padding: 12px 20px; border: none; border-radius: 9px; font-weight: 700; font-size: 13.5px; font-family: 'DM Sans', sans-serif; cursor: pointer; color: var(--rp-teal1); background: var(--rp-pink2); }
.rp-btn-final:disabled { cursor: not-allowed; color: #fff; background: rgba(255,255,255,.15); }

.rp-chat-body { flex: 1; display: flex; min-height: 0; }
.rp-chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rp-chat-log { flex: 1; overflow-y: auto; padding: 26px 32px; display: flex; flex-direction: column; gap: 16px; }

.rp-msg-row { display: flex; }
.rp-msg-row.user { justify-content: flex-end; }
.rp-msg-row.assistant { justify-content: flex-start; }
.rp-bubble { max-width: 72%; padding: 14px 18px; border-radius: 14px 14px 14px 4px; background: var(--rp-card); border: 1px solid var(--rp-border); }
.rp-msg-row.user .rp-bubble { border-radius: 14px 14px 4px 14px; background: rgba(255,61,156,.12); border-color: var(--rp-pink2); }
.rp-bubble-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .08em; font-weight: 700; color: var(--rp-teal2); margin-bottom: 5px; text-transform: uppercase; }
.rp-msg-row.user .rp-bubble-label { color: #D6207F; }
.rp-bubble-images { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rp-bubble-images img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid rgba(0,0,0,.1); }
.rp-bubble-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }

.rp-typing { align-self: flex-start; max-width: 70%; }
.rp-typing-bubble { background: var(--rp-card); border: 1px solid var(--rp-border); border-radius: 14px 14px 14px 4px; padding: 14px 18px; display: flex; gap: 5px; align-items: center; }
.rp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--rp-ink-dim); animation: rpDot 1.2s infinite; }
.rp-dot:nth-child(2) { animation-delay: .2s; }
.rp-dot:nth-child(3) { animation-delay: .4s; }
@keyframes rpDot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.rp-chat-empty { margin: auto; text-align: center; color: var(--rp-ink-dim); max-width: 360px; }
.rp-chat-empty-title { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 16px; color: var(--rp-ink); margin-bottom: 8px; text-transform: uppercase; }
.rp-chat-empty-text { font-size: 13px; line-height: 1.6; }

.rp-chat-inputbar { padding: 16px 32px 22px; border-top: 1px solid var(--rp-border); background: var(--rp-paper); flex-shrink: 0; }
.rp-pending-images { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rp-pending-images img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--rp-border-strong); }
.rp-input-row { display: flex; gap: 10px; align-items: flex-end; }
.rp-attach-btn { flex-shrink: 0; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--rp-border-strong); background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; color: var(--rp-ink-soft); position: relative; }
.rp-attach-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.rp-chat-textarea { flex: 1; resize: none; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--rp-border-strong); font-size: 14px; font-family: 'DM Sans', sans-serif; max-height: 120px; }
.rp-send-btn { flex-shrink: 0; padding: 12px 22px; border: none; border-radius: 10px; font-weight: 700; font-size: 14px; font-family: 'DM Sans', sans-serif; cursor: pointer; color: #fff; background: linear-gradient(120deg, var(--rp-teal1), var(--rp-teal2)); }
.rp-send-btn:disabled { cursor: not-allowed; background: #D8CBB6; }

.rp-chat-sidebar { width: 280px; flex-shrink: 0; background: var(--rp-card); border-left: 1px solid var(--rp-border); padding: 22px; overflow-y: auto; }
.rp-sidebar-label { font-size: 11px; letter-spacing: .08em; color: var(--rp-ink-soft); font-family: 'DM Mono', monospace; font-weight: 600; margin-bottom: 10px; }
.rp-sidebar-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.rp-sidebar-thumb { width: 56px; height: 56px; border-radius: 8px; border: 1px solid var(--rp-border); background-size: cover; background-position: center; background-color: var(--rp-paper); display: flex; align-items: center; justify-content: center; font-family: 'DM Mono', monospace; font-size: 9px; color: var(--rp-ink-dim); }
.rp-sidebar-text { font-size: 12.5px; line-height: 1.7; color: var(--rp-ink); }

.rp-review-hint { display: block; font-family: 'DM Sans', sans-serif; font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 10.5px; color: var(--rp-ink-dim); margin-top: 3px; }
#review-panel { margin-bottom: 22px; }
.rp-rev-group-title { font-size: 11px; font-weight: 700; color: var(--rp-ink); margin: 12px 0 6px; }
.rp-rev-group-title:first-child { margin-top: 0; }
.rp-rev-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.rp-rev-row label { flex: 1; font-size: 11.5px; color: var(--rp-ink-soft); }
.rp-rev-row input { width: 82px; flex-shrink: 0; }
.rp-rev-row2 { display: flex; gap: 6px; margin-bottom: 5px; }
.rp-rev-row2 input:first-child { flex: 1; }
.rp-rev-row2 input:last-child { width: 56px; flex-shrink: 0; }
#review-panel input { border: 1px solid var(--rp-border-strong); border-radius: 6px; padding: 5px 8px; font-family: 'DM Mono', monospace; font-size: 12px; color: var(--rp-ink); background: var(--rp-paper); box-sizing: border-box; }
#review-panel input:focus { outline: none; border-color: #FF3D9C; }
.rp-rev-save { width: 100%; margin-top: 12px; background: linear-gradient(120deg, var(--rp-teal1), var(--rp-teal2)); color: #fff; border: none; border-radius: 8px; padding: 9px; font-weight: 600; font-size: 13px; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.rp-rev-save:disabled { opacity: .6; cursor: default; }
.rp-rev-status { font-size: 11px; color: var(--rp-ink-soft); margin-top: 6px; line-height: 1.5; }

@media (max-width: 900px) {
  .rp-chat-sidebar { display: none; }
}
