/* Premium styling for CommonSpirit Prep Workspace */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  
  /* Primary HSL Palettes (Navy, Slate, Gold, Crimson) */
  --primary: #1e3a8a;
  --primary-light: #eff6ff;
  --primary-hover: #1d4ed8;
  --primary-rgb: 30, 58, 138;
  
  --accent: #0284c7;
  --accent-light: #e0f2fe;
  
  --success: #15803d;
  --success-light: #f0fdf4;
  --success-border: #bbf7d0;
  
  --warning: #a16207;
  --warning-light: #fef9c3;
  --warning-border: #fef08a;
  
  --danger: #b91c1c;
  --danger-light: #fef2f2;
  --danger-border: #fca5a5;
  
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --sidebar-width: 320px;
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

body.dark {
  --bg: #0b0f19;
  --surface: #131b2e;
  --surface-2: #1e293b;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  
  --primary: #3b82f6;
  --primary-light: #172554;
  --primary-hover: #60a5fa;
  --primary-rgb: 59, 130, 246;
  
  --accent: #38bdf8;
  --accent-light: #0c4a6e;
  
  --success: #4ade80;
  --success-light: #14532d;
  --success-border: #166534;
  
  --warning: #facc15;
  --warning-light: #713f12;
  --warning-border: #854d0e;
  
  --danger: #f87171;
  --danger-light: #7f1d1d;
  --danger-border: #991b1b;
  
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  font-weight: 700;
  margin-top: 0;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 24px;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 1.3rem;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.3);
}

.brand h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 800;
}

.brand p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
  font-weight: 500;
}

.sidebar-tools {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
  transition: all 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.search-icon {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  width: 100%;
  font-size: 0.9rem;
}

.nav-list {
  flex-grow: 1;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  border: none;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.sidebar-footer {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--surface-2);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--surface-2);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  min-width: 0;
  padding: 40px 48px;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.topbar-info {
  margin-right: auto;
}

.topbar-info h2 {
  font-size: 1.45rem;
  margin: 0;
}

.eyebrow {
  display: block;
  font-family: var(--font-title);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.status-chip {
  padding: 6px 14px;
  background: var(--primary-light);
  border: 1px solid var(--border);
  color: var(--primary);
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Navigation History Controls */
.nav-history {
  display: flex;
  gap: 6px;
}

.history-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.history-btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.history-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Panels & Cards */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  padding: 36px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  margin-bottom: 32px;
  border-left: 6px solid var(--primary);
}

.hero-text {
  max-width: 720px;
}

.hero h3 {
  font-size: 1.8rem;
  line-height: 1.3;
  margin: 12px 0;
  color: var(--primary);
}

.hero p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-light);
  color: var(--primary);
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent);
}

