/* --- GLOBAL TEXT SELECTION BLOCKER --- */
* {
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none;    /* Firefox */
  -ms-user-select: none;     /* Internet Explorer/Edge */
  user-select: none;         /* Standard syntax */
}

/* Allow users to still type in input boxes (like the Access Code prompt) */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

:root {
  --bg: #f4f5f7;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f9fafc;
  --text: #1f2933;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger: #dc2626;
  --success: #16a34a;
  --border: #e5e7eb;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

body.dark {
  --bg: #0f172a;
  --bg-panel: #111827;
  --bg-panel-alt: #020617;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --danger: #f87171;
  --success: #4ade80;
  --border: #1f2937;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  /* Prevent text selection/highlighting across the whole app */
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none;     /* IE 10 and 11 */
  user-select: none;         /* Standard syntax */
}

/* Allow input boxes (like the Access Code prompt) to still work */
input, textarea {
  user-select: text !important;
  -webkit-user-select: text !important;
}


body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top left, #e0f2fe, #f4f5f7);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  width: 100vw;
  overflow-x: hidden;
  overflow-y: auto; /* FIXED: Restore scrolling */
}

body.dark {
  background: radial-gradient(circle at top left, #020617, #020617);
}

/* ================================
   HEADER & CENTRALIZED USER
================================ */
.app-header {
  position: relative; /* REQUIRED for centering child */
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #f9fafb;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.5);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Perfectly center the "Training: User" display */
.user-display-center {
  /*position: absolute;*/
  left: 50%;
  transform: translateX(50%);
  font-weight: 200;
  font-size: 1.6rem;
  color: #f9fafb;
  pointer-events: none; /* Allows clicks to pass through if needed */
}

.app-title {
  margin: 0;
  font-size: 1.6rem;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #9ca3af;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.score-panel,
.accuracy-panel,
.timer-panel {
  background: rgba(15, 23, 42, 0.7);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  display: flex;
  gap: 6px;
  align-items: center;
}

#score-value,
#accuracy-value,
#timer-value {
  font-weight: 600;
}

.icon-button {
  border: none;
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7eb;
  border-radius: 999px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  background: rgba(55, 65, 81, 0.9);
  transform: translateY(-1px);
}

.progress-bar-wrapper {
  width: 100%;
  background: rgba(15, 23, 42, 0.08);
  height: 6px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 0.3s ease-out;
}

/* ================================
   SIDEBAR & RESET BUTTON
================================ */
.app-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 24px 32px;
}

.sidebar {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 18px 16px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 85vh; /* Ensure sidebar is tall enough */
}

/* ENLARGED RESET BUTTON AT BOTTOM */
#logout-button {
  margin-top: auto; /* PUSHES TO BOTTOM */
  width: 100%;
  padding: 14px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

#logout-button:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.sidebar h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.sidebar-section {
  margin-bottom: 18px;
}

.sidebar-section h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-panel-alt);
  color: var(--text);
  font-size: 0.9rem;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 0.8rem;
  background: var(--bg-panel-alt);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.pill:hover {
  transform: translateY(-1px);
}

.pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.primary-button {
  width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #f9fafb;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.primary-button:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* Main content */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
  gap: 18px;
}

.panel {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 18px 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.panel-bottom {
  background: var(--bg-panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  display: grid;
  justify-content: center;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.badge {
  font-size: 0.7rem;
  padding: 14px 18px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.tag {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-panel-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.scenario-description {
  font-size: 0.99rem;
  color: var(--text);
  margin-top: 6px;
  margin-bottom: 12px;
}

.escalation-chain h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

#escalation-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.step-header {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#step-indicator {
  font-weight: 600;
}

.question-text {
  margin-top: 10px;
  font-size: 1rem;
}

.options-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-panel-alt);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}

.option-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.option-btn.disabled {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

.feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  display: none;
}

.feedback.show {
  display: block;
}

.feedback.correct {
  background: rgba(22, 163, 74, 0.12);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.4);
}

.feedback.wrong {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.4);
}

.bottom-meta {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-tags {
  font-style: italic;
}

.difficulty-indicator {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-panel-alt);
  border: 1px dashed var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.fade-in {
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================================
   LOGIN SCREEN (CENTRALIZED)
================================ */
.login-screen {
  display: flex;             
  justify-content: center;   
  align-items: center;       
  width: 100vw;
  height: 100vh;
  background: #1e1e2f;       
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
}

.login-box {
  background: #2d2d44;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  text-align: center;
  width: 350px;
  color: white;
}
    
.login-box h1 {
  margin-bottom: 10px;
  font-size: 24px;
}

.login-subtitle {
  color: #ccc;
  margin-bottom: 25px;
}

#login-name {
  width: 100%;
  padding: 12px;
  margin-bottom: 20px;
  border-radius: 5px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  box-sizing: border-box;
}

#login-button {
  width: 100%;
  padding: 12px;
  background-color: #4f46e5;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.3s ease;
}

#login-button:hover {
  background-color: #4338ca;
}

#login-error {
  color: #ff4d4d;
  font-size: 14px;
  margin-top: 15px;
}

/* Responsive */
@media (max-width: 960px) {
  .app-layout { grid-template-columns: 1fr; }
  .panels { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .header-controls {
    width: 100%;
    justify-content: space-between;
  }
}