/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #141718;
  --surface:     rgba(24, 28, 30, 0.72);
  --border:      rgba(255, 255, 255, 0.07);
  --text:        #d8e0e3;
  --muted:       #6e7d82;
  --accent:      #3d9e9e;   /* client: steel teal */
  --accent2:     #2a7a7a;   /* client: deeper teal */
  --prof-accent: #c9a84c;   /* professor: muted gold */
  --prof-accent2:#5b9ecc;   /* professor: sky blue */
  --success:     #3a9e68;
  --radius:      14px;
  --transition:  0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── Background blobs ─────────────────────────────────────────────────────── */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}
.blob-1 { width: 600px; height: 600px; background: #0e3535; top: -150px; left: -150px; }
.blob-2 { width: 500px; height: 500px; background: #1a2a2a; bottom: -100px; right: -100px; }
.blob-3 { width: 400px; height: 400px; background: #0a2828; top: 50%; left: 50%; transform: translate(-50%,-50%); }

body.professor-mode .blob-1 { background: #2a1e00; }
body.professor-mode .blob-2 { background: #1a2a2a; }
body.professor-mode .blob-3 { background: #1e2820; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.layout {
  position: relative;
  z-index: 1;
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 0.5rem; }
.logo-icon { font-size: 1.6rem; }
.logo-text { font-family: 'Playfair Display', serif; font-size: 1.4rem; font-weight: 700; color: var(--accent); }
body.professor-mode .logo-text { color: var(--prof-accent); }
.beta-badge {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 9px;
  border-radius: 99px; border: 1px solid var(--border);
  color: var(--muted);
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 2rem; }
.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: 0.6rem;
}
body.professor-mode .hero-title {
  background: linear-gradient(135deg, #fff 0%, var(--prof-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-subtitle { color: var(--muted); font-size: 1rem; }

/* ── Mode Toggle ──────────────────────────────────────────────────────────── */
.mode-toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.mode-label { font-size: 0.85rem; color: var(--muted); font-weight: 500; transition: color var(--transition); }
.mode-label.active { color: var(--text); }
.professor-label { color: var(--muted); }
body.professor-mode .professor-label { color: var(--prof-accent); }

.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid var(--border);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 4px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: rgba(220, 179, 96, 0.3); border-color: var(--prof-accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); background: var(--prof-accent); }

/* ── Glass Panel ──────────────────────────────────────────────────────────── */
.glass-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.25rem;
}

/* ── Gamification Panel ───────────────────────────────────────────────────── */
.gam-panel {
  margin-bottom: 1.25rem;
  border-color: rgba(220, 179, 96, 0.2);
}
.gam-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.gam-level { display: flex; align-items: center; gap: 0.5rem; }
.level-icon { font-size: 1.3rem; }
.level-name { font-weight: 700; font-size: 1rem; color: var(--prof-accent); }
.gam-xp { display: flex; align-items: center; gap: 0.35rem; }
.xp-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.xp-value { font-weight: 700; font-size: 1rem; color: var(--prof-accent); }
.gam-streak { display: flex; align-items: center; gap: 0.35rem; }
.streak-icon { font-size: 1rem; }
.streak-value { font-size: 0.85rem; color: var(--muted); }
.streak-value.hot { color: #3d9e9e; font-weight: 600; }

.xp-bar-wrapper { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.xp-bar { flex: 1; height: 6px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--prof-accent2), var(--prof-accent)); border-radius: 99px; transition: width 0.6s ease; }
.xp-next { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

.badges-row { display: flex; flex-wrap: wrap; gap: 0.4rem; min-height: 28px; }
.badge-chip {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 3px 8px; border-radius: 99px;
  background: rgba(220, 179, 96, 0.12);
  border: 1px solid rgba(220, 179, 96, 0.3);
  font-size: 0.72rem; color: var(--prof-accent);
  animation: badgePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ── Results Grid ─────────────────────────────────────────────────────────── */
.results-wrapper { margin-bottom: 1.25rem; }
.results-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 800px) { .results-grid { grid-template-columns: 1fr; } }

.main-card { padding: 1.5rem; }
.sidebar-col { display: flex; flex-direction: column; gap: 1rem; }
.sidebar-card { padding: 1rem; }

/* ── Card Headers ─────────────────────────────────────────────────────────── */
.card-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.card-icon { font-size: 1rem; }
.card-title { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* ── Conversation ─────────────────────────────────────────────────────────── */
.conversation { display: flex; flex-direction: column; gap: 1rem; }
.msg { border-radius: 10px; padding: 0.9rem 1rem; line-height: 1.65; }
.msg-user {
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-size: 0.9rem;
}
body.professor-mode .msg-user { border-left-color: var(--prof-accent2); }
.msg-ai { font-size: 0.92rem; }
.msg-ai h1,.msg-ai h2,.msg-ai h3 { font-size: 1em; margin: 0.5em 0 0.25em; color: var(--accent); }
body.professor-mode .msg-ai h1,
body.professor-mode .msg-ai h2,
body.professor-mode .msg-ai h3 { color: var(--prof-accent); }
.msg-ai p  { margin: 0.4em 0; }
.msg-ai ul,.msg-ai ol { padding-left: 1.4em; margin: 0.4em 0; }
.msg-ai li { margin: 0.2em 0; }
.msg-ai strong { color: var(--text); }
.msg-ai em { color: var(--muted); }
.msg-ai a { color: var(--accent); text-decoration: underline; }
body.professor-mode .msg-ai a { color: var(--prof-accent); }

/* Thinking bubble */
.msg-thinking {
  display: flex; align-items: center; gap: 0.65rem;
  color: var(--muted); font-size: 0.85rem; font-style: italic;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
}
.thinking-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}
body.professor-mode .thinking-spinner { border-top-color: var(--prof-accent); }

/* Scoring bubble */
.scoring-bubble {
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
}
.scoring-bubble.correct   { background: rgba(63, 185, 80, 0.1); border-left: 3px solid var(--success); }
.scoring-bubble.partial   { background: rgba(220, 179, 96, 0.1); border-left: 3px solid var(--prof-accent); }
.scoring-bubble.incorrect { background: rgba(229, 92, 92, 0.1); border-left: 3px solid var(--accent); }
.scoring-row { display: flex; align-items: center; gap: 0.5rem; }
.scoring-pts { font-weight: 700; font-size: 1.1rem; }
.scoring-pts.correct { color: var(--success); }
.scoring-pts.partial { color: var(--prof-accent); }
.scoring-pts.incorrect { color: var(--accent); }
.scoring-feedback { color: var(--muted); }
.streak-bonus { font-size: 0.75rem; color: #3d9e9e; font-weight: 600; }

/* ── Recent Cases ─────────────────────────────────────────────────────────── */
.cases-list { display: flex; flex-direction: column; gap: 0.65rem; }
.case-item {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.case-item:hover { border-color: rgba(229, 92, 92, 0.35); }
body.professor-mode .case-item:hover { border-color: rgba(220, 179, 96, 0.35); }
.case-name { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }
.case-name a { color: var(--accent); text-decoration: none; }
.case-name a:hover { text-decoration: underline; }
body.professor-mode .case-name a { color: var(--prof-accent); }
.case-meta { font-size: 0.72rem; color: var(--muted); }
.case-snippet { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* ── Topics ───────────────────────────────────────────────────────────────── */
.topics-list { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.topics-list li { font-size: 0.8rem; color: var(--muted); padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.topics-list li:last-child { border-bottom: none; }
.topics-list li::before { content: '→ '; color: var(--accent); }
body.professor-mode .topics-list li::before { color: var(--prof-accent); }

/* ── Scoring Sidebar Card ─────────────────────────────────────────────────── */
#scoringContent { display: flex; flex-direction: column; gap: 0.5rem; }
.score-row { display: flex; justify-content: space-between; font-size: 0.82rem; }
.score-label { color: var(--muted); }
.score-val { font-weight: 600; }

/* ── Interaction Card ─────────────────────────────────────────────────────── */
.interaction-card { position: sticky; bottom: 1.5rem; }
.input-label {
  display: block;
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
  transition: color var(--transition);
}
.textarea-wrapper { position: relative; margin-bottom: 0.75rem; }
textarea {
  width: 100%; resize: none;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  line-height: 1.6;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color var(--transition);
}
textarea:focus { border-color: var(--accent); }
body.professor-mode textarea:focus { border-color: var(--prof-accent); }
textarea::placeholder { color: var(--muted); }

.submit-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; padding: 0.7rem 1.25rem;
  background: linear-gradient(135deg, #2a7a7a, #3d9e9e);
  border: none; border-radius: 10px;
  color: #fff; font-family: 'Inter', sans-serif;
  font-size: 0.92rem; font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
body.professor-mode .submit-btn {
  background: linear-gradient(135deg, #2a7a7a, #c9a84c);
}
.submit-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Badge Toast ──────────────────────────────────────────────────────────── */
.badge-toast {
  position: fixed; bottom: 2rem; right: 2rem;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: rgba(18, 24, 36, 0.95);
  border: 1px solid rgba(220, 179, 96, 0.4);
  border-radius: 12px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 9999;
  animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.badge-toast-icon { font-size: 1.75rem; }
.badge-toast-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--prof-accent); font-weight: 600; margin-bottom: 0.15rem; }
.badge-toast-name { font-size: 0.9rem; font-weight: 600; color: var(--text); }

/* ── Case Analysis Card ───────────────────────────────────────────────────── */
.score-meter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.score-dial {
  display: flex;
  align-items: baseline;
  gap: 0.1rem;
}
.score-number {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.score-label-sm { font-size: 0.8rem; color: var(--muted); }
.verdict-label  { font-size: 0.82rem; font-weight: 600; }

.score-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.65rem;
}
.score-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s ease;
}

.analysis-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}
.analysis-label { color: var(--muted); }
.analysis-val   { font-weight: 600; color: var(--text); }

.factors-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.5rem 0;
}
.factor {
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  line-height: 1.4;
}
.factor-pro {
  background: rgba(74, 222, 128, 0.08);
  color: #4ade80;
  border-left: 2px solid #3a9e68;
}
.factor-con {
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
  border-left: 2px solid #f87171;
}
.analysis-disclaimer {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ── Keyframes ────────────────────────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes badgePop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes toastIn  { from { transform: translateY(20px) scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
