/* ============================================================
   ROLEPLAY.CSS — roleplay.html chat interface
   ============================================================ */

.rp-chat-wrap {
  background: var(--bg-section);
  min-height: calc(100vh - var(--nav-height));
  padding: 20px 24px 40px;
}

.roleplay-shell {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 16px;
  align-items: start;
}

/* ---- Scenario selection: editorial open layout ---- */

.rp-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 48px;
}

.rp-hero {
  padding: 80px 0 56px;
  background: var(--bg-main);
  border-bottom: 1px solid rgba(122, 88, 59, 0.10);
}

.rp-display {
  font-family: "Noto Serif SC", "Noto Serif", "Bodoni Moda", "Songti SC", serif;
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 700;
  color: var(--text);
  margin: 8px 0 20px;
  line-height: 1.15;
}

.rp-display::after {
  content: '';
  display: block;
  width: 48px;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent);
  margin-top: 18px;
  border-radius: 2px;
}

.rp-lead {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 540px;
  margin: 0;
}

.rp-scenarios-section {
  background: var(--bg-section);
  padding: 40px 0 80px;
  border-top: 1px solid var(--line);
}

/* Filter bar */
.rp-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.rp-scenario-meta {
  font-size: 12px;
  color: var(--subtle);
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.rp-filter-tabs {
  display: flex;
  gap: 3px;
  padding: 4px;
  background: rgba(49, 51, 49, 0.06);
  border-radius: 12px;
  border: 1px solid var(--line-strong);
}

/* Segmented pill control — overrides components.css pill style */
.rp-filter-tabs .tab-btn {
  background: none;
  box-shadow: none;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 0;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
  white-space: nowrap;
}

.rp-filter-tabs .tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}

.rp-filter-tabs .tab-btn.active {
  background: var(--bg-ink);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.16);
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 0;
}

.scenario-card {
  border: 1px solid rgba(122, 88, 59, 0.14);
  border-radius: var(--radius-card);
  padding: 22px 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fdfcfb 100%);
  cursor: pointer;
  transition: all 240ms cubic-bezier(0.22, 1, 0.36, 1);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(122, 88, 59, 0.12);
  border-color: rgba(122, 88, 59, 0.32);
}

.scenario-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.scenario-card h3 {
  font-size: 17px;
  margin: 0;
  line-height: 1.3;
}

.scenario-card p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.difficulty-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.difficulty-L1 { background: var(--success-soft); color: var(--success); }
.difficulty-L2 { background: var(--warning-soft); color: #8a5c1a; }
.difficulty-L3 { background: var(--danger-soft); color: var(--danger); }

.scenario-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scenario-tag {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  background: var(--bg-depth);
  color: var(--subtle);
  border: 1px solid var(--line);
}

.channel-badge {
  font-size: 11px;
  color: var(--accent-2);
  font-weight: 600;
}

/* ---- Chat interface ---- */
.rp-left-panel,
.rp-right-panel {
  position: sticky;
  top: calc(var(--nav-height) + 16px);
}

/* Stage progress sidebar */
.stage-progress {
  padding: 18px 16px;
}

.stage-progress h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
  margin: 0 0 14px;
}

.stage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--subtle);
  border: 1px solid transparent;
  transition: all 200ms ease;
}

.stage-item.active {
  background: var(--accent-soft);
  border-color: rgba(196, 137, 108, 0.2);
  color: var(--accent);
  font-weight: 600;
}

.stage-item.done {
  color: var(--muted);
}

.stage-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.stage-item.done .stage-num {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* Timer and controls */
.rp-controls {
  margin-top: 14px;
  padding: 14px 16px;
}

.rp-timer {
  font-family: "Bodoni Moda", serif;
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.rp-timer.warning { color: var(--warning); }
.rp-timer.danger  { color: var(--danger);  }

/* Coaching hints panel */
.coaching-panel {
  padding: 16px;
}

.coaching-panel h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
  margin: 0 0 12px;
}

.coaching-hint {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  margin-bottom: 10px;
}

.win-condition {
  font-size: 12px;
  color: var(--success);
  padding: 8px 10px;
  background: var(--success-soft);
  border-radius: 8px;
  line-height: 1.5;
}

/* ---- Chat main area ---- */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height) - 48px);
  min-height: 500px;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-info h2 {
  font-size: 17px;
  margin: 0;
}

