/* Reset + base — shell minimalista para visualização BI */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Tema: azul vibrante (~#1E6FFF) e tons próximos */
:root {
  --brand-blue: #1e6fff;
  --brand-blue-dark: #1557cc;
  --brand-navy: #142c66;
  --brand-cyan: #5c9dff;
  --brand-black: #0a0f1e;
  --bg: #e9efff;
  --surface: #ffffff;
  --border: #d6dff2;
  --text: var(--brand-black);
  --text-muted: #4a5569;
  --accent: var(--brand-blue);
  --accent-hover: var(--brand-blue-dark);
  --accent-soft: rgba(30, 111, 255, 0.12);
  --accent-soft-strong: rgba(30, 111, 255, 0.2);
  --accent-border: rgba(30, 111, 255, 0.35);
  --accent-surface: #e8efff;
  --card-hover-bg: #d4e3ff;
  --card-hover-border: rgba(30, 111, 255, 0.4);
  --shadow-blue: 21, 54, 120;
  /* Fundo principal da app (home Painéis + tela do relatório) */
  --report-shell-bg: linear-gradient(155deg, #2f78ff 0%, #1e6fff 42%, #1866f0 100%);
  --header-height: 56px;
  --radius: 8px;
  --ease-smooth: cubic-bezier(0.33, 1, 0.68, 1);
  --dur-view: 0.45s;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--report-shell-bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* Sem barra de rolagem na página ao ver relatório (scroll fica dentro do embed, se houver) */
body.view-report {
  overflow: hidden;
  height: 100vh;
  max-height: 100vh;
}

/* Troca suave home ↔ relatório (painéis sobrepostos) */
.app-stage {
  position: relative;
  width: 100%;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  isolation: isolate;
}

body.view-report .app-stage {
  height: calc(100vh - var(--header-height));
  max-height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.app-panel {
  width: 100%;
  backface-visibility: hidden;
  transition:
    opacity var(--dur-view) var(--ease-smooth),
    transform var(--dur-view) var(--ease-smooth),
    visibility var(--dur-view);
}

.app-panel.is-active {
  position: relative;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.app-panel:not(.is-active) {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
  min-height: calc(100vh - var(--header-height));
}

/* Entrada do conteúdo da home (primeira carga) */
.home-view .home-inner {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.55s var(--ease-smooth),
    transform 0.55s var(--ease-smooth);
}

body.app-ready .home-view.is-active .home-inner {
  opacity: 1;
  transform: translateY(0);
}

body.app-ready .home-view:not(.is-active) .home-inner {
  opacity: 1;
  transform: translateY(0);
  transition: none;
}

/* Barra superior — fixa no topo (navbar) */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--header-height);
  padding: 0 12px 0 16px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 4px 24px rgba(18, 48, 120, 0.08);
  flex-shrink: 0;
}

.app-header-leading {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.app-header-logo-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  line-height: 0;
  transition: opacity 0.15s ease;
}

body.view-home .app-header-logo-btn {
  cursor: default;
}

body.view-report .app-header-logo-btn:hover {
  opacity: 0.88;
}

body.view-report .app-header-logo-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-header-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: min(200px, 42vw);
  object-fit: contain;
  object-position: left center;
}

.app-header-titles {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
}

.header-brand {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand-black);
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
}

body.view-home .header-brand {
  cursor: default;
  pointer-events: none;
}

body.view-report .header-brand:hover {
  color: var(--accent);
}

.header-sep {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-muted);
  user-select: none;
}

.header-tagline {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  min-width: 0;
}

.relatorio-atual {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-black);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: min(52vw, 480px);
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand-black);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sidebar-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-surface);
}

body.view-home .sidebar-toggle {
  display: none;
}

