/* ==========================================================
   BNMA ADVOGADOS - LAYOUT, SHELL & RESPONSIVIDADE
   ========================================================== */

/* Body Lock para evitar rolagem de tela fantasma em segundo plano */
body.menu-open,
body.modal-open {
  overflow: hidden !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  background-color: var(--bg-body);
  position: relative;
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.logo-badge {
  width: 36px;
  height: 36px;
  background-color: var(--accent-solid);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.logo-text h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.1;
}

.logo-text span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-nav {
  padding: 1.25rem 0.75rem;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-solid);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* MAIN CONTENT */
.main-wrapper {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* HEADER */
.top-header {
  height: 64px;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.content-container {
  padding: 2rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* MOBILE TOGGLE & RESPONSIVIDADE */
.mobile-menu-btn {
  display: none;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  min-width: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 35;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
  touch-action: none;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 1024px) {
  .sidebar {
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--transition-normal), visibility var(--transition-normal);
  }
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }
  .sidebar-footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }
  .main-wrapper {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .top-header {
    padding: 0 1rem;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .content-container {
    padding: 1.25rem 1rem;
    width: 100%;
    max-width: 100vw;
  }
}

@media (max-width: 768px) {
  .top-header {
    height: 56px;
    padding: 0 0.75rem;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .header-left span {
    font-size: 0.85rem !important;
  }
  .content-container {
    padding: 0.75rem;
    width: 100%;
    max-width: 100vw;
  }
  .page-title {
    font-size: 1.05rem;
  }
}

@media (max-width: 480px) {
  .top-header {
    padding: 0 0.5rem;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .content-container {
    padding: 0.5rem;
  }
  .nav-item {
    min-height: 48px;
    font-size: 0.9rem;
  }
}
