/* ── Portal-specific styles ── */

/* Tab navigation */
.portal-tabs {
  background: #F8F8F8;
  border-bottom: 1px solid #E0E0E0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.portal-tabs .container {
  display: flex;
  gap: 0;
  overflow-x: auto;
}

.tab {
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: var(--dark-grey);
  font-family: inherit;
  white-space: nowrap;
}

.tab:hover { color: var(--black); }
.tab.active {
  color: var(--black);
  border-bottom-color: var(--blue);
}

/* Form elements */
.form-input {
  display: block;
  width: 100%;
  max-width: 400px;
  padding: 10px 14px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid #E0E0E0;
  margin: 8px 0 16px;
}

.form-input:focus {
  outline: 2px solid var(--blue);
  border-color: var(--blue);
}

.form-error {
  color: #C62828;
  font-size: 14px;
  margin-top: 8px;
}

.form-error:empty { display: none; }

.form-hint {
  color: var(--dark-grey);
  font-size: 14px;
}

/* Consent document */
.consent-document {
  margin: 24px 0;
  padding: 32px;
  border: 1px solid #E0E0E0;
  max-height: 600px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
}
.consent-document h3 {
  text-align: center;
  margin: 0 0 4px;
  font-size: 16px;
}
.consent-document h4 {
  font-size: 15px;
  margin: 28px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #E0E0E0;
}
.consent-document ul {
  padding-left: 20px;
  margin: 8px 0;
}
.consent-document li {
  margin-bottom: 8px;
}
.consent-document p {
  margin: 8px 0;
}

/* Consent toggles */
.consent-toggles {
  border: 1px solid #E0E0E0;
  margin: 24px 0;
}
.consent-toggle-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
}
.consent-toggle-row + .consent-toggle-row {
  border-top: 1px solid #E0E0E0;
}
.consent-toggle-label {
  font-weight: 700;
  font-size: 15px;
}
.consent-toggle-hint {
  font-size: 13px;
  color: var(--dark-grey);
  margin-top: 2px;
}
.consent-toggle-row.disabled {
  opacity: 0.6;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 26px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: #2E7D32; }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* Survey */
.survey-section {
  margin-bottom: 40px;
  padding-bottom: 40px;
  border-bottom: 1px solid #E0E0E0;
}

.survey-section:last-child { border-bottom: none; }

.survey-section h3 {
  font-size: 24px;
  margin-bottom: 8px;
}

.survey-section .section-desc {
  color: var(--dark-grey);
  margin-bottom: 24px;
}

.survey-question {
  margin-bottom: 24px;
}

.survey-question label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.survey-question .question-text {
  margin-bottom: 12px;
}

/* Likert scale */
.likert-scale {
  display: flex;
  gap: 0;
  margin: 8px 0;
}

.likert-scale label {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  border: 1px solid #E0E0E0;
  margin-left: -1px;
}

.likert-scale label:first-child { margin-left: 0; }

.likert-scale input { display: none; }
.likert-scale input:checked + span {
  background: var(--blue);
  color: white;
}

.likert-scale label:has(input:checked) {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  z-index: 1;
}

.likert-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--dark-grey);
  margin-top: 4px;
}

/* Radio group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.radio-group input[type="radio"] { accent-color: var(--blue); }

/* Text input in surveys */
.survey-text {
  width: 100%;
  max-width: 600px;
  padding: 10px 14px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid #E0E0E0;
  min-height: 80px;
  resize: vertical;
}

.survey-text:focus {
  outline: 2px solid var(--blue);
  border-color: var(--blue);
}

/* Session list */
.session-project {
  margin-bottom: 8px;
  border: 1px solid #E0E0E0;
}

.session-project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: #F8F8F8;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.session-project-header::-webkit-details-marker { display: none; }

.session-project-header::before {
  content: "▶";
  font-size: 10px;
  margin-right: 10px;
  transition: transform 0.15s;
  color: var(--dark-grey);
}

details[open] > .session-project-header::before {
  transform: rotate(90deg);
}

.session-project-name {
  font-size: 15px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
  flex: 1;
}

.session-project-count {
  font-size: 13px;
  color: var(--dark-grey);
  font-weight: 400;
  margin-left: 12px;
  white-space: nowrap;
}

.session-project-body {
  border-top: 1px solid #E0E0E0;
}

.session-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #E0E0E0;
  font-size: 14px;
}

.session-revoked {
  opacity: 0.5;
}

.session-revoked .session-title {
  text-decoration: line-through;
}

.session-title {
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  color: var(--dark-grey);
  font-size: 13px;
}

/* Survey progress */
.survey-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0;
  padding: 16px 0;
  border-top: 1px solid #E0E0E0;
}

.survey-progress {
  font-size: 14px;
  color: var(--dark-grey);
}

/* Loading state */
.loading {
  color: var(--dark-grey);
  font-style: italic;
  padding: 24px 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: white;
  padding: 32px;
  max-width: 480px;
  width: 90%;
}

.modal h3 {
  font-size: 20px;
  margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 600px) {
  .likert-scale { flex-wrap: wrap; }
  .likert-scale label { flex: none; width: calc(100% / 4); }
  .consent-toggle-box { flex-wrap: wrap; }
  .tab { padding: 12px 16px; font-size: 12px; }
}

/* ── Insights tab ────────────────────────────────────────── */

