/**
 * Cognifiy authenticated application shell
 */

.cg-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  background: transparent;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}

.cg-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-primary);
  border-right: 1px solid var(--border-subtle);
  padding: 0 12px 12px;
  z-index: var(--z-sticky);
}

.cg-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 72px;
  padding: 24px 8px 0;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.cg-sidebar__brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gradient-brand);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

.cg-sidebar__brand-text {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.cg-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: auto;
  padding-bottom: 12px;
}

.cg-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font-size: var(--font-base);
  font-weight: 500;
  transition: background var(--motion-base) var(--ease), color var(--motion-base) var(--ease);
}

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

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

.cg-nav-item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.cg-sidebar__section {
  margin-top: 16px;
  margin-bottom: 6px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.cg-sidebar__footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.cg-sidebar__footer .cg-dropdown {
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  top: auto;
  width: 100%;
}

.cg-sidebar__profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: background var(--motion-base) var(--ease);
}
.cg-sidebar__profile:hover { background: var(--surface-hover); }

.cg-sidebar__profile-meta { min-width: 0; flex: 1; }
.cg-sidebar__profile-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cg-sidebar__profile-sub {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}
.cg-sidebar__chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.cg-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.cg-content {
  flex: 1;
  padding: var(--page-pad-y) var(--page-pad) 40px;
  width: min(var(--content-max), 100%);
  margin: 0 auto;
}

.cg-content--narrow { width: min(var(--content-form), 100%); }
.cg-content--dashboard { width: min(var(--content-dashboard), 100%); }
.cg-content--readiness { width: min(var(--content-readiness), 100%); }
.cg-content--workspace { width: min(var(--content-workspace), 100%); }

.cg-mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: var(--surface-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.cg-mobile-header__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.cg-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-bottom-nav);
  height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-primary);
  border-top: 1px solid var(--border-subtle);
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
}

.cg-bottom-nav__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-tertiary);
  font-size: 10.5px;
  font-weight: 500;
}
.cg-bottom-nav__item svg { width: 20px; height: 20px; }
.cg-bottom-nav__item.is-active { color: var(--primary); }
.cg-bottom-nav__item.is-active::before {
  content: "";
  position: absolute;
  top: 2px;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
}

.cg-mobile-drawer-backdrop { display: none; }

@media (max-width: 768px) {
  .cg-app { grid-template-columns: 1fr; }

  .cg-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 86vw);
    transform: translateX(-105%);
    transition: transform var(--motion-panel) var(--ease);
    box-shadow: var(--shadow-modal);
    z-index: var(--z-drawer);
  }
  .cg-sidebar.is-open { transform: translateX(0); }

  .cg-mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-drawer-overlay);
    background: var(--overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--motion-panel) var(--ease), visibility var(--motion-panel) var(--ease);
  }
  .cg-mobile-drawer-backdrop.is-open {
    opacity: 1;
    visibility: visible;
  }

  .cg-mobile-header { display: flex; }
  .cg-bottom-nav { display: grid; }
  .cg-content {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }
}

/* Public auth chrome */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--surface-primary) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-desktop-menu { display: flex; gap: 8px; }
.nav-mobile-menu { display: none; }
.nav-links { display: none; }

.auth-grid {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 74px);
  padding: 32px 16px 48px;
}
.auth-card {
  width: min(var(--content-auth), 100%);
  padding: 28px 28px 24px;
  background: var(--surface-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card-lg);
}
.auth-card .h1 { margin-bottom: 8px; }
.auth-card .p { margin-bottom: 20px; }

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field .input {
  width: 100%;
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control, 8px);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--text-primary);
  background: var(--surface-secondary, rgba(0, 0, 0, 0.04));
  outline: none;
}
.password-toggle__icon {
  width: 20px;
  height: 20px;
}
.password-toggle__icon--hide { display: none; }
.password-toggle.is-visible .password-toggle__icon--show { display: none; }
.password-toggle.is-visible .password-toggle__icon--hide { display: block; }

@media (max-width: 760px) {
  .nav-desktop-menu { display: none; }
  .nav-mobile-menu {
    display: none;
    position: absolute;
    right: 16px;
    top: 64px;
    background: var(--surface-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-dropdown);
    padding: 8px;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-dropdown);
  }
  .nav-mobile-menu.is-open { display: flex; }
}
