/* Layout do portal: estrutura de um Power BI App com a identidade MEV Brasil */

:root {
  --topbar-h: 56px;
  --sidebar-w: 260px;
}

body { overflow: hidden; }

/* ---------- Barra superior (branca, como o cabeçalho do site) ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  z-index: 30;
}

.topbar .brand { min-width: 0; white-space: nowrap; }

.topbar-icon {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--mev-teal);
  font-size: 20px;
  border-radius: 50%;
  cursor: pointer;
}

.topbar-icon:hover { background: var(--mev-teal-soft); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; min-width: 0; }

.user-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.topbar-link {
  font-family: var(--font-condensed);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.topbar-link:hover { color: var(--mev-teal); }

.topbar-link-admin { color: var(--mev-teal); }

.topbar-btn {
  height: 34px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--mev-yellow);
  color: var(--mev-green-dark);
  font-family: var(--font-condensed);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(245, 204, 0, .35);
}

.topbar-btn:hover { background: var(--mev-yellow-dark); }

/* ---------- Estrutura ---------- */

.layout {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  display: flex;
}

/* ---------- Painel de navegação ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0 16px;
  transition: margin-left .2s ease, transform .2s ease;
}

body.nav-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 16px 7px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.3;
}

.nav-item:hover { background: var(--hover); }

.nav-item.active { background: var(--selected); color: var(--mev-teal-dark); font-weight: 600; }

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--mev-yellow);
}

.nav-icon { width: 16px; height: 16px; flex: 0 0 16px; fill: currentColor; opacity: .75; }

.nav-item.active .nav-icon { opacity: 1; }

.nav-home { margin-bottom: 8px; }

.nav-group { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 4px; }

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px 6px 20px;
  border: 0;
  background: transparent;
  font-family: var(--font-condensed);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--mev-teal);
  cursor: pointer;
  text-align: left;
}

.nav-group-header:hover { color: var(--mev-teal-dark); }

.chevron { width: 10px; height: 10px; fill: currentColor; transition: transform .15s; }

.nav-group.collapsed .chevron { transform: rotate(-90deg); }

.nav-group.collapsed .nav-group-items { display: none; }

.nav-group-items .nav-item { padding-left: 28px; }

/* ---------- Conteúdo ---------- */

.content { flex: 1 1 auto; min-width: 0; position: relative; background: var(--bg); overflow: hidden; }

.content > section { position: absolute; inset: 0; }

/* Página inicial */

.home { overflow-y: auto; padding: 0 0 40px; }

.home-header {
  background: var(--mev-yellow);
  padding: 32px 32px 30px;
  margin-bottom: 28px;
}

.home-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
  color: var(--text);
}

.home-sub { color: var(--text); opacity: .8; margin: 6px 0 0; font-size: 15px; }

.home-group { margin: 0 32px 32px; }

.home-group h2 {
  font-family: var(--font-condensed);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--mev-teal);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-group h2::before { content: ""; width: 4px; height: 18px; background: var(--mev-yellow); border-radius: 2px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow .15s, transform .15s, border-color .15s;
}

.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--mev-yellow); }

.card-thumb {
  height: 90px;
  background: linear-gradient(135deg, var(--mev-teal) 0%, var(--mev-teal-dark) 100%);
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 16px 20px;
}

.card-thumb span { width: 14px; border-radius: 3px 3px 0 0; }

.card-thumb span:nth-child(1) { height: 35%; background: var(--mev-green); }
.card-thumb span:nth-child(2) { height: 60%; background: var(--mev-yellow); }
.card-thumb span:nth-child(3) { height: 85%; background: var(--mev-yellow); }
.card-thumb span:nth-child(4) { height: 50%; background: var(--mev-green); }

.card-body { padding: 14px 18px 18px; }

.card-title { font-weight: 700; font-size: 16px; margin: 0 0 4px; }

.card-desc { color: var(--text-muted); font-size: 13px; margin: 0; }

.empty {
  margin: 0 32px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  max-width: 560px;
}

/* Relatório */

.report { display: flex; flex-direction: column; }

.report-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 8px 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.report-title { font-size: 15px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.report-workspace {
  font-family: var(--font-condensed);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mev-teal);
  background: var(--mev-teal-soft);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.report-actions { margin-left: auto; display: flex; gap: 4px; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.action-btn:hover { background: var(--mev-teal-soft); color: var(--mev-teal-dark); }

.action-btn svg { width: 16px; height: 16px; fill: currentColor; }

.frame-wrap { position: relative; flex: 1 1 auto; min-height: 0; background: #EAEAEA; }

.frame-wrap:fullscreen { background: #EAEAEA; }

.report-frame { display: block; width: 100%; height: 100%; border: 0; }

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  color: var(--text-muted);
  z-index: 2;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid var(--border);
  border-top-color: var(--mev-yellow);
  border-right-color: var(--mev-green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Mensagens (sem permissão, não encontrado) */

.message { display: flex; flex-direction: column; align-items: flex-start; padding: 48px 32px; }

.message h1 { font-size: 22px; font-weight: 700; margin: 0 0 8px; }

.message p { color: var(--text-muted); margin: 0 0 20px; max-width: 560px; }

.backdrop { display: none; }

.nav-mobile-only { display: none; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }

/* ---------- Celular: menu vira gaveta ---------- */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    z-index: 20;
    margin-left: 0 !important;
    transform: translateX(-100%);
  }

  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-md); }

  .nav-mobile-only { display: flex; }

  .backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0, 0, 0, .35);
    z-index: 15;
  }

  .topbar .brand-divider,
  .topbar .brand-sub,
  .topbar-link,
  .report-workspace,
  .action-btn span { display: none; }

  .topbar .brand-logo { height: 18px; }

  .topbar-right { gap: 10px; }

  .user-name { max-width: 90px; font-size: 13px; }

  .home-header { padding: 24px 16px; }

  .home-header h1 { font-size: 22px; }

  .home-group { margin: 0 16px 28px; }

  .empty { margin: 0 16px; }

  .cards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .card, .chevron { transition: none; }
  .spinner { animation-duration: 2s; }
}
