/* Navegação do topo (protótipo Rodada A).
   A faixa escura começa na barra de módulos e continua no cabeçalho da página
   (.main-content__header) e nas abas do módulo (.page-tabs): o `order` do flex põe os
   dois logo abaixo da barra, qualquer que seja a posição deles no HTML da view. */

.ms {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  flex-shrink: 0;
}

.ms::before { content: attr(data-icon); }

.app-layout {
  flex-direction: column;
}

/* Rede de proteção: nenhum elemento (painel fixo, campo nativo) alarga a página para os
   lados — no Safari/WebView isso esticava a barra inferior e deslocava a tela. */
html,
body {
  overflow-x: clip;
}

/* ---------- barra ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #081028;
  color: var(--nav-text);
  padding: 0 28px;
}

.topnav__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 68px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.topnav a,
.topnav a:hover {
  text-decoration: none;
}

.topnav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 20px;
  color: var(--nav-text);
}

.topnav__brand:hover { color: #fff; }

.topnav__logo svg {
  width: 30px;
  height: 30px;
  display: block;
}

.topnav__brand-name {
  font: 700 17px/1 var(--font-sans);
}

.topnav__modules {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.topnav__module {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--nav-soft);
  font: 600 14px/1 var(--font-sans);
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.topnav__module:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}

.topnav__module--active,
.topnav__module--active:hover {
  background: #fff;
  color: #0d1a42;
}

.topnav__spacer { flex: 1; }

.topnav__search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  width: 260px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  color: var(--nav-muted);
  margin: 0;
}

.topnav__search:focus-within {
  border-color: var(--nav-accent);
  background: rgba(255, 255, 255, .1);
}

.topnav__search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff;
  font: 400 13px/1 var(--font-sans);
}

.topnav__search input::placeholder { color: var(--nav-muted); }

.topnav__new {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: #5466e8;
  color: #fff;
  font: 700 13px/1 var(--font-sans);
  margin-left: 4px;
  cursor: pointer;
}

.topnav__new:hover { background: #3c4ed0; }

.topnav__icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nav-soft);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.topnav__icon-btn:hover,
.topnav__icon-btn--active {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.topnav__theme-light { display: none; }
[data-theme="dark"] .topnav__theme-light { display: inline-block; }
[data-theme="dark"] .topnav__theme-dark { display: none; }

.topnav__user {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 10px 0 4px;
  border-radius: 12px;
  margin-left: 4px;
  background: rgba(255, 255, 255, .06);
  cursor: pointer;
  max-width: 240px;
}

.topnav__user:hover { background: rgba(255, 255, 255, .1); }

.topnav__avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #5466e8;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 12px/1 var(--font-sans);
  flex-shrink: 0;
}

.topnav__user-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.topnav__user-name,
.topnav__user-role {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topnav__user-name { font: 600 13px/1.1 var(--font-sans); }
.topnav__user-role { font: 400 11px/1.1 var(--font-sans); color: var(--nav-sub); }

/* ---------- menus (<details>) ---------- */
.topnav__menu,
.bottomnav__more {
  position: relative;
}

.topnav__menu > summary,
.bottomnav__more > summary {
  list-style: none;
}

.topnav__menu > summary::-webkit-details-marker,
.bottomnav__more > summary::-webkit-details-marker {
  display: none;
}

.topnav__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(10, 14, 30, .22);
  padding: 8px;
  z-index: 60;
}

.topnav__dropdown--right { left: auto; right: 0; }

.topnav__dropdown--wide {
  left: auto;
  right: 0;
  width: 520px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}

.topnav__dropdown--wide .topnav__dropdown-section:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  columns: 2;
  column-gap: 8px;
}

.topnav__dropdown--wide .topnav__dropdown-section:last-child:nth-child(odd) .topnav__dropdown-title {
  column-span: all;
}

.topnav__dropdown-title {
  font: 600 11px/1 var(--font-sans);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  padding: 12px 10px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topnav__dropdown-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--color-text);
  font: 500 14px/1.2 var(--font-sans);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  break-inside: avoid;
}

.topnav__dropdown-link:hover {
  background: var(--surface-2);
  color: var(--color-text);
  text-decoration: none;
}

.topnav__dropdown-link--active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.topnav__dropdown-link--danger,
.topnav__dropdown-link--danger:hover { color: var(--danger); }

.topnav__logout-form { margin: 0; }

/* ---------- conteúdo ---------- */
.main-content {
  flex: 1;
  min-width: 0; /* um filho largo não estica a viewport */
  max-width: 100%;
  padding: 0 28px 32px;
  display: flex;
  flex-direction: column;
}

.main-content__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
}

.main-content__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0;
}

.main-content__actions {
  display: flex;
  gap: var(--space-2);
}