.sidebar-toggle-icon {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

/* Overlay: fecha ao clicar fora */
.sidebar-backdrop {
  position: fixed;
  inset: var(--header-height) 0 0 0;
  z-index: 90;
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  background: rgba(20, 44, 102, 0.26);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  cursor: pointer;
  display: block;
}

body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.home-view {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  overflow-y: auto;
}

.home-inner {
  flex: 1;
  width: 100%;
  max-width: min(1560px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: clamp(1.25rem, 4vh, 2.5rem) clamp(1rem, 2.5vw, 2rem);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.home-catalog {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: clamp(380px, 52vh, 720px);
  padding: clamp(0.5rem, 1.5vw, 1rem) 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.home-catalog-title {
  flex: 0 0 auto;
  margin: 0 0 clamp(0.75rem, 1.5vh, 1.25rem);
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 1px 3px rgba(0, 25, 70, 0.22);
  text-align: center;
}

/* Grid 4 colunas + espaço generoso entre os quadrados */
.home-cards {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: center;
  align-content: center;
  justify-content: center;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1023px) {
  .home-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 599px) {
  .home-cards {
    grid-template-columns: 1fr;
  }
}

.home-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 0;
  padding: 16px 14px 14px;
  box-sizing: border-box;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  border-top: 3px solid var(--brand-blue);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.22s ease,
    transform 0.2s ease;
}

.home-card:hover {
  background: var(--card-hover-bg);
  border-color: var(--card-hover-border);
  border-top-color: var(--brand-blue-dark);
  box-shadow:
    0 4px 6px rgba(var(--shadow-blue), 0.1),
    0 14px 36px rgba(var(--shadow-blue), 0.18);
  transform: translateY(-3px);
}

.home-card:hover .home-card-icon {
  background: rgba(30, 111, 255, 0.16);
  border-color: rgba(30, 111, 255, 0.32);
  color: var(--brand-blue-dark);
}

.home-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Ícone quadrado “painel” — legível e comum em hubs de analytics */
.home-card-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--brand-blue);
  background: var(--accent-surface);
  border: 1px solid var(--accent-border);
}

.home-card-icon svg {
  display: block;
  opacity: 0.92;
}

.home-card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.home-card-kicker {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.home-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-card-resumo {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-muted);
  flex: 1;
  min-height: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  body {
    background: var(--brand-blue);
    background-attachment: scroll;
  }

  .view-report .main-content {
    background: var(--brand-blue);
  }

  .app-panel {
    transition: opacity 0.2s ease;
    transform: none !important;
  }

  .home-view .home-inner,
  body.app-ready .home-view.is-active .home-inner {
    transition: opacity 0.25s ease;
    transform: none !important;
  }

  .home-card {
    transition: none;
  }

  .home-card:hover {
    transform: none;
  }
}

.view-report {
  min-height: calc(100vh - var(--header-height));
}

body.view-report .view-report.is-active {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.view-report .main-content {
  background: var(--report-shell-bg);
  align-items: center;
  padding: 0 clamp(0.75rem, 2vw, 1.25rem);
  box-sizing: border-box;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  z-index: 100;
  width: min(280px, 92vw);
  height: calc(100vh - var(--header-height));
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(var(--shadow-blue), 0.09);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
}

body.sidebar-open .sidebar {
  transform: translateX(0);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

/* Navegação: área (título) + BIs listados */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.sidebar-grupo-titulo {
  margin: 0 0 6px 0;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.sidebar-bi-lista {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-bi-item-wrap {
  margin-bottom: 3px;
}

.sidebar-bi-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 11px;
  box-sizing: border-box;
  text-align: left;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
}

.sidebar-bi-item:hover {
  background: #c8d8f5;
  color: var(--brand-navy);
}

.sidebar-bi-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sidebar-bi-item.active {
  background: var(--accent-surface);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

.report-frame-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(1560px, calc(100vw - 2rem));
  margin: 0 auto;
  min-height: 0;
  padding: clamp(12px, 2vh, 20px) clamp(12px, 1.5vw, 20px) clamp(16px, 2.5vh, 28px);
  box-sizing: border-box;
}

.view-report .report-frame-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

iframe#biFrame {
  flex: 1;
  width: 100%;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.view-report iframe#biFrame {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 28px rgba(12, 35, 90, 0.18);
}

@media (max-width: 992px) {
  iframe#biFrame {
    min-height: 60vh;
  }

  .view-report iframe#biFrame {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-backdrop {
    transition: none;
  }
}
