/* =============================================================================
   Campus Attendance Bot — static demo page.

   Design tokens follow the project's React web chat (Apple
   developer-documentation look): dark nav bar, hairline separators, pill
   badges, Inter for chrome + Source Serif 4 for headings (both free fonts).
   ============================================================================= */

:root {
  color-scheme: light;

  --bg: #fbfbfd;
  --content-bg: #ffffff;
  --panel: #ffffff;
  --hairline: #d2d2d7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --surface-2: #f5f5f7;
  --hover: #f2f2f4;

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-contrast: #ffffff;
  --bubble-user-text: #ffffff;

  --input-bg: #ffffff;
  --input-border: #d2d2d7;
  --send-disabled: #e8e8ed;

  --topbar: #1d1d1f;
  --topbar-text: #f5f5f7;
  --topbar-muted: #a1a1a6;

  --bot-bubble: #f5f5f7;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.08);

  --font-sans: "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #000000;
  --content-bg: #000000;
  --panel: #1d1d1f;
  --hairline: #38383a;
  --text: #f5f5f7;
  --muted: #86868b;
  --surface-2: #1d1d1f;
  --hover: #2c2c2e;

  --accent: #0a84ff;
  --accent-hover: #1a8fff;
  --accent-contrast: #ffffff;
  --bubble-user-text: #ffffff;

  --input-bg: #1d1d1f;
  --input-border: #38383a;
  --send-disabled: #2c2c2e;

  --topbar: #1d1d1f;
  --topbar-text: #f5f5f7;
  --topbar-muted: #a1a1a6;

  --bot-bubble: #242426;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.2s ease;
}

button,
input {
  font: inherit;
}

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* --- top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 8px 20px;
  background: var(--topbar);
  color: var(--topbar-text);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 0;
  flex-wrap: wrap;
}

.brand-emoji {
  font-size: 1rem;
}

.chip {
  padding: 2px 9px;
  border: 1px solid #48484a;
  border-radius: 999px;
  color: var(--topbar-muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip-quiet {
  border-style: dashed;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.topnav-link {
  color: var(--topbar-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
}

.topnav-link:hover {
  color: var(--topbar-text);
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle {
  border: 1px solid #48484a;
  background: transparent;
  color: var(--topbar-text);
  border-radius: 8px;
  width: 34px;
  height: 30px;
  cursor: pointer;
  line-height: 1;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* --- layout --------------------------------------------------------------- */

.content {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  flex: 1;
  padding: 40px 0 56px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero-sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
  max-width: 46rem;
}

section {
  margin-bottom: 44px;
}

h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 0 0 14px;
}

.muted {
  color: var(--muted);
}

/* --- chat card ------------------------------------------------------------ */

.chat-card {
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: var(--content-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.chat-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-head-text .muted {
  font-size: 0.78rem;
}

.ghost-btn {
  border: 1px solid var(--input-border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-btn:hover {
  background: var(--hover);
}

.messages {
  height: 400px;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  border-bottom-left-radius: 5px;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 5px;
}

.msg-time {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  opacity: 0.62;
  text-align: right;
}

.msg-system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  max-width: 92%;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 2px 2px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.1s infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

/* --- quick replies + composer --------------------------------------------- */

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 2px;
}

.quick-chip {
  border: 1px solid var(--input-border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.8rem;
  cursor: pointer;
}

.quick-chip:hover {
  background: var(--hover);
  border-color: var(--accent);
  color: var(--accent);
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 16px 16px;
}

.composer input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  font-size: 0.92rem;
}

.composer input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.send-btn {
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 12px;
  padding: 0 22px;
  font-weight: 600;
  cursor: pointer;
}

.send-btn:hover {
  background: var(--accent-hover);
}

.send-btn:disabled {
  background: var(--send-disabled);
  color: var(--muted);
  cursor: default;
}

/* --- voice input ----------------------------------------------------------- */

.mic-btn {
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 0 15px;
  font-size: 1.05rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mic-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.mic-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mic-btn:disabled {
  color: var(--muted);
  cursor: default;
}

/* While recording: red, pulsing halo until the mic is stopped. */
.mic-btn.listening {
  border-color: transparent;
  background: #d21f3c;
  animation: mic-pulse 1.4s ease-out infinite;
}

:root[data-theme="dark"] .mic-btn.listening {
  background: #e5484d;
}

@keyframes mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(210, 31, 60, 0.45);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(210, 31, 60, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(210, 31, 60, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mic-btn.listening {
    animation: none;
  }
}

.speech-hint {
  margin: 0 16px;
  padding: 9px 13px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

/* --- login gate ----------------------------------------------------------- */

.login {
  padding: 26px 18px 22px;
  max-width: 540px;
  margin: 0 auto;
}

.login-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.login-emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  font-size: 1rem;
}

.login-head strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  margin-bottom: 3px;
}

.login-head p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.login-form label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.login-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 13px;
  outline: none;
  font-size: 0.92rem;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.login-submit {
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

.login-submit:hover {
  background: var(--accent-hover);
}

.login-error {
  margin: 0;
  color: #d21f3c;
  font-size: 0.84rem;
  line-height: 1.45;
}

:root[data-theme="dark"] .login-error {
  color: #ff6961;
}

.login-hint {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.login-hint code {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.92em;
}

/* --- info sections -------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--content-bg);
  padding: 18px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.card code,
.links code {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.82em;
}

.links {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.92rem;
  line-height: 1.55;
}

.links a {
  color: var(--accent);
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 0;
}

pre code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono",
    monospace;
}

.run .muted {
  font-size: 0.85rem;
  margin-top: -6px;
}

.footer {
  border-top: 1px solid var(--hairline);
  padding: 18px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 560px) {
  .content {
    width: calc(100% - 24px);
    padding-top: 24px;
  }

  .messages {
    height: 340px;
  }

  .msg {
    max-width: 88%;
  }

  .chip-quiet {
    display: none;
  }
}