/* Cabeçalho da página = continuação da faixa escura. */
body.is-signed-in .main-content__header {
  order: -2;
  margin: 0 -28px 22px;
  padding: 20px 28px 26px;
  background: linear-gradient(180deg, #081028 0%, #0d1a42 100%);
  color: var(--nav-text);
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px 32px;
}

body.is-signed-in .main-content:has(> .page-tabs) .main-content__header {
  margin-bottom: 0;
  padding-bottom: 6px;
}

body.is-signed-in .main-content__header .main-content__title,
body.is-signed-in .main-content__header h1,
body.is-signed-in .main-content__header h2 {
  color: #fff;
  font: 600 32px/1.1 var(--font-sans) !important;
  letter-spacing: -.025em;
  margin: 0;
}

body.is-signed-in .main-content__header p,
body.is-signed-in .main-content__header .text-muted {
  color: var(--nav-sub) !important;
  font-size: 14px !important;
  margin: 8px 0 0;
}

body.is-signed-in .main-content__header a:not(.btn) { color: var(--nav-accent); }
body.is-signed-in .main-content__header a:not(.btn):hover { color: #fff; }

body.is-signed-in .main-content__header .main-content__actions {
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

body.is-signed-in .main-content__header .main-content__actions form { display: inline-flex; margin: 0; }

body.is-signed-in .main-content__header .btn {
  height: 40px;
  padding: 0 15px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
}

body.is-signed-in .main-content__header .btn--secondary,
body.is-signed-in .main-content__header .btn--outline,
body.is-signed-in .main-content__header .btn--ghost {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .14);
  color: #fff;
}

body.is-signed-in .main-content__header .btn--secondary:hover,
body.is-signed-in .main-content__header .btn--outline:hover,
body.is-signed-in .main-content__header .btn--ghost:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

body.is-signed-in .main-content__header .btn--primary {
  background: #5466e8;
  border-color: #5466e8;
}

body.is-signed-in .main-content__header .btn--blocked,
body.is-signed-in .main-content__header .btn--blocked:disabled {
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .14);
  color: var(--nav-muted);
}

/* Trilha (breadcrumbs), destaque em serifa e selo dentro do cabeçalho. */
.page-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font: 500 13px/1 var(--font-sans);
  color: var(--nav-muted);
  margin-bottom: 14px;
}

.page-crumbs a { color: var(--nav-muted) !important; }
.page-crumbs a:hover { color: #fff !important; }
.page-crumbs__current { color: #fff; }
.page-crumbs .ms { font-size: 16px; opacity: .6; }

.page-accent {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--nav-accent);
  font-size: 1.18em;
  letter-spacing: 0;
}

.page-hint {
  font: 600 11px/1 var(--font-sans);
  background: rgba(242, 179, 61, .18);
  color: #f2b33d;
  padding: 3px 7px;
  border-radius: 20px;
}

/* Abas do módulo, logo abaixo do cabeçalho. */
body.is-signed-in .page-tabs {
  order: -1;
  display: flex;
  gap: 4px;
  margin: 0 -28px 22px;
  padding: 0 28px;
  background: #0d1a42;
  overflow-x: auto;
  scrollbar-width: none;
}

.page-tabs__tab {
  position: relative;
  padding: 12px 14px 16px;
  font: 600 14px/1 var(--font-sans);
  color: var(--nav-muted);
  white-space: nowrap;
}

.page-tabs__tab:hover {
  color: #fff;
  text-decoration: none;
}

.page-tabs__tab--active { color: #fff; }

.page-tabs__tab--active::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: #5466e8;
}

/* ---------- barra inferior (celular) ---------- */
.bottomnav { display: none; }

@media (max-width: 1280px) {
  .topnav__search { width: 200px; }
  .topnav__user-text { display: none; }
  .topnav__user { padding-right: 4px; }
}

@media (max-width: 1100px) {
  .topnav__module span:not(.ms) { display: none; }
  .topnav__module { padding: 0 11px; }
}

@media (max-width: 900px) {
  .topnav { padding: 0 16px; }
  .topnav__bar { height: 60px; }
  .topnav__modules,
  .topnav__search,
  .topnav__new span:not(.ms) { display: none; }
  .topnav__new { padding: 0 10px; }

  .main-content {
    padding: 0 14px 104px;
  }

  body.is-signed-in .main-content__header,
  body.is-signed-in .page-tabs {
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Abas que não cabem quebram de linha em vez de rolar escondidas. */
  body.is-signed-in .page-tabs {
    flex-wrap: wrap;
    overflow: visible;
    gap: 0 2px;
  }

  .page-tabs__tab { padding: 10px 10px 13px; font-size: 13px; }
  .page-tabs__tab--active::after { left: 10px; right: 10px; }

  body.is-signed-in .main-content__header {
    padding-top: 12px;
    padding-bottom: 18px;
    margin-bottom: 14px;
  }

  body.is-signed-in .main-content__header .main-content__title,
  body.is-signed-in .main-content__header h1 {
    font-size: 22px !important;
  }

  body.is-signed-in .main-content__header {
    flex-direction: column;
    align-items: stretch;
  }

  body.is-signed-in .main-content__header .main-content__actions { width: 100%; }

  /* Menus do topo (Novo, engrenagem, usuário) viram uma folha sob a barra: alinhados ao
     botão, saíam pela borda da tela. */
  .topnav__dropdown,
  .topnav__dropdown--wide {
    position: fixed;
    top: 64px;
    left: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    max-width: calc(100vw - 24px);
    display: block;
    max-height: calc(100vh - 160px);
  }

  .topnav__dropdown--wide .topnav__dropdown-section:last-child:nth-child(odd) { columns: 1; }

  .bottomnav { max-width: 100vw; }
  .bottomnav__sheet { max-width: calc(100vw - 16px); }

  .bottomnav {
    display: flex;
    justify-content: space-around;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
  }

  .bottomnav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 60px;
    min-height: 48px;
    color: var(--color-text-secondary);
    font: 600 10px/1 var(--font-sans);
    cursor: pointer;
  }

  .bottomnav__item:hover { text-decoration: none; color: var(--color-text); }
  .bottomnav__item--active,
  .bottomnav__item--active:hover { color: var(--accent); }

  .bottomnav__sheet {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    max-height: 70vh;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(10, 14, 30, .25);
    padding: 8px;
  }
}

@media print {
  .topnav,
  .bottomnav,
  .page-tabs { display: none !important; }
}
