/*
 * Design tokens. Bootstrap 5 reads --bs-* variables at runtime, so overriding a handful here
 * re-themes every component without a build step or a forked stylesheet. Keep app-specific rules
 * below the token block, and prefer Bootstrap utilities over new CSS.
 */
:root {
  --mgtcc-brand: #3d3a8c;          /* NCU 校色系的深紫藍 */
  --mgtcc-brand-dark: #2c2a66;
  --bs-primary: var(--mgtcc-brand);
  --bs-primary-rgb: 61, 58, 140;
  --bs-link-color: var(--mgtcc-brand);
  --bs-link-hover-color: var(--mgtcc-brand-dark);
  --bs-border-radius: 0.625rem;
  --bs-border-radius-sm: 0.375rem;
  --bs-border-radius-lg: 0.875rem;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC",
    "Microsoft JhengHei", "PingFang TC", sans-serif;
  --bs-body-bg: #f6f6f9;
}

[data-bs-theme="dark"] {
  --mgtcc-brand: #9a96ef;
  --mgtcc-brand-dark: #b7b4f5;
  --bs-primary: var(--mgtcc-brand);
  --bs-primary-rgb: 154, 150, 239;
  --bs-body-bg: #16161d;
}

html {
  font-size: 16px;
}

/* Bootstrap derives button colours from its own compiled values, so point them at the token. */
.btn-primary {
  --bs-btn-bg: var(--mgtcc-brand);
  --bs-btn-border-color: var(--mgtcc-brand);
  --bs-btn-hover-bg: var(--mgtcc-brand-dark);
  --bs-btn-hover-border-color: var(--mgtcc-brand-dark);
  --bs-btn-active-bg: var(--mgtcc-brand-dark);
  --bs-btn-active-border-color: var(--mgtcc-brand-dark);
  --bs-btn-disabled-bg: var(--mgtcc-brand);
  --bs-btn-disabled-border-color: var(--mgtcc-brand);
}

.btn-outline-primary {
  --bs-btn-color: var(--mgtcc-brand);
  --bs-btn-border-color: var(--mgtcc-brand);
  --bs-btn-hover-bg: var(--mgtcc-brand);
  --bs-btn-hover-border-color: var(--mgtcc-brand);
  --bs-btn-active-bg: var(--mgtcc-brand);
  --bs-btn-active-border-color: var(--mgtcc-brand);
}

/* Cards carry the page instead of borders: quiet surface, no heavy outline. */
.card {
  --bs-card-border-color: transparent;
  box-shadow: 0 1px 2px rgba(16, 16, 32, 0.06), 0 1px 12px rgba(16, 16, 32, 0.04);
}

/* Table headers read as labels, not as another row of data. */
.table > thead {
  --bs-table-color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  text-transform: none;
  letter-spacing: 0.02em;
}

/* Comfortable tap targets on phones. */
.btn {
  min-height: 2.5rem;
}

.btn-sm {
  min-height: 2rem;
}

/* Bootstrap's alert padding would still show an empty validation summary. */
.validation-summary-valid {
  display: none;
}

.validation-summary-errors ul {
  margin-bottom: 0;
  padding-left: 1.25rem;
}

.auth-card {
  max-width: 28rem;
  margin: 2rem auto;
}

/* Page width: wide enough for the roster table, never edge-to-edge on a monitor. */
.page-narrow {
  max-width: 44rem;
  margin-inline: auto;
}

/* Admin nav: the active section is marked by weight and a bar, not a filled pill. */
.admin-nav .nav-link {
  color: var(--bs-body-color);
  border-bottom: 2px solid transparent;
  padding-inline: 0.75rem;
}

.admin-nav .nav-link:hover {
  color: var(--mgtcc-brand);
}

.admin-nav .nav-link.active {
  color: var(--mgtcc-brand);
  font-weight: 600;
  border-bottom-color: var(--mgtcc-brand);
}

/* Dashboard tiles. */
.stat-value {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
}

/* Queue console: while an action is in flight the board stops responding to clicks, so a second
   press can't act on a row the incoming snapshot is about to move. */
.queue-busy .queue-board {
  opacity: 0.6;
  pointer-events: none;
}

/* Waiting-area screen. Sized for a TV across the room: no pointer, no chrome, huge numbers. */
.kiosk {
  cursor: none;
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 3rem);
  background: var(--bs-body-bg);
}

.kiosk-grid {
  display: grid;
  gap: clamp(1rem, 3vh, 2.5rem);
}

.kiosk-heading {
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  letter-spacing: 0.1em;
}

.kiosk-calling {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1rem, 2vw, 2rem);
}

.kiosk-card {
  flex: 1 1 14rem;
  padding: clamp(1rem, 2vw, 2rem);
  border-radius: var(--bs-border-radius-xl);
  background: var(--bs-danger);
  color: #fff;
  text-align: center;
}

.kiosk-number {
  font-size: clamp(4rem, 14vw, 11rem);
  font-weight: 700;
  line-height: 1;
}

.kiosk-name {
  font-size: clamp(1.25rem, 3vw, 2.5rem);
}

.kiosk-idle {
  font-size: clamp(2rem, 6vw, 4rem);
  color: var(--bs-secondary-color);
}

.kiosk-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: clamp(1rem, 3vw, 3rem);
}

.kiosk-ready {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: clamp(1.5rem, 4vw, 3rem);
}

.kiosk-chip {
  padding: 0.1em 0.5em;
  border-radius: var(--bs-border-radius-lg);
  background: var(--bs-warning);
  color: #000;
  font-weight: 700;
}

.kiosk-count {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 700;
}

/* One flash when a new number is called, for anyone who can't hear the chime. */
.kiosk-flash {
  animation: kiosk-flash 1.2s ease-out 2;
}

@keyframes kiosk-flash {
  0%, 100% { background-color: var(--bs-body-bg); }
  30% { background-color: color-mix(in srgb, var(--bs-danger) 35%, var(--bs-body-bg)); }
}

@media (prefers-reduced-motion: reduce) {
  .kiosk-flash { animation: none; }
}

/* Question bodies authored in TinyMCE, rendered raw after Services/QuestionHtml.cs has cleaned
   them. Bootstrap resets most of this away, so the tags the editor produces need styling back. */
.rich-text > :last-child {
  margin-bottom: 0;
}

.rich-text p {
  margin-bottom: 0.75rem;
}

.rich-text ul,
.rich-text ol {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}

.rich-text h3,
.rich-text h4,
.rich-text h5,
.rich-text h6 {
  font-size: 1.05rem;
  font-weight: 600;
}

.rich-text blockquote {
  margin: 0 0 0.75rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--bs-border-color);
  color: var(--bs-secondary-color);
}

.rich-text pre {
  padding: 0.5rem 0.75rem;
  border-radius: var(--bs-border-radius);
  background: var(--bs-tertiary-bg);
  white-space: pre-wrap;
}

.rich-text table {
  width: auto;
  margin-bottom: 0.75rem;
  border-collapse: collapse;
}

.rich-text th,
.rich-text td {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--bs-border-color);
}

/* In a card header the question shares a flex row with the score badge: no stray block margins. */
.rich-text-tight p,
.rich-text-tight ul,
.rich-text-tight ol {
  margin-bottom: 0;
}

/* An uploaded picture is whatever size the author's camera made it: never let it set the width
   of the exam page or of a grading card. */
.rich-text img {
  max-width: 100%;
  height: auto;
}

.rich-text figure {
  margin: 0 0 0.75rem;
}

.rich-text figcaption {
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
}
