.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  left: 0;

  display: flex;
  align-items: center;
  justify-content: space-between;

  height: var(--header-height);
  padding: 0 24px;

  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.5px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-user-name {
  font-size: 14px;
  color: var(--color-text-muted);
}

.sidebar {
  position: fixed;
  z-index: 25;
  top: var(--header-height);
  bottom: 0;
  left: 0;

  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  max-height: calc(100dvh - var(--header-height));
  padding: 20px 12px calc(24px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;

  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-small);
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
  background: #f0f0f0;
  color: var(--color-text);
}

.sidebar-link.active {
  background: var(--color-primary);
  color: #ffffff;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 24px) 32px 40px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
}

.page-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--color-text-muted);
}

.page-content {
  margin-top: 20px;
}

.app-footer {
  margin-left: var(--sidebar-width);
  padding: 16px 32px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
  background: var(--color-surface);
}

.sidebar-toggle,
.sidebar-backdrop {
  display: none;
}

/* ==========================================================
   Menu lateral contextual
   ========================================================== */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-link .icone {
  flex-shrink: 0;
  opacity: 0.75;
}

.sidebar-link.active .icone {
  opacity: 1;
}

.sidebar-link__label {
  flex: 1;
  min-width: 0;
}

.sidebar-badge {
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #b60000;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
}

.sidebar-link.active .sidebar-badge {
  background: #ffffff;
  color: var(--color-primary);
}

.sidebar-back {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-small);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.sidebar-back:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.04);
}

.sidebar-event-name {
  margin: 10px 10px 14px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.sidebar-section {
  margin: 16px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  opacity: 0.8;
}

/* Tema escuro (Araújo): herda as cores claras do menu */
[data-theme="araujo-jj-team"] .sidebar-back,
[data-theme="araujo-jj-team"] .sidebar-section {
  color: var(--ajj-gray);
}

[data-theme="araujo-jj-team"] .sidebar-back:hover {
  color: var(--ajj-white);
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="araujo-jj-team"] .sidebar-event-name {
  color: var(--ajj-white);
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: -0.01em;
}

[data-theme="araujo-jj-team"] .sidebar-link.active .sidebar-badge {
  color: var(--ajj-red);
}

/* ==========================================================
   Trilha de navegação (breadcrumb)
   ========================================================== */
.trilha {
  margin-bottom: 8px;
}

.trilha ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--color-text-muted);
}

.trilha li + li::before {
  content: "›";
  margin-right: 4px;
  opacity: 0.6;
}

.trilha a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.trilha a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.trilha [aria-current="page"] span {
  color: var(--color-text);
  font-weight: 600;
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 16px;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--color-border);
    padding: 6px 10px;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
  }

  .header-user-name {
    display: none;
  }

  .sidebar {
    width: min(280px, 82vw);
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    max-height: calc(100dvh - var(--header-height));
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.2, 0, 0, 1);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 20;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: none;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    touch-action: none;
    overscroll-behavior: contain;
  }

  .sidebar-backdrop.visible {
    display: block;
  }

  html.sidebar-aberta,
  body.sidebar-aberta {
    overflow: hidden !important;
  }

  .main-content {
    margin-left: 0;
    padding: calc(var(--header-height) + 16px) 16px 32px;
  }

  .app-footer {
    margin-left: 0;
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
  }

  .page-header .button {
    width: 100%;
  }
}
