/* Global UI standardization */

/* CSS Reset (light) */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; color: var(--text-primary, #1f2937); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }

/* Root variables (fallbacks still respected) */
:root {
  --primary-color: #5b21b6;
  --primary-dark: #4c1d95;
  --primary-light: #7c3aed;
  --accent-color: #8b5cf6;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --background: #ffffff;
  --background-alt: #f9fafb;
  --background-card: #ffffff;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Typography */
  --font-sans: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing scale */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
}

/* Typography */
html, body {
  font-family: var(--font-sans);
  color: var(--text-primary, #1f2937);
  line-height: 1.6;
  background: var(--background-alt, #f9fafb);
}
html { font-size: clamp(15px, 1.1vw + 10px, 18px); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Fluid heading sizes for hero/landing without impacting base text */
.header--landing h1 { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem); }
.header--landing p { font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.1rem); }

/* Layout containers */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h2 { font-size: 1.875rem; font-weight: 600; margin-bottom: 0.5rem; }
.page-header p { color: var(--text-secondary, #6b7280); font-size: 1.1rem; }

/* Header */
.header {
  background: var(--background-card, #ffffff);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title { display: flex; align-items: center; gap: 0.5rem; }
.header-title h1 { font-size: 1.5rem; font-weight: 700; color: var(--primary-color, #5b21b6); }
.header-badge { background: var(--primary-color, #5b21b6); color: #fff; padding: 0.25rem 0.5rem; border-radius: 0.25rem; font-size: 0.75rem; font-weight: 500; }
.nav-links { display: flex; gap: 1rem; }
.nav-link { padding: 0.5rem 1rem; color: var(--text-secondary, #6b7280); text-decoration: none; border-radius: var(--radius, 0.5rem); transition: all 0.2s ease; }
.nav-link:hover { background: var(--primary-color, #5b21b6); color: #fff; }
.back-link { color: var(--text-secondary, #6b7280); text-decoration: none; display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: var(--radius, 0.5rem); transition: all 0.2s ease; }
.back-link:hover { background: var(--primary-color, #5b21b6); color: #fff; }

/* Header link variant (on dark/gradient headers) */
.header-link { color: #fff; text-decoration: none; opacity: 0.8; transition: opacity 0.2s ease; }
.header-link:hover { opacity: 1; }

/* Simple flex helper */
.flex-row-center { display: flex; gap: 1rem; align-items: center; }

/* Media defaults */
img, video, canvas, svg { max-width: 100%; height: auto; }
iframe { max-width: 100%; width: 100%; }

/* Avoid text overflow issues */
p, h1, h2, h3, h4, h5, h6, .scenario-preview { overflow-wrap: anywhere; word-break: break-word; }

/* Chat/message helpers */
.meta-timestamp { font-size: 0.7rem; color: var(--text-light, #9ca3af); margin-left: auto; }
.status-indicator--thinking { background: var(--warning-color, #f59e0b); animation: pulse 2s infinite; }

/* Section titles */
.section-title { margin-bottom: 1rem; color: var(--primary-color, #5b21b6); }
.stats-section h3 { margin-bottom: 1rem; color: var(--primary-color, #5b21b6); }

/* Header variant: Chat (hero/gradient) */
.header--chat {
  background: linear-gradient(135deg, var(--primary-color, #5b21b6) 0%, var(--primary-light, #7c3aed) 50%, var(--accent-color, #8b5cf6) 100%);
  color: #fff;
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-md);
}
.header--chat .header-title h1 { color: #fff; }
.header--chat .header-badge { background: rgba(255, 255, 255, 0.2); text-transform: uppercase; letter-spacing: 0.05em; }

/* Header variant: Landing (hero) */
.header--landing {
  background: linear-gradient(135deg, var(--primary-color, #5b21b6) 0%, var(--primary-light, #7c3aed) 100%);
  color: #fff;
  padding: 3rem 2rem;
  text-align: center;
  position: static;
  border: 0;
}
.header--landing h1 { font-size: 2rem; font-weight: 600; margin-bottom: 0.5rem; color: #fff; }
.header--landing p { font-size: 1.1rem; opacity: 0.9; }

/* Spacing utilities */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-5 { padding-top: var(--space-5); padding-bottom: var(--space-5); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.px-1 { padding-left: var(--space-1); padding-right: var(--space-1); }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.ml-auto { margin-left: auto; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--primary-color, #5b21b6);
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: var(--radius, 0.5rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px; /* Accessible tap target */
}

.btn:hover {
  background: var(--primary-dark, #4c1d95);
  transform: translateY(-1px);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  min-height: 40px; /* Keep small buttons touch-friendly */
}

.btn-block {
  width: 100%;
}

.btn-secondary {
  background: var(--background-card, #ffffff);
  color: var(--text-primary, #1f2937);
  border: 1px solid var(--border-color, #e5e7eb);
}

.btn-secondary:hover {
  background: var(--primary-color, #5b21b6);
  color: #fff;
  border-color: var(--primary-color, #5b21b6);
}

.btn-danger {
  background: var(--error-color, #ef4444);
}

.btn-danger:hover {
  background: #dc2626;
}

/* Practice button aligns with primary button styling */
.practice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--primary-color, #5b21b6);
  color: #fff;
  border: none;
  border-radius: var(--radius, 0.5rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.practice-btn:hover {
  background: var(--primary-dark, #4c1d95);
  transform: translateY(-1px);
}

/* Cards */
.card,
.scenario-card,
.stat-card {
  background: var(--background-card, #ffffff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Scenarios grid */
.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* Standardized scenario card (Educator style) */
.scenario-card {
  background: var(--background-card, #ffffff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 1rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.scenario-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary-color, #5b21b6), var(--primary-light, #7c3aed));
  border-radius: 50%;
  transform: translate(30px, -30px);
  opacity: 0.1;
  transition: all 0.3s ease;
}

.scenario-card:hover {
  border-color: var(--primary-color, #5b21b6);
  box-shadow: 0 8px 25px -5px rgba(91, 33, 182, 0.15);
  transform: translateY(-4px);
}

.scenario-card:hover::before {
  transform: translate(20px, -20px) scale(1.2);
  opacity: 0.15;
}

.scenario-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--primary-color, #5b21b6);
}

.scenario-preview {
  color: var(--text-secondary, #6b7280);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.scenario-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: auto;
  align-items: center;
}

.scenario-card.clickable { cursor: pointer; }

/* Ensure primary action on student cards sits at bottom */
.scenario-card .practice-btn { margin-top: auto; }

/* Shared scenario metadata */
.scenario-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-light, #9ca3af);
  margin-bottom: 1rem;
}

/* Stats */
.stats-section {
  background: var(--background-card, #ffffff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-lg, 0.75rem);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card { text-align: center; padding: 1rem; background: var(--background-alt, #f9fafb); border-radius: var(--radius, 0.5rem); }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary-color, #5b21b6); display: block; }
.stat-label { color: var(--text-secondary, #6b7280); font-size: 0.9rem; margin-top: 0.25rem; }

/* Filters */
.filter-section { display: flex; gap: 1rem; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; }
.filter-section label { font-weight: 500; color: var(--text-primary, #1f2937); }
.filter-section select { padding: 0.5rem 1rem; border: 1px solid var(--border-color, #e5e7eb); border-radius: var(--radius, 0.5rem); background: var(--background-card, #ffffff); color: var(--text-primary, #1f2937); }

/* Empty state */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-secondary, #6b7280); }
.empty-state-icon { width: 80px; height: 80px; margin: 0 auto 1.5rem; opacity: 0.7; }

/* Landing roles */
.role-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.role-btn { display: block; padding: 2rem 1.5rem; border: 2px solid var(--border-color, #e5e7eb); border-radius: var(--radius, 0.5rem); text-decoration: none; color: var(--text-primary, #1f2937); background: var(--background, #ffffff); transition: all 0.2s ease; text-align: center; }
.role-btn:hover { border-color: var(--primary-color, #5b21b6); background: var(--background, #ffffff); color: var(--text-primary, #1f2937); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.role-btn h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.role-btn p { font-size: 0.9rem; color: inherit; opacity: 0.8; }
.role-btn:hover p { opacity: 1; }

/* Ensure role icons are perfect circles */
.role-icon { width: 72px; height: 72px; margin: 0 auto 1.5rem; box-shadow: 0 6px 20px rgba(91, 33, 182, 0.15); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.role-btn:hover .role-icon { transform: scale(1.05); box-shadow: 0 10px 24px rgba(91, 33, 182, 0.22); }

/* Icon circles */
.icon-circle,
.role-icon,
.choice-icon,
.empty-state-icon {
  background: linear-gradient(135deg, var(--primary-color, #5b21b6), var(--primary-light, #7c3aed));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.icon-circle svg,
.role-icon svg,
.choice-icon svg,
.empty-state-icon svg {
  stroke: currentColor;
}

/* (removed duplicate links/utilities defined earlier for consistency) */

/* Modal & Tabs */
.modal { display:none; position:fixed; inset:0; background:rgba(17,24,39,0.55); backdrop-filter: blur(4px) saturate(120%); z-index:1000; }
.modal.show { display:flex; align-items:center; justify-content:center; padding:2rem; }
.modal-content { background: var(--background-card, #ffffff); border:1px solid var(--border-color, #e5e7eb); border-radius:12px; max-width:960px; width:100%; max-height:90vh; overflow:auto; padding:1.25rem 1.5rem; box-shadow: var(--shadow-md); }
/* Give room for sticky action bar */
.modal-content { padding-bottom: 5.5rem; }
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:1rem; }
.close-btn { background:none; border:none; font-size:1.25rem; cursor:pointer; color:#6b7280; display:inline-flex; align-items:center; justify-content:center; min-width: 40px; min-height: 40px; border-radius: 8px; }
.tabbar { display:flex; gap:.5rem; margin-bottom:1rem; }
.tab { padding:.5rem .75rem; border:1px solid var(--border-color, #e5e7eb); border-radius:6px; background:#fff; cursor:pointer; }
.tab.active { background:var(--primary-color, #5b21b6); color:#fff; border-color:var(--primary-color, #5b21b6); }
.tab-pane.hidden { display:none; }

/* Pane wrappers for create modal */
#manual-pane, #ai-pane { background: var(--background-card, #ffffff); border: 1px solid var(--border-color, #e5e7eb); border-radius: 10px; padding: 1rem; }

/* Info card */
.info-card { background: var(--background-alt, #f9fafb); border: 1px solid var(--border-color, #e5e7eb); border-radius: 10px; padding: 0.75rem 1rem; margin-top: 0.5rem; }
.info-card h3 { font-size: 1rem; margin-bottom: 0.25rem; color: var(--text-primary, #1f2937); }
.info-card p { color: var(--text-secondary, #6b7280); font-size: 0.9rem; }

/* Forms in modals */
.form-group { margin-bottom:1rem; }
.form-group.full { grid-column: 1 / -1; }
.form-grid { display:grid; grid-template-columns: 1fr 1fr; gap:1rem; }
.form-group textarea, .form-group input, .form-group select { width:100%; padding:.75rem; border:1px solid var(--border-color, #e5e7eb); border-radius:8px; font-family:inherit; font-size:.95rem; }
.form-actions { display:flex; gap:.5rem; margin:.5rem 0 1rem; }
.alert { display:none; padding:.75rem 1rem; border-radius:6px; }
.alert.show { display:block; }
.alert.error { background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }

/* Sticky action bar */
.action-bar { position: sticky; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border-color); padding: .75rem 0; margin-top: 1rem; box-shadow: 0 -4px 10px rgba(0,0,0,0.03); z-index: 5; }
.action-bar .bar-inner { display:flex; justify-content: space-between; align-items:center; gap:.5rem; }
.action-bar .bar-left, .action-bar .bar-right { display:flex; gap:.5rem; align-items:center; }
.action-bar .muted { color: var(--text-secondary); font-size:.9rem; }

/* (removed) status badges for legacy modal */

/* Skeletons */
.skeleton { position: relative; overflow: hidden; background: #eef2f7; border-radius: 8px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.6) 50%, rgba(255,255,255,0) 100%); animation: shimmer 1.4s infinite; }
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-title { height: 16px; width: 60%; margin-bottom: 8px; }
.skeleton-meta { height: 10px; width: 40%; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* Micro help text */
.help { color: var(--text-secondary, #6b7280); font-size: .9rem; margin-top: .25rem; }
.section-title-sm { font-size: 1rem; font-weight: 600; margin: .25rem 0 .5rem; color: var(--primary-color, #5b21b6); }
/* (removed) legacy accordion styles */

/* Badges */
.badge { padding:.125rem .5rem; font-size:.75rem; border-radius:999px; border:1px solid var(--border-color, #e5e7eb); }
.badge-draft { background:#fef3c7; color:#92400e; border-color:#fde68a; }
.badge-published { background:#d1fae5; color:#065f46; border-color:#a7f3d0; }
.meta { color:#6b7280; font-size:.8rem; }

/* Toasts */
.toast-container { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1100; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-md); opacity: 0.95; display:flex; gap:.5rem; align-items:center; }
.toast-success { background: #065f46; }
.toast-error { background: #991b1b; }
.toast-info { background: #1f2937; }

@media (max-width: 768px){ .form-grid { grid-template-columns: 1fr; } .drafts{ grid-template-columns: 1fr; } }

/* Small-screen layout polish */
@media (max-width: 768px) {
  .main { padding: 1rem; }
  .header-content { padding: 0 1rem; }
  .nav-links { gap: 0.5rem; flex-wrap: wrap; }
  .page-header h2 { font-size: 1.5rem; }
  .page-header p { font-size: 1rem; }
  .scenarios-grid { grid-template-columns: 1fr; }
  .role-buttons { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; gap: 0.75rem; }
}

@media (max-width: 400px) {
  .btn, .practice-btn { padding: 0.625rem 1rem; }
  .btn-small { padding: 0.5rem 0.875rem; }
  .header-content { padding: 0 0.75rem; }
}

/* (removed) legacy chips used in old builder */

/* Wizard highlight */
.highlight { box-shadow: 0 0 0 3px rgba(91,33,182,0.25) inset; transition: box-shadow .2s ease; }

/* (removed) legacy labs + legacy wizard elements */

/* (removed) legacy builder lists */

/* (removed) legacy ROS builder */

/* (removed) legacy exam builder */

/* Fix textarea sizes (no manual drag-resize) */
.form-group textarea { resize: none; }
.exam-row textarea { resize: none; }

/* (removed) legacy exam field sizing */
