/* =========================================================================
   Smart Communication and Response System — Design tokens
   Concept: a campus notice board. Pinned index cards, a brass-stamp accent,
   and a deep chalkboard-green field instead of the generic cream/terracotta
   AI-app look. Chat replies read like index cards pinned to a corkboard.
   ========================================================================= */

:root {
  --ink: #1f2d24;          /* chalkboard green-black — primary dark */
  --ink-soft: #2c3d31;
  --parchment: #f4efe3;    /* warm paper background */
  --parchment-dim: #ece4d2;
  --card: #fffdf7;         /* index-card white */
  --gold: #c9a227;         /* brass stamp accent */
  --gold-dim: #e7cf87;
  --brick: #a63d2f;        /* alerts / errors */
  --sage: #7c9070;         /* muted secondary green */
  --ink-40: rgba(31, 45, 36, 0.4);
  --ink-15: rgba(31, 45, 36, 0.15);

  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;

  --radius: 6px;
  --shadow-pin: 0 3px 0 rgba(31,45,36,0.08), 0 8px 20px rgba(31,45,36,0.12);
}

@font-face {
  font-family: "Fraunces";
  src: local("Georgia");
  font-weight: 400 700;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    linear-gradient(var(--parchment-dim) 1px, transparent 1px),
    linear-gradient(90deg, var(--parchment-dim) 1px, transparent 1px);
  background-size: 32px 32px;
  background-attachment: fixed;
}

a { color: var(--ink); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0 0 0.4em 0;
  letter-spacing: -0.01em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage);
  display: block;
  margin-bottom: 0.5em;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--ink);
  color: var(--parchment);
  border-bottom: 4px solid var(--gold);
}

.topbar .brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .brand .stamp {
  width: 30px; height: 30px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--gold);
  transform: rotate(-8deg);
}

.topbar nav { display: flex; gap: 20px; align-items: center; }
.topbar nav a {
  color: var(--parchment);
  text-decoration: none;
  font-size: 0.92rem;
  opacity: 0.85;
  border-bottom: 2px solid transparent;
  padding-bottom: 3px;
}
.topbar nav a:hover, .topbar nav a.active { opacity: 1; border-color: var(--gold); }

.topbar .user-chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--gold-dim);
}

/* ---------- Layout shells ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }
.center-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ---------- Index card (the signature element) ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pin);
  padding: 28px 30px;
  position: relative;
}

.card::before {
  /* the "pin" */
  content: "";
  position: absolute;
  top: -7px;
  left: 26px;
  width: 14px; height: 14px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.card.no-pin::before { display: none; }

.auth-card { width: 100%; max-width: 400px; }

/* ---------- Forms ---------- */
label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-40);
  margin: 16px 0 6px;
}
label:first-of-type { margin-top: 0; }

input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--ink-15);
  border-radius: 4px;
  background: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,162,39,0.2);
}

button, .btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 11px 22px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  background: var(--ink);
  color: var(--parchment);
  transition: transform 0.08s ease, background 0.15s ease;
}
button:hover, .btn:hover { background: var(--ink-soft); }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #b8931f; }
.btn-block { width: 100%; margin-top: 18px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink-15); }

.error-msg {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--brick);
  margin-top: 12px;
  min-height: 1.2em;
}
.hint { font-size: 0.85rem; color: var(--ink-40); margin-top: 14px; text-align: center; }
.hint a { color: var(--brick); text-decoration: none; font-weight: 600; }

/* ---------- Dashboard tiles ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
  margin-top: 28px;
}
.tile {
  display: block;
  text-decoration: none;
  color: var(--ink);
}
.tile .card { transition: transform 0.15s ease, box-shadow 0.15s ease; height: 100%; }
.tile:hover .card { transform: translateY(-3px) rotate(-0.4deg); box-shadow: 0 6px 0 rgba(31,45,36,0.08), 0 14px 26px rgba(31,45,36,0.16); }
.tile .icon { font-size: 1.6rem; margin-bottom: 10px; display: block; }
.tile h3 { font-size: 1.05rem; }
.tile p { margin: 0; color: var(--ink-40); font-size: 0.88rem; }

/* ---------- Chat ---------- */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 88px);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}
.msg { max-width: 78%; }
.msg-user { align-self: flex-end; }
.msg-bot { align-self: flex-start; }

.msg-user .bubble {
  background: var(--ink);
  color: var(--parchment);
  padding: 12px 16px;
  border-radius: 12px 12px 2px 12px;
}
.msg-bot .bubble {
  background: var(--card);
  box-shadow: var(--shadow-pin);
  padding: 14px 18px;
  border-radius: 2px 12px 12px 12px;
  position: relative;
}
.msg-bot .bubble::before {
  content: "";
  position: absolute;
  top: -6px; left: 16px;
  width: 11px; height: 11px;
  background: var(--gold);
  border-radius: 50%;
}
.msg-source {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sage);
  margin-top: 6px;
  display: block;
}

.chat-input-bar {
  border-top: 2px solid var(--ink-15);
  background: var(--parchment-dim);
  padding: 16px 24px;
}
.chat-input-row {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 140px;
  font-family: var(--font-body);
}

.typing-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--sage);
  animation: bounce 1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tile:hover .card { transform: none; }
  .typing-dots span { animation: none; }
}

/* ---------- History / feedback / admin tables ---------- */
.history-item { margin-bottom: 14px; }
.history-item .q { font-weight: 600; margin-bottom: 4px; }
.history-item .a { color: var(--ink-40); font-size: 0.92rem; }
.history-item time { font-family: var(--font-mono); font-size: 0.7rem; color: var(--sage); }

table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ink-15); font-size: 0.9rem; }
th { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sage); }

.rating-stars { color: var(--gold); font-size: 1.3rem; letter-spacing: 3px; }

@media (max-width: 640px) {
  .topbar { padding: 14px 18px; }
  .topbar nav { gap: 12px; }
  .page { padding: 24px 16px 60px; }
}