.insights-block {
  margin: 28px 0;
  padding: 20px;
  background: #fafafa;
  border-left: 3px solid var(--dark-grey);
}

.insights-block h3 {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px;
  color: var(--dark-grey);
}

.insights-block h4 {
  font-size: 14px;
  margin: 12px 0 6px;
  color: #222;
}

.insights-about {
  background: #f4f4f4;
  border: 1px solid #e0e0e0;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 13px;
  color: #444;
}
.insights-about summary { cursor: pointer; font-weight: 600; }
.insights-about p { margin: 8px 0; }

.snapshot-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 13px;
}
.snapshot-selector select { padding: 4px 8px; font-size: 13px; }
.snapshot-selector .hint { color: #888; font-size: 12px; }

.at-a-glance .headline {
  font-size: 18px;
  line-height: 1.5;
  font-weight: 600;
  margin: 0 0 16px;
}
.at-a-glance .glance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.at-a-glance .glance-grid > div {
  background: white;
  padding: 12px;
  border: 1px solid #e0e0e0;
}
.at-a-glance h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--dark-grey);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.at-a-glance .glance-grid p { margin: 0; font-size: 13px; line-height: 1.5; }

.top-stats .stat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.top-stats .stat {
  text-align: center;
  background: white;
  padding: 12px 4px;
  border: 1px solid #e0e0e0;
}
.top-stats .num {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: #222;
}
.top-stats .lbl {
  display: block;
  font-size: 11px;
  color: var(--dark-grey);
  margin-top: 4px;
  line-height: 1.3;
}

.weekly .chart { width: 100%; height: auto; background: white; border: 1px solid #e0e0e0; }
.weekly .legend { margin-top: 8px; font-size: 12px; display: flex; gap: 16px; }
.weekly .legend i { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: middle; }

.perception .perception-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.perception .perception-grid > div { background: white; padding: 12px; border: 1px solid #e0e0e0; }
.perception .perception-grid h4 { font-size: 12px; color: var(--dark-grey); text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 6px; }
.perception .perception-grid p { margin: 0; font-size: 13px; line-height: 1.5; }

.interaction-style .badge {
  display: inline-block;
  background: #222;
  color: white;
  padding: 3px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px;
}
.interaction-style .narrative p { margin: 0 0 10px; line-height: 1.6; }

.project-areas ul, .what-worked ul, .friction-cat ul { padding-left: 18px; }
.project-areas li, .what-worked li { margin-bottom: 10px; line-height: 1.5; }

.friction-cat {
  background: white;
  padding: 12px;
  border: 1px solid #e0e0e0;
  margin: 10px 0;
}
.friction-cat h4 { margin: 0 0 6px; font-size: 14px; color: #222; }

.things-to-try .try-card {
  background: white;
  border: 1px solid #e0e0e0;
  padding: 14px;
  margin: 12px 0;
}
.things-to-try .try-card h4 { margin: 0 0 8px; font-size: 15px; }
.things-to-try .try-card p { margin: 4px 0; font-size: 13px; line-height: 1.5; }
.things-to-try .copyable {
  margin-top: 8px;
  position: relative;
}
.things-to-try .copyable pre {
  background: #1e1e1e;
  color: #e0e0e0;
  padding: 10px 12px;
  font-size: 12px;
  font-family: 'SFMono-Regular', Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.things-to-try .copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #444;
  color: white;
  border: none;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
}
.things-to-try .copy-btn:hover { background: #666; }

.dim-table { width: 100%; border-collapse: collapse; font-size: 13px; background: white; }
.dim-table th, .dim-table td { padding: 8px 10px; border-bottom: 1px solid #e0e0e0; text-align: left; }
.dim-table th { background: #f0f0f0; font-weight: 600; }

.cohort-context .hint { font-size: 12px; color: #888; }

.snapshot-meta {
  font-size: 11px;
  color: #888;
  text-align: right;
  margin: 24px 0 0;
}

@media (max-width: 600px) {
  .at-a-glance .glance-grid { grid-template-columns: 1fr; }
  .perception .perception-grid { grid-template-columns: 1fr; }
  .top-stats .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .top-stats .num { font-size: 20px; }
}

/* ── Course tab ────────────────────────────────────────── */

.course-header h3 { font-size: 20px; margin: 0 0 20px; }
.course-header .hint { font-size: 12px; color: #888; font-weight: 400; }

.student-card {
  background: white;
  border: 1px solid #e0e0e0;
  margin: 10px 0;
}
.student-card summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.student-card summary .hint {
  font-weight: 400;
  color: #888;
  font-size: 12px;
  margin-left: 8px;
}
.student-card[open] summary { border-bottom: 1px solid #e0e0e0; background: #fafafa; }
.student-card-body { padding: 16px; }
.student-card-body .headline { font-size: 15px; font-weight: 600; line-height: 1.5; margin: 0 0 12px; }
.student-card-body .glance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.student-card-body .glance-grid > div {
  background: #fafafa;
  padding: 10px;
  border: 1px solid #e0e0e0;
}
.student-card-body .glance-grid h4 {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--dark-grey);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.student-card-body .glance-grid p { margin: 0; font-size: 12px; line-height: 1.5; }
.student-card-body .insights-block { background: #fafafa; }

@media (max-width: 600px) {
  .student-card-body .glance-grid { grid-template-columns: 1fr; }
}

.student-card.shadow summary { background: #f5f0e8; }
.shadow-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #8a7a4a;
  color: white;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}
