/* ============================================================
   PUBLYA HUB — DESIGN SYSTEM
   Usa CSS custom properties para suportar dark/light mode.
   O modo escuro é o padrão (:root define os valores dark).
   O modo claro é ativado adicionando a classe .light ao <body>.
   ============================================================ */


/* ============================================================
   VARIÁVEIS — DARK MODE (padrão)
   ============================================================ */
:root {
  --c-bg:      #0f1117;   /* fundo geral da página */
  --c-panel:   #161922;   /* sidebar, topbars, modais */
  --c-card:    #1e2130;   /* cards, inputs, elementos elevados */
  --c-border:  #2a2d3a;   /* bordas em todo o app */
  --c-tx-hi:   #e2e8f0;   /* texto primário */
  --c-tx-md:   #9ca3af;   /* texto secundário */
  --c-tx-lo:   #6b7280;   /* texto muted / placeholders */
  --c-accent:  #3b82f6;   /* azul de destaque */
  --c-aclt:    #63b3ed;   /* azul claro */
  --c-online:  #34d399;   /* verde online/sucesso */
  --c-grad:    linear-gradient(135deg, #3b82f6, #6366f1);

  /* Overlay dos modais/painéis */
  --c-overlay: rgba(0, 0, 0, 0.72);

  /* Hover sutil em fundos escuros */
  --c-hover-bg: rgba(255, 255, 255, 0.05);
}

/* ============================================================
   VARIÁVEIS — LIGHT MODE
   Aplicado quando <body> tem a classe .light
   ============================================================ */
body.light {
  --c-bg:       #f1f5f9;
  --c-panel:    #ffffff;
  --c-card:     #f8fafc;
  --c-border:   #e2e8f0;
  --c-tx-hi:    #0f172a;
  --c-tx-md:    #475569;
  --c-tx-lo:    #94a3b8;
  --c-accent:   #2563eb;   /* azul mais escuro p/ contraste em fundo branco */
  --c-aclt:     #2563eb;   /* texto azul de links/títulos no light mode */
  --c-online:   #059669;
  --c-grad:     linear-gradient(135deg, #2563eb, #4f46e5);
  --c-overlay:  rgba(0, 0, 0, 0.45);
  --c-hover-bg: rgba(0, 0, 0, 0.04);
}


/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--c-bg);
  color: var(--c-tx-hi);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

a          { text-decoration: none; color: inherit; }
button     { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; line-height: inherit; color: inherit; }
input      { font-family: inherit; font-size: inherit; }
img        { display: block; max-width: 100%; }

/* Acessibilidade — anel de foco visível apenas para navegação por teclado */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: 6px;
}
#chatInput:focus-visible { outline-offset: 0; }


/* ============================================================
   OVERLAY (mobile backdrop)
   ============================================================ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  z-index: 150;
}
.overlay.visible { display: block; }


/* ============================================================
   LAYOUT — duas colunas, 100vw × 100vh
   ============================================================ */
.layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--c-bg);
}


/* ============================================================
   SIDEBAR — 280px fixo
   ============================================================ */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  height: 100%;
  background: var(--c-panel);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.sidebar-hd {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.sidebar-hd-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-tx-hi);
  letter-spacing: -0.01em;
}

.sidebar-hd-sub {
  font-size: 11px;
  color: var(--c-tx-lo);
  margin-top: 2px;
}

/* ── Botões de navegação ── */
.sidebar-nav {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--c-tx-md);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.nav-btn i {
  font-size: 13.5px;
  width: 15px;
  text-align: center;
  flex-shrink: 0;
}

.nav-btn:hover {
  color: var(--c-tx-hi);
  background: var(--c-hover-bg);
}

.nav-btn.active {
  color: var(--c-aclt);
  background: rgba(99, 179, 237, 0.10);
  box-shadow: inset 3px 0 0 var(--c-accent);
}

/* ── Ferramentas de acesso rápido ── */
.sidebar-tools {
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
  transition: border-color 0.25s ease;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.18);
  color: var(--c-aclt);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.tool-btn:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--c-accent);
  color: var(--c-tx-hi);
}
.tool-btn i:first-child {
  font-size: 13px;
  width: 15px;
  text-align: center;
  flex-shrink: 0;
}
.tool-btn span { flex: 1; }
.tool-btn-arrow { font-size: 9px; color: var(--c-tx-lo); flex-shrink: 0; transition: color 0.2s ease; }
.tool-btn:hover .tool-btn-arrow { color: var(--c-aclt); }

