/* ============================================================================
   Inovyo Hub — estilos da aplicação (consomem os tokens de theme.css)
   ============================================================================ */

body {
  transition: background-color .3s ease, color .3s ease;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.hub-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--inv-gradient);
  backdrop-filter: saturate(140%) blur(8px);
  box-shadow: 0 2px 16px rgba(89, 57, 89, .28);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.hub-navbar .navbar-brand,
.hub-navbar .fw-semibold,
.hub-navbar .nav-link { color: #fff; }
.hub-navbar .navbar-brand img { transition: opacity .2s ease; }
.hub-navbar .btn-outline-light {
  border-color: rgba(255, 255, 255, .55);
  transition: background-color .15s ease, transform .15s ease;
}
.hub-navbar .btn-outline-light:hover {
  background: rgba(255, 255, 255, .16);
  border-color: #fff;
}
#themeToggle { transition: transform .25s ease; }
#themeToggle:hover { transform: rotate(-18deg) scale(1.05); }

/* Lockup da marca: logo · divisória · "Hub" */
.hub-brand-sep {
  width: 1px; height: 20px;
  background: rgba(255, 255, 255, .35);
  display: inline-block;
}
.hub-nav-trigger { white-space: nowrap; }

/* ── Drawer de navegação (Offcanvas) ────────────────────────────────────── */
.hub-drawer {
  background: var(--inv-surface);
  border-right: 1px solid var(--inv-border);
}
.hub-drawer .offcanvas-header { border-bottom: 1px solid var(--inv-border); }
.hub-drawer-cat {
  color: var(--inv-muted);
  font-size: .72rem;
  letter-spacing: .04em;
  margin-bottom: .4rem;
}
.hub-drawer-item {
  border-radius: var(--inv-radius-sm);
  padding: .5rem .6rem;
  color: var(--bs-body-color);
  text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.hub-drawer-item:hover { background: rgba(var(--bs-primary-rgb), .08); }
.hub-drawer-item.active {
  background: rgba(var(--bs-primary-rgb), .14);
  color: var(--inv-primary);
  box-shadow: inset 3px 0 var(--inv-primary);
}
.hub-drawer-item.active .hub-drawer-item-icon,
.hub-drawer-item.active .hub-drawer-item-name { color: var(--inv-primary); }
.hub-drawer-item-icon { font-size: 1.1rem; line-height: 1.35; color: var(--inv-muted); }
.hub-drawer-item-name { font-weight: 500; display: block; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius);
  box-shadow: var(--inv-shadow-sm);
  background: var(--inv-surface);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card-header {
  background: var(--inv-surface-2);
  border-bottom: 1px solid var(--inv-border);
  font-weight: 600;
}

/* Cards de ferramenta da home (clicáveis) */
a.text-decoration-none .hub-tool-card { border: 1px solid var(--inv-border); }
a.text-decoration-none .hub-tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--inv-shadow-md);
  border-color: var(--inv-primary);
}
.hub-tool-icon {
  width: 46px; height: 46px;
  flex: 0 0 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--inv-radius-sm);
  background: rgba(var(--bs-primary-rgb), .12);
  color: var(--inv-primary);
  font-size: 1.3rem;
}

/* ── Botões ─────────────────────────────────────────────────────────────── */
.btn-primary {
  --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent;
  background: var(--inv-gradient);
  border: none;
  border-radius: var(--inv-radius-pill);
  box-shadow: 0 2px 10px rgba(var(--bs-primary-rgb), .35);
  transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--inv-gradient);
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(var(--bs-primary-rgb), .45);
}
.btn-primary:active { transform: translateY(0); filter: brightness(.96); }
.btn-outline-primary { border-radius: var(--inv-radius-pill); }

