/* ==========================================================================
   Layout global — app shell, sidebar, header, containers
   Direção editorial/corporativa: densidade maior, menos ornamento.
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  min-height: 100vh;
  background: var(--bg-body);
}

.app-shell--auth {
  display: block;
  min-height: 100vh;
  background: var(--bg-body);
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: var(--faj-blue);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 0;
  border-right: 1px solid rgba(255,255,255,0.04);
  position: relative;
  z-index: 5;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: var(--white);
}
.sidebar__brand-mark {
  width: 32px; height: 32px;
  border-radius: 5px;
  background: rgba(255,255,255,0.10);
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--white);
  flex: 0 0 auto;
}
.sidebar__brand-text {
  display: flex; flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.sidebar__brand-name {
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--white);
}
.sidebar__brand-sub {
  font-size: 10px; font-weight: 500;
  letter-spacing: 1.3px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  padding: 14px 0 8px;
  flex: 1 1 auto;
  overflow-y: auto;
  gap: 1px;
}

.sidebar__section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.42);
  padding: 4px 24px 8px;
  font-weight: 700;
}

.sidebar__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 24px 9px 24px;
  color: rgba(255,255,255,0.72);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  border-radius: 0;
}
.sidebar__link:hover { color: var(--white); background: rgba(255,255,255,0.04); }
.sidebar__link .icon { flex: 0 0 16px; opacity: 0.72; }
.sidebar__link:hover .icon { opacity: 1; }
.sidebar__link.is-active {
  color: var(--white);
  background: rgba(255,255,255,0.06);
  font-weight: 600;
}
.sidebar__link.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--white);
  border-radius: 0 3px 3px 0;
}
.sidebar__link.is-active .icon { opacity: 1; }

.sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
}
.sidebar__footer .avatar {
  background: rgba(255,255,255,0.14);
  color: var(--white);
}
.sidebar__user-meta { min-width: 0; flex: 1 1 auto; }
.sidebar__user-name {
  font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__footer .icon-btn {
  color: rgba(255,255,255,0.75);
}
.sidebar__footer .icon-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}

/* ---------------- Header ---------------- */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.app-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  flex: 0 0 auto;
}
.app-header__title {
  font-size: 14px; font-weight: 600; color: var(--gray-900);
  line-height: 1.15;
}
.app-header__subtitle {
  color: var(--gray-500); font-size: 12px;
  line-height: 1.15;
}
.app-header__actions { display: flex; align-items: center; gap: 8px; }

/* ---------------- Content ---------------- */
.app-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 32px 32px 64px;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-header__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.page-header__title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--gray-900);
  line-height: 1.15;
}
.page-header__subtitle {
  color: var(--gray-600); font-size: 14px; margin-top: 6px;
  max-width: 640px;
}
.page-header__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Sections com título editorial */
.section {
  display: flex; flex-direction: column; gap: 12px;
}
.section__header {
  display: flex; align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.section__actions { font-size: 13px; color: var(--gray-600); }

/* ---------------- Mobile toggle ---------------- */
.sidebar__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--gray-700);
}
.sidebar__toggle:hover { background: var(--gray-100); }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 260px;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__toggle { display: inline-flex; }
  .app-content { padding: 20px 16px 56px; }
  .app-header { padding: 0 16px; }
  .page-header__title { font-size: 22px; }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.4);
    z-index: 4;
    opacity: 0; pointer-events: none;
    transition: opacity var(--dur) var(--ease);
  }
  .sidebar-overlay.is-open { opacity: 1; pointer-events: auto; }
}