/* ── Área de conteúdo (scroll interno) ── */
.sidebar-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid var(--c-border);
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}

.sidebar-content::-webkit-scrollbar { width: 3px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }

.panel { display: none; padding: 10px; }
.panel.active { display: block; }


/* ============================================================
   CARDS (Checklists & Vídeos)
   ============================================================ */
.p-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 10px 10px 10px 12px;
  margin-bottom: 7px;
  transition: border-color 0.2s ease, background 0.25s ease;
}
.p-card:last-child { margin-bottom: 0; }
.p-card:hover { border-color: var(--c-accent); }

.p-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.p-card-icon.pdf   { background: rgba(239, 68, 68,   0.15); color: #f87171; }
.p-card-icon.video { background: rgba( 59, 130, 246, 0.15); color: var(--c-aclt); }

.p-card-info { flex: 1; min-width: 0; }

.p-card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-tx-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.p-card-desc {
  font-size: 11px;
  color: var(--c-tx-lo);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-p {
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--c-accent);
  color: var(--c-aclt);
  background: transparent;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.btn-p:hover { background: rgba(59, 130, 246, 0.15); }


/* ============================================================
   CARDS DE AVISOS
   ============================================================ */
.aviso-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 7px;
  transition: border-color 0.2s ease, background 0.25s ease;
}
.aviso-card:last-child { margin-bottom: 0; }
.aviso-card:hover { border-color: var(--c-accent); }

.aviso-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.aviso-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.badge-urgente     { background: rgba(239, 68,  68,  0.15); color: #f87171; }
.badge-informativo { background: rgba( 59, 130, 246, 0.15); color: var(--c-aclt); }
.badge-atualizacao { background: rgba( 52, 211, 153, 0.15); color: #34d399; }
.badge-lembrete    { background: rgba(251, 191,  36, 0.15); color: #fbbf24; }

.aviso-date { font-size: 10px; color: var(--c-tx-lo); white-space: nowrap; }

.aviso-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-tx-hi);
  line-height: 1.35;
  margin-bottom: 5px;
}

.aviso-text { font-size: 11.5px; color: var(--c-tx-md); line-height: 1.5; }


/* ============================================================
   LISTA DE LINKS
   ============================================================ */
.link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.link-item:last-child { border-bottom: none; }
.link-item:hover { background: var(--c-hover-bg); }

.link-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-aclt);
  font-size: 12px;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.link-item:hover .link-item-icon { background: rgba(59, 130, 246, 0.20); }

.link-item-info { flex: 1; min-width: 0; }

.link-item-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-aclt);
  transition: color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-item:hover .link-item-title { color: var(--c-tx-hi); }

.link-item-desc {
  font-size: 10.5px;
  color: var(--c-tx-lo);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-item-arrow { font-size: 10px; color: var(--c-tx-lo); flex-shrink: 0; transition: color 0.15s ease; }
.link-item:hover .link-item-arrow { color: var(--c-aclt); }


/* ============================================================
   CHAT — coluna direita
   ============================================================ */
.chat-area {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
  transition: background 0.25s ease;
}

/* ── Header do chat ── */
.chat-hd {
  background: var(--c-panel);
  border-bottom: 1px solid var(--c-border);
  padding: 0 14px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.burger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: var(--c-tx-md);
  font-size: 15px;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}
.burger-btn:hover { background: var(--c-hover-bg); color: var(--c-tx-hi); }

.bot-avatar-hd {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}
.bot-avatar-hd img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chat-hd-identity { display: flex; align-items: center; gap: 10px; }

.chat-hd-name { font-size: 14px; font-weight: 600; color: var(--c-tx-hi); }

/* Online — empurrado para a direita */
.chat-hd-online {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-online);
  animation: pulseOnline 2.4s ease-in-out infinite;
}