/* ── Badges semânticos pela paleta ──────────────────────────────────────── */
.badge.text-bg-success { background: var(--inv-success) !important; color: #fff !important; }
.badge.text-bg-danger  { background: var(--inv-danger)  !important; color: #fff !important; }
.badge.text-bg-warning { background: var(--inv-warning) !important; color: #1a1a1a !important; }
.badge.text-bg-info    { background: var(--inv-info)    !important; color: #fff !important; }
.badge.bg-secondary    { background: var(--inv-plum)    !important; }
.badge.bg-success      { background: var(--inv-success) !important; }

/* ── Tabelas ────────────────────────────────────────────────────────────── */
.table thead th { border-bottom: 2px solid var(--inv-border); }
[data-bs-theme="dark"] .table-light {
  --bs-table-bg: var(--inv-surface-2);
  --bs-table-color: var(--bs-body-color);
}

/* ── Login ──────────────────────────────────────────────────────────────── */
.hub-login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(60rem 60rem at 110% -10%, rgba(119,66,157,.16), transparent 60%),
    radial-gradient(50rem 50rem at -10% 110%, rgba(154,35,118,.16), transparent 60%);
}
.hub-login-card {
  max-width: 400px; width: 100%;
  border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius-lg);
  box-shadow: var(--inv-shadow-lg);
  background: var(--inv-surface);
}
.hub-google-btn {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  border-radius: var(--inv-radius-pill);
}

/* ── Log de execução (SSE) ─────────────────────────────────────────────── */
.hub-log {
  background: #0d1117; color: #c9d1d9;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; line-height: 1.5;
  padding: 1rem; border-radius: var(--inv-radius-sm);
  height: 360px; overflow-y: auto; white-space: pre-wrap;
  border: 1px solid rgba(255, 255, 255, .06);
}
.hub-log .log-bedrock { color: #79c0ff; }
.hub-log .log-step    { color: #d2a8ff; font-weight: 600; }
.hub-log .log-error   { color: #ff7b72; }
.hub-log .log-done    { color: #7ee787; font-weight: 600; }

/* ── Animações sutis ────────────────────────────────────────────────────── */
@keyframes hub-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.hub-fade-up { animation: hub-fade-up .45s ease both; }
.hub-fade-up:nth-child(2) { animation-delay: .05s; }
.hub-fade-up:nth-child(3) { animation-delay: .10s; }
.hub-fade-up:nth-child(4) { animation-delay: .15s; }
.hub-fade-up:nth-child(5) { animation-delay: .20s; }
.hub-fade-up:nth-child(6) { animation-delay: .25s; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
#toastContainer { z-index: 1090; }
.hub-toast {
  border-radius: var(--inv-radius-sm);
  box-shadow: var(--inv-shadow-md);
  overflow: hidden;
}
.hub-toast-header {
  border-top-left-radius: var(--inv-radius-sm);
  border-top-right-radius: var(--inv-radius-sm);
}

/* Skeleton loaders (shimmer) — substitui o conteúdo dos blocos *Loading */
.skeleton {
  background: linear-gradient(90deg,
    var(--inv-surface-2) 25%, var(--inv-border) 37%, var(--inv-surface-2) 63%);
  background-size: 400% 100%;
  animation: hub-shimmer 1.2s ease infinite;
  border-radius: var(--inv-radius-sm);
}
@keyframes hub-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Markdown renderizado (respostas do chat) ─────────────────────────────── */
.hub-md > :first-child { margin-top: 0; }
.hub-md > :last-child  { margin-bottom: 0; }
.hub-md p { margin: 0 0 .5rem; }
.hub-md ul, .hub-md ol { margin: 0 0 .5rem; padding-left: 1.25rem; }
.hub-md li { margin-bottom: .15rem; }
.hub-md h1, .hub-md h2, .hub-md h3, .hub-md h4 { font-size: 1rem; font-weight: 600; margin: .6rem 0 .35rem; }
.hub-md a { color: var(--inv-primary); }
.hub-md code {
  background: var(--inv-surface-2); border: 1px solid var(--inv-border);
  border-radius: 6px; padding: .05rem .3rem; font-size: .85em;
}
.hub-md pre {
  background: #0d1117; color: #c9d1d9; border-radius: var(--inv-radius-sm);
  padding: .6rem .75rem; overflow-x: auto; margin: 0 0 .5rem;
}
.hub-md pre code { background: none; border: 0; padding: 0; color: inherit; }
.hub-md table { width: 100%; font-size: .85em; border-collapse: collapse; margin: 0 0 .5rem; }
.hub-md th, .hub-md td { border: 1px solid var(--inv-border); padding: .2rem .4rem; }
.hub-md blockquote { border-left: 3px solid var(--inv-border); margin: 0 0 .5rem; padding-left: .6rem; color: var(--bs-secondary-color); }

/* ── Chatbot flutuante (balão global) ─────────────────────────────────────── */
.hub-docchat-fab {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 1035;
  width: 56px; height: 56px; border: 0; border-radius: var(--inv-radius-pill);
  background: var(--inv-gradient); color: #fff; font-size: 1.4rem;
  box-shadow: var(--inv-shadow-lg); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
.hub-docchat-fab:hover { transform: translateY(-2px); }
.hub-docchat-panel {
  position: fixed; right: 1.25rem; bottom: 5.5rem; z-index: 1035;
  width: min(390px, 92vw); height: min(560px, 72vh);
  display: flex; flex-direction: column;
  background: var(--inv-surface); border: 1px solid var(--inv-border);
  border-radius: var(--inv-radius); box-shadow: var(--inv-shadow-lg);
  overflow: hidden;
}
.hub-docchat-panel.d-none { display: none; }
.hub-docchat-header {
  background: var(--inv-gradient); color: #fff;
  padding: .6rem .85rem; display: flex; align-items: center; justify-content: space-between;
}
.hub-docchat-body { flex: 1 1 auto; overflow-y: auto; padding: .75rem; }
.hub-docchat-foot { border-top: 1px solid var(--inv-border); padding: .5rem; }
.hub-docchat-bubble { max-width: 90%; padding: .45rem .65rem; border-radius: var(--inv-radius-sm); white-space: normal; }
.hub-docchat-bubble.user { background: var(--inv-primary); color: #fff; }
.hub-docchat-bubble.bot  { background: var(--inv-surface-2); border: 1px solid var(--inv-border); }
.hub-docchat-refs a { font-size: .75rem; }
@media (prefers-reduced-motion: reduce) {
  .hub-docchat-fab { transition: none; }
}

/* ── Fullscreen do preview de documento ───────────────────────────────────── */
#pdfWrap:fullscreen { width: 100%; height: 100vh; background: var(--inv-surface); }
#pdfWrap:fullscreen #pdfFrame { height: 100vh !important; display: block; }
