/* ── App layout ── */

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

/* ── Sidebar ── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.sidebar-title {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-subtitle {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.sidebar-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 0.75rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.sidebar-nav a:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.sidebar-nav a.active {
  background: var(--color-bg-hover);
  color: var(--color-text);
  font-weight: 600;
}

.sidebar-nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.375rem;
  bottom: 0.375rem;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--color-accent);
}

.sidebar-nav a svg {
  opacity: 0.6;
  flex-shrink: 0;
}

.sidebar-nav a:hover svg,
.sidebar-nav a.active svg {
  opacity: 0.9;
}

.sidebar-footer {
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.sidebar-footer .sign-out-link {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-left: auto;
  transition: color var(--transition-fast);
}

.sidebar-footer .sign-out-link:hover {
  color: var(--color-text);
}

/* ── Sidebar Student Profile ── */
.sidebar-profile {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
}

.sidebar-profile-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.sidebar-profile-link:hover {
  background: var(--color-bg-hover);
  color: inherit;
}

.sidebar-profile-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-profile-photo-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.sidebar-profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.sidebar-profile-name {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-profile-meta {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-profile-tier {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.0625rem 0.4375rem;
  border-radius: 9999px;
  font-size: 0.5625rem;
  font-weight: 600;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  margin-top: 0.0625rem;
  line-height: 1.4;
}

.sidebar-profile-usage {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.625rem;
  padding: 0 0.5rem;
}

.sidebar-profile-usage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.125rem 0.5rem;
  align-items: center;
}

.sidebar-profile-usage-label {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.sidebar-profile-usage-count {
  font-size: 0.625rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.sidebar-profile-usage-row .progress-bar-track {
  grid-column: 1 / -1;
}

.progress-bar-track--xs {
  height: 3px;
}

/* ── Main content ── */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 0.75rem 2rem;
  /* vertical padding for breathing room */
  min-height: 3.5rem;
  /* replace fixed height with min-height */
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  /* keeps items vertically centered */
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  background: rgba(247, 247, 245, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  will-change: backdrop-filter;
  gap: 0.75rem;
  /* adds space between heading and right group */
  flex-wrap: wrap;
  /* allows items to wrap on narrow screens */
}

.topbar h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.4;
  /* better readability for wrapped lines */
  word-break: break-word;
  /* prevents overflow from long words */
  flex: 1;
  /* allows heading to take available space */
  min-width: 0;
  /* prevents flex overflow */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-content {
  padding: 1.75rem 2rem 2.5rem;
  flex: 1;
  min-width: 0;
}

.page-content::after {
  content: "";
  display: block;
  height: var(--keyboard-inset, 0px);
}

/* =============================================================
   Survey layout (l-survey)
   Used by student & parent intake surveys — no sidebar, no topbar.
   ============================================================= */

.l-survey {
  background: var(--color-bg, #f8f9fa);
  color: var(--color-text, #111827);
  min-height: 100vh;
}

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

.survey-header {
  background: #ffffff;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  padding: 16px 24px;
}

.survey-header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.survey-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-primary, #2563eb);
}

.survey-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.survey-logo-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-text, #111827);
}

.survey-logo-subtitle {
  font-size: 11px;
  color: var(--color-text-muted, #6b7280);
  letter-spacing: 0.02em;
}

.survey-sign-out {
  font-size: 13px;
  color: var(--color-text-muted, #6b7280);
  text-decoration: none;
}
.survey-sign-out:hover {
  color: var(--color-text, #111827);
  text-decoration: underline;
}

.survey-content {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.survey-footer {
  border-top: 1px solid var(--color-border, #e5e7eb);
  padding: 16px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted, #6b7280);
  background: #ffffff;
}

@media (max-width: 640px) {
  .survey-header { padding: 12px 16px; }
  .survey-content { padding: 24px 16px 32px; }
}