/* Shared visual language for the authenticated HaiEdu workspaces. */
:root {
  --hm-bg: #f5f9ff;
  --hm-surface: #fff;
  --hm-soft: #eaf2fd;
  --hm-text: #202c40;
  --hm-muted: #5e708a;
  --hm-line: #d7e3f3;
  --hm-blue: #244f88;
  --hm-warm: #fff7e7;
  --hm-sidebar-width: 232px;
}
body { background: var(--hm-bg); color: var(--hm-text); }
body .card { background: var(--hm-surface); border-color: var(--hm-line); border-radius: 14px; box-shadow: 0 9px 27px #203a5910; }
body .subtle, body .page-lede { color: var(--hm-muted); }
body .eyebrow, body .mode-kicker, body .panel-kicker { color: var(--hm-blue); letter-spacing: .055em; }
body button:not(.ghost):not(.secondary):not(.danger-btn), body .button-link:not(.ghost):not(.secondary) { border-radius: 10px; }
body a:focus-visible, body button:focus-visible, body input:focus-visible, body select:focus-visible { outline: 3px solid #8db7ed; outline-offset: 2px; }

/* Final cross-workspace text contract: Armenian copy wraps at word boundaries. */
body :is(h1, h2, h3, p, li, dt, dd, label, legend),
body :is(button, a.button-link, a.ghost),
body :is(.subtle, .page-lede, .message, .feedback, .feedback-banner, .status-badge, .amp-status-badge, .pill, .mode-kicker),
body :is([class$="-card"], [class*="-card "], [class$="-label"], [class*="-label "]) {
  overflow-wrap: break-word;
  word-break: normal;
}

/* Only technical tokens may split without a natural word boundary. */
body :is(code, pre, .code-field, .item-code, .skill-code, .invite-email, .roster-email, [data-technical-token]),
body a[href^="http"],
body a[href^="mailto:"] {
  overflow-wrap: anywhere;
  word-break: normal;
}

/* The existing student navigation supplies enrolled classes and permitted links. */
body.amp-student-shell-active .amp-side-nav {
  background: var(--hm-surface); color: var(--hm-text);
  border-right: 1px solid var(--hm-line); box-shadow: 3px 0 18px #203a590a;
}
body.amp-student-shell-active .amp-nav-brand { border-bottom-color: var(--hm-line); }
body.amp-student-shell-active .amp-brand-link { background: transparent; box-shadow: none; padding-left: 0; }
body.amp-student-shell-active .amp-brand-link:focus-visible { outline-color: #8db7ed; }
body.amp-student-shell-active .amp-nav-brand span { color: var(--hm-muted); }
body.amp-student-shell-active .amp-nav-link { color: var(--hm-muted); }
body.amp-student-shell-active .amp-nav-link:hover { background: var(--hm-bg); color: var(--hm-blue); }
body.amp-student-shell-active .amp-nav-link[aria-current="page"] { background: var(--hm-soft); color: var(--hm-blue); box-shadow: none; }
body.amp-student-shell-active .amp-nav-disabled:hover { color: var(--hm-muted); background: transparent; }
body.amp-student-shell-active .amp-nav-section-label { color: var(--hm-muted); }
body.amp-student-shell-active .amp-course-sublink {
  color: #46607c;
  font-weight: 600;
}
body.amp-student-shell-active .amp-course-sublink:hover {
  color: var(--hm-blue);
  background: var(--hm-bg);
}
body.amp-student-shell-active .amp-course-sublink[aria-current="page"] {
  color: var(--hm-blue);
  background: var(--hm-soft);
  font-weight: 750;
}
body.amp-student-shell-active .amp-nav-utility { border-top-color: var(--hm-line); }
body.amp-student-shell-active .amp-nav-utility a { color: var(--hm-blue); }
body.amp-student-shell-active .topbar {
  background: var(--hm-surface); border: 1px solid var(--hm-line);
  border-radius: 13px; padding: 18px 22px; margin-bottom: 20px;
}
body.amp-student-shell-active .recommendation-card { background: var(--hm-surface); border-color: #bdcfe6; }
body.amp-student-shell-active .mode-kicker { background: var(--hm-soft); color: var(--hm-blue); }

/* Staff navigation is created only after the page's existing authorization check. */
.hm-role-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--hm-sidebar-width); padding: 25px 14px 18px;
  display: flex; flex-direction: column; gap: 16px;
  background: var(--hm-surface); border-right: 1px solid var(--hm-line);
  box-shadow: 3px 0 18px #203a590a;
}
.hm-role-brand { display: block; padding: 0 10px 22px; border-bottom: 1px solid var(--hm-line); }
.hm-role-brand img { display: block; width: min(100%, 162px); height: auto; }
.hm-workspace-label { color: var(--hm-muted); font-size: .74rem; font-weight: 700; letter-spacing: .08em; margin: 2px 10px 0; }
.hm-role-nav { display: grid; gap: 4px; }
.hm-role-nav a {
  display: block; padding: 11px 12px; border-radius: 9px;
  color: var(--hm-muted); text-decoration: none; font-weight: 650; line-height: 1.3;
}
.hm-role-nav a:hover { color: var(--hm-blue); background: var(--hm-bg); }
.hm-role-nav a[aria-current="page"] { color: var(--hm-blue); background: var(--hm-soft); }
.hm-role-foot { margin-top: auto; padding: 16px 10px 2px; border-top: 1px solid var(--hm-line); display: grid; gap: 12px; }
.hm-role-foot span { color: var(--hm-muted); font-size: .8rem; }
.hm-role-foot a { color: var(--hm-blue); font-weight: 600; }
.hm-sidebar-signout { width: 100%; text-align: left; color: #7b4350 !important; border-color: #dfc3c8 !important; }
.school-admin-page.hm-has-role-sidebar .school-admin-header #signOutBtn { display: none !important; }
body[data-role-workspace^="content"] .content-topbar #signOutBtn,
body[data-role-workspace^="content"] .guide-topbar #signOutBtn {
  display: none !important;
}
.hm-role-chip {
  display: inline-block; align-self: flex-start; white-space: nowrap;
  padding: 7px 11px; border: 1px solid var(--hm-line);
  border-radius: 999px; color: var(--hm-blue); background: var(--hm-soft);
  font-size: .84rem; font-weight: 700;
}
body.hm-has-role-sidebar > main { box-sizing: border-box; width: auto; max-width: none; margin: 0 0 0 var(--hm-sidebar-width); padding: 24px clamp(16px,3vw,42px) 48px; min-width: 0; container-type: inline-size; container-name: hm-workspace; }
body.amp-student-shell-active > main { container-type: inline-size; container-name: hm-student-workspace; }
body.hm-has-role-sidebar .teacher-topbar,
body.hm-has-role-sidebar .school-admin-header,
body.hm-has-role-sidebar .admin-topbar,
body.hm-has-role-sidebar .content-topbar,
body.hm-has-role-sidebar .guide-topbar {
  background: var(--hm-surface); border: 1px solid var(--hm-line);
  border-radius: 14px; padding: 20px 24px; margin: 0 0 20px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
}
body.hm-has-role-sidebar .teacher-topbar h1,
body.hm-has-role-sidebar .school-admin-header h1,
body.hm-has-role-sidebar .admin-topbar h1,
body.hm-has-role-sidebar .content-topbar h1,
body.hm-has-role-sidebar .guide-topbar h1 { font-size: clamp(1.8rem,2.5vw,2.8rem); line-height: 1.15; }
body.hm-has-role-sidebar .teacher-welcome-card { background: var(--hm-surface); border-color: var(--hm-line); }
body.hm-has-role-sidebar .admin-panel,
body.hm-has-role-sidebar .admin-card,
body.hm-has-role-sidebar .curriculum-card,
body.hm-has-role-sidebar .bank-card { border-color: var(--hm-line); }
body.hm-has-role-sidebar .quality-layout { grid-template-columns: minmax(0,1fr); }
body.hm-has-role-sidebar .quality-layout .table-wrap { overflow-x: auto; }
body.hm-has-role-sidebar .quality-layout .detail-panel { position: static; max-height: none; }

/* Container queries respond to the usable dashboard width after sidebars, not only the viewport. */
@container hm-workspace (max-width: 70rem) {
  .teacher-onboarding-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matrix-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quality-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .class-header-card,
  .admin-overview-grid { grid-template-columns: 1fr; }
}

@container hm-workspace (max-width: 44rem) {
  .teacher-onboarding-steps,
  .teacher-profile-card,
  .teacher-create-card,
  .teacher-profile-form,
  .teacher-create-form,
  .overview-stats,
  .admin-stats { grid-template-columns: 1fr; }
  .matrix-summary-grid,
  .quality-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container hm-student-workspace (max-width: 48rem) {
  .dashboard-summary,
  .dashboard-row,
  .mode-grid,
  .skill-map { grid-template-columns: 1fr; }
  .dashboard-heading,
  .recommendation-card,
  .skill-map-heading { align-items: stretch; flex-direction: column; }
}

@media (min-width: 1840px) {
  body.hm-has-role-sidebar .quality-layout { grid-template-columns: minmax(720px,1.2fr) minmax(620px,1fr); }
}
@media (max-width: 1100px) {
  .hm-role-sidebar { position: static; width: auto; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--hm-line); flex-direction: row; align-items: center; }
  .hm-role-brand { border: 0; padding: 0; }
  .hm-role-brand img { width: 120px; }
  .hm-workspace-label { display: none; }
  .hm-role-nav { display: flex; overflow-x: auto; white-space: nowrap; min-width: 0; }
  .hm-role-nav a { flex: 0 0 auto; }
  .hm-role-foot { margin: 0; padding: 0; border: 0; flex: 0 0 auto; }
  .hm-role-foot > span, .hm-role-foot > a { display: none; }
  .hm-sidebar-signout { width: auto; text-align: center; }
  body.hm-has-role-sidebar > main { margin: 0; padding: 16px 18px 32px; }
  body.hm-has-role-sidebar .teacher-topbar,
  body.hm-has-role-sidebar .school-admin-header,
  body.hm-has-role-sidebar .admin-topbar,
  body.hm-has-role-sidebar .content-topbar,
  body.hm-has-role-sidebar .guide-topbar { flex-wrap: wrap; padding: 17px; }
}
@media (max-width: 560px) {
  body.hm-has-role-sidebar > main { padding: 12px; }
  .hm-role-sidebar { padding: 12px; gap: 8px; }
  body.amp-student-shell-active .topbar { padding: 15px; }
}


/* Stable authenticated workspace shell while role/data checks are running. */
.hm-role-sidebar-loading{pointer-events:none}
.hm-loading-nav{display:grid;gap:10px;padding:0 10px}
.hm-loading-nav span,
.hm-loading-card::before,
.hm-loading-card span{display:block;border-radius:8px;background:linear-gradient(90deg,#edf2f8 25%,#f8fbff 50%,#edf2f8 75%);background-size:220% 100%;animation:hm-loading-shimmer 1.15s linear infinite}
.hm-loading-nav span{height:38px}
.hm-loading-nav span:nth-child(2){width:86%}.hm-loading-nav span:nth-child(3){width:92%}.hm-loading-nav span:nth-child(4){width:78%}.hm-loading-nav span:nth-child(5){width:84%}
.hm-workspace-loading{display:grid;gap:14px;margin:0 0 20px}
.hm-loading-card{min-height:124px;padding:20px;border:1px solid var(--hm-line);border-radius:14px;background:var(--hm-surface);box-shadow:0 9px 27px #203a5910}
.hm-loading-card-wide{min-height:150px}
.hm-loading-card-wide span{height:14px;margin:10px 0}
.hm-loading-card-wide span:first-child{width:32%;height:20px}.hm-loading-card-wide span:nth-child(2){width:68%}.hm-loading-card-wide span:nth-child(3){width:54%}
.hm-loading-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.hm-loading-grid .hm-loading-card{min-height:112px}.hm-loading-grid .hm-loading-card::before{content:"";height:100%;min-height:72px}
@keyframes hm-loading-shimmer{0%{background-position:200% 0}100%{background-position:-20% 0}}
@media (prefers-reduced-motion:reduce){.hm-loading-nav span,.hm-loading-card::before,.hm-loading-card span{animation:none}}
@media(max-width:760px){.hm-loading-grid{grid-template-columns:1fr}}