/* Main Content Sectioning */
.section {
  margin-bottom: 40px;
  scroll-margin-top: 100px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.section-number {
  min-width: 44px;
  height: 44px;
  background: var(--primary);
  color: #ffffff;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.section-title-wrap h2 {
  font-size: 1.55rem;
  margin: 0;
}

.section-intro {
  color: var(--text-muted);
  margin: 4px 0 0 0;
  font-size: 0.92rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

.card h3 {
  color: var(--primary);
  font-size: 1.18rem;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* Callouts */
.callout {
  padding: 16px 20px;
  border-left: 4px solid var(--primary);
  background: var(--surface-2);
  border-radius: 8px;
  margin: 16px 0;
  font-size: 0.95rem;
}

.callout.success {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
  border-left-width: 5px;
}

.callout.warning {
  background: var(--warning-light);
  border-color: var(--warning);
  color: var(--warning);
  border-left-width: 5px;
}

.callout.danger {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
  border-left-width: 5px;
}

.callout strong {
  color: inherit;
}

/* Layout Grids */
.grid-2, .grid-3 {
  display: grid;
  gap: 16px;
  margin: 16px 0;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  font-size: 1.6rem;
  color: var(--primary);
  font-family: var(--font-title);
  font-weight: 800;
  line-height: 1.2;
}

.metric span {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* Accordions */
.accordion {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.accordion-trigger {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 16px 20px;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.2s;
}

.accordion-trigger:hover {
  background: var(--surface-2);
}

.accordion-content {
  display: none;
  padding: 0 20px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.accordion.open .accordion-content {
  display: block;
}

.accordion-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.accordion.open .accordion-icon {
  transform: rotate(45deg);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

th, td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-family: var(--font-title);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--primary-light);
}

.quote {
  padding: 18px;
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  font-size: 0.98rem;
  color: var(--text-muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 6px;
  margin-bottom: 6px;
}

/* Context / Related Links inside Cards */
.context-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.context-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.context-link {
  background: var(--primary-light);
  border: 1px solid var(--border);
  color: var(--primary);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.context-link:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Interactive Reference Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: flex-end;
  transition: opacity 0.3s;
}

.drawer {
  width: min(650px, 100vw);
  background: var(--surface);
  height: 100vh;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid var(--border);
}

.drawer-overlay:not(.hidden) .drawer {
  transform: translateX(0);
}

.drawer-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
}

.drawer-header h3 {
  margin: 4px 0 0 0;
  font-size: 1.25rem;
  color: var(--primary);
}

.close-drawer {
  border-radius: 50%;
  width: 36px;
  height: 36px;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

/* Search results block */
.search-results {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}

.search-results h3 {
  color: var(--primary);
  margin-bottom: 16px;
}

.search-hit {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
  border-radius: 6px;
}

.search-hit:last-child {
  border-bottom: none;
}

.search-hit:hover {
  background: var(--surface-2);
}

.search-hit button {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  font-size: 1rem;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.search-hit button:hover {
  text-decoration: underline;
}

.search-hit p {
  margin: 6px 0 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Checklist custom styling */
.checklist label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.2s;
  cursor: pointer;
}

.checklist label:hover {
  background: var(--surface-2);
}

.checklist input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  cursor: pointer;
}

/* Live Simulator View */
.interview-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
  padding: 24px;
}

.interview-shell {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

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

.interview-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.close-interview {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger-border);
}

.close-interview:hover {
  background: var(--danger);
  color: white;
}

.stage-chooser {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 40px;
}

.stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.stage-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.stage-card h3 {
  color: var(--primary);
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.stage-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-grow: 1;
  margin: 0;
}

.interview-flow {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.interview-progress-container {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.interview-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.3s ease;
}

.interview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.question-counter {
  font-weight: 600;
  font-size: 0.9rem;
}

.interview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.interview-card h1 {
  font-size: 2rem;
  line-height: 1.25;
  margin: 10px 0 24px 0;
  color: var(--text);
}

.answer-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.answer-panel {
  padding: 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-icon {
  font-size: 1.2rem;
}

.answer-panel h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.primary-answer {
  background: var(--primary-light);
  border-color: rgba(var(--primary-rgb), 0.2);
}

.primary-answer h3 {
  color: var(--primary);
}

.caution-panel {
  background: var(--danger-light);
  border-color: var(--danger-border);
  color: var(--danger);
}

.caution-panel h3 {
  color: var(--danger);
}

.answer-panel ul, .answer-panel ol {
  margin: 0;
  padding-left: 18px;
}

.answer-panel li {
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.live-notes {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
}

.live-notes summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.live-notes textarea {
  width: 100%;
  min-height: 120px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
  outline: none;
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.2s;
}

.live-notes textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.notes-status-wrap {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.notes-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.interview-footer {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.interview-footer button {
  min-height: 44px;
}

.interview-footer #nextQuestion {
  margin-left: auto;
}

.shortcut-help {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 16px;
}

/* Back to Top */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  display: none;
  box-shadow: var(--shadow-lg);
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: all 0.2s;
}

.back-to-top:hover {
  transform: translateY(-2px);
  background: var(--primary-hover);
}

/* Animations */
.linked-flash {
  animation: linkedFlash 1.5s ease;
}

@keyframes linkedFlash {
  0% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0); }
}

.hidden {
  display: none !important;
}

/* Responsive Styles */
@media (max-width: 1100px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .main-content {
    padding: 24px;
  }
  .answer-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    padding: 24px;
  }
  .hero-actions {
    width: 100%;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .status-chip {
    align-self: flex-start;
  }
}