@keyframes pulseOnline {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.chat-hd-online span:last-child {
  font-size: 11px;
  color: var(--c-online);
  font-weight: 500;
}

/* ── Botão de tema ── */
.theme-toggle {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-tx-lo);
  font-size: 13px;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, transform 0.3s ease;
}
.theme-toggle:hover {
  background: var(--c-hover-bg);
  color: var(--c-tx-hi);
  transform: rotate(20deg);
}

/* ── Mensagens ── */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 80%;
  animation: msgIn 0.2s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.bot  { align-self: flex-start; }
.msg.user { align-self: flex-end; }

.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}
.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.msg-bubble {
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.58;
  word-break: break-word;
  max-width: 100%;
}

.msg.bot .msg-bubble {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  color: var(--c-tx-hi);
  border-radius: 4px 14px 14px 14px;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.msg.user .msg-bubble {
  background: var(--c-grad);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}

/* Typing */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  min-height: 44px;
}

.typing-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-tx-lo);
  animation: typePulse 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typePulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1; }
}

/* ── Botões rápidos ── */
.quick-bar-wrap {
  border-top: 1px solid var(--c-border);
  padding: 8px 14px;
  flex-shrink: 0;
  transition: border-color 0.25s ease;
}

.quick-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.quick-bar::-webkit-scrollbar { display: none; }

.pill-btn {
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--c-accent);
  color: var(--c-aclt);
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}
.pill-btn:hover { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }

/* ── Input ── */
.chat-input-wrap {
  padding: 8px 14px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#chatInput {
  flex: 1;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--c-tx-hi);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease, background 0.25s ease;
}
#chatInput::placeholder { color: var(--c-tx-lo); }
#chatInput:focus { border-color: var(--c-accent); }

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--c-grad);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.send-btn:hover:not(.is-disabled) { opacity: 0.9; transform: scale(1.07); }
.send-btn.is-disabled { opacity: 0.3; cursor: not-allowed; }


/* ============================================================
   MODAL DE VÍDEO
   ============================================================ */
.video-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--c-overlay);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.video-modal-overlay.open { display: flex; }

.video-modal-box {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  width: 100%;
  max-width: 840px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.video-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.video-modal-title { font-size: 13.5px; font-weight: 600; color: var(--c-tx-hi); }

.video-modal-close,
.content-panel-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-tx-md);
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}
.video-modal-close:hover,
.content-panel-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.video-modal-body {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  background: #000;
}
.video-modal-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; }


/* ============================================================
   PAINEL DE CONTEÚDO (botões rápidos)
   ============================================================ */
.content-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--c-overlay);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.content-overlay.open { display: flex; }

.content-panel {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.22s ease;
}

.content-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.content-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-tx-hi);
}

/* Corpo do painel com scroll */
.content-panel-body {
  overflow-y: auto;
  padding: 20px 22px 24px;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}
.content-panel-body::-webkit-scrollbar { width: 3px; }
.content-panel-body::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }

/* Tipografia do conteúdo */
.content-panel-body h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-aclt);
  margin: 20px 0 8px;
}
.content-panel-body h3:first-child { margin-top: 0; }

.content-panel-body p {
  font-size: 13.5px;
  color: var(--c-tx-md);
  line-height: 1.7;
  margin-bottom: 10px;
}

.content-panel-body ul,
.content-panel-body ol {
  padding-left: 18px;
  margin-bottom: 10px;
}

.content-panel-body li {
  font-size: 13.5px;
  color: var(--c-tx-md);
  line-height: 1.65;
  margin-bottom: 5px;
}

.content-panel-body code {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  color: var(--c-aclt);
}

.content-panel-body strong { color: var(--c-tx-hi); font-weight: 600; }
.content-panel-body .text-urgent { color: #ef4444; }

.content-edit-note {
  margin-top: 20px;
  padding: 10px 12px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--c-tx-lo);
  line-height: 1.5;
}


/* ============================================================
   RESPONSIVIDADE MOBILE (< 768px)
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .chat-area { width: 100%; }
  .burger-btn { display: flex; }
  .chat-input-wrap { padding: 8px 10px 12px; }
  .quick-bar-wrap  { padding: 7px 10px; }
  .chat-messages   { padding: 12px 10px; }
  .msg { max-width: 90%; }
  .video-modal-overlay,
  .content-overlay { padding: 10px; }
}