.chat-header-info p {
  font-size: 13px;
  color: var(--muted);
  margin: 3px 0 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

/* Message bubbles */
.msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
  animation: revealUp 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.msg-advisor {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-customer {
  align-self: flex-start;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.msg-advisor .msg-avatar {
  background: linear-gradient(135deg, var(--accent-2), #2e4a6e);
  color: #fff;
}

.msg-customer .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
}

.msg-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
  word-break: break-word;
}

.msg-advisor .msg-bubble {
  background: var(--accent-2-soft);
  border-bottom-right-radius: 4px;
  color: var(--text);
  border: 1px solid rgba(61, 90, 128, 0.15);
}

.msg-customer .msg-bubble {
  background: var(--accent-soft);
  border-bottom-left-radius: 4px;
  color: var(--text);
  border: 1px solid rgba(196, 137, 108, 0.15);
}

.msg-typing .msg-bubble {
  background: var(--accent-soft);
  border: 1px solid rgba(196, 137, 108, 0.15);
  color: var(--muted);
  font-style: italic;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---- Input area ---- */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--card-elevated);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--line-strong);
  border-radius: 16px;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.8);
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 44px;
  line-height: 1.5;
  transition: border-color 200ms ease;
  font-family: inherit;
}

.chat-input:focus {
  border-color: rgba(196, 137, 108, 0.5);
  box-shadow: 0 0 0 3px rgba(196, 137, 108, 0.10);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 200ms ease;
  box-shadow: 0 4px 12px rgba(196, 137, 108, 0.25);
}

.chat-send-btn:hover { background: linear-gradient(135deg, var(--accent-hover), var(--accent-deep)); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.chat-hint {
  font-size: 12px;
  color: var(--subtle);
  margin-top: 8px;
  text-align: center;
}

/* ---- Evaluation results ---- */
.eval-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.6);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: revealFade 300ms ease both;
}

.eval-panel {
  background: var(--card-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(10, 12, 18, 0.3);
  transform-origin: center bottom;
  animation: revealScale 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eval-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eval-score {
  font-family: "Bodoni Moda", serif;
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.eval-body { padding: 20px 24px 24px; }

.eval-section { margin-bottom: 20px; }

.eval-section h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtle);
  margin: 0 0 10px;
}

.stage-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.stage-score-name {
  font-size: 13px;
  font-weight: 600;
  width: 64px;
  flex-shrink: 0;
  color: var(--text);
}

.stage-score-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-depth);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.stage-score-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.stage-score-num {
  font-size: 13px;
  font-weight: 600;
  width: 32px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stage-score-comment {
  font-size: 12px;
  color: var(--subtle);
  margin: 2px 0 10px 74px;
  line-height: 1.5;
}

.eval-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.eval-tag {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
}

.eval-tag-strength { background: var(--success-soft); color: var(--success); }
.eval-tag-weakness { background: var(--danger-soft); color: var(--danger); }
.eval-tag-module   { background: var(--warning-soft); color: #7a5010; }

.eval-key-moment {
  padding: 12px 14px;
  background: var(--gold-soft);
  border-radius: var(--radius-inner);
  font-size: 13px;
  line-height: 1.6;
  border-left: 3px solid var(--gold);
  color: var(--text);
}

.eval-tip {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
}

.eval-tip::before {
  content: '→';
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.eval-drill {
  padding: 12px 14px;
  background: var(--accent-2-soft);
  border-radius: var(--radius-inner);
  font-size: 13px;
  line-height: 1.6;
}

.eval-drill strong { color: var(--accent-2); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .rp-container { padding: 0 32px; }
}

@media (max-width: 920px) {
  .rp-container { padding: 0 20px; }
  .rp-hero { padding: 56px 0 36px; }
  .roleplay-shell {
    grid-template-columns: 1fr;
    max-width: 640px;
  }
  .rp-left-panel, .rp-right-panel { position: static; }
  .scenario-grid { grid-template-columns: 1fr; }
  .chat-panel { height: 70vh; }
}

@media (max-width: 640px) {
  .rp-filter-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .rp-chat-wrap { padding: 12px 12px 32px; }
  .eval-panel { margin: 8px; max-height: 94vh; }
  .eval-score { font-size: 48px; }
  .msg { max-width: 90%; }
}
