/* ===========================================
   ProTools ER1: Programming Tools for Empirical Research
   A comprehensive guide to Python, Stata & R
   by Giulia Caprini (Sciences Po)
   =========================================== */

:root {
  /* Color Palette - Academic/Research inspired */
  --color-primary: #1a365d;
  --color-secondary: #2c5282;
  --color-accent: #ed8936;
  --color-accent-light: #fbd38d;
  --color-success: #38a169;
  --color-python: #3776ab;
  --color-stata: #1a476f;
  --color-r: #276dc3;
  --color-bg: #f7fafc;
  --color-bg-alt: #edf2f7;
  --color-text: #2d3748;
  --color-text-light: #4a5568;
  --color-border: #e2e8f0;
  
  /* Code block colors - LIGHTER BACKGROUND for better contrast */
  --color-code-bg: #1e1e2e;
  --color-code-text: #cdd6f4;
  
  /* Typography */
  --font-heading: 'Crimson Pro', Georgia, serif;
  --font-body: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-code: 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* Layout */
  --max-width: 900px;
  --sidebar-width: 280px;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--color-text);
  background: var(--color-bg);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-primary);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
}

h1 {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-bottom: 3px solid var(--color-accent);
  padding-bottom: var(--space-md);
}

h2 {
  font-size: 2rem;
  margin-top: var(--space-3xl);
  position: relative;
  padding-left: var(--space-lg);
}

h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.2em;
  height: 1.2em;
  width: 4px;
  background: var(--color-accent);
  border-radius: 2px;
}

h3 {
  font-size: 1.5rem;
  color: var(--color-secondary);
}

h4 {
  font-size: 1.25rem;
}

p {
  margin-bottom: var(--space-md);
}

a {
  color: var(--color-secondary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

a:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* Layout */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--color-primary) 0%, #0d1f3c 100%);
  color: white;
  padding: var(--space-xl);
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
  margin-bottom: var(--space-xs);
  display: block;
}

.sidebar-subtitle {
  font-size: 0.85rem;
  color: var(--color-accent-light);
  font-style: italic;
  margin-bottom: var(--space-2xl);
  display: block;
}

.sidebar nav ul {
  list-style: none;
}

.sidebar nav ul li {
  margin-bottom: var(--space-xs);
}

.sidebar nav a {
  color: rgba(255, 255, 255, 0.8);
  display: block;
  padding: var(--space-sm) var(--space-md);
  border-radius: 4px;
  font-size: 0.95rem;
  border-bottom: none;
  transition: all 0.2s ease;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  transform: translateX(4px);
}

.sidebar nav a.active {
  border-left: 3px solid var(--color-accent);
  background: rgba(237, 137, 54, 0.15);
}

/* Welcome page icon */
.sidebar nav a .welcome-icon {
  margin-right: var(--space-sm);
  font-size: 1.1rem;
}

/* Sub-navigation for IDE guides */
.sidebar nav ul.sub-nav {
  margin-left: var(--space-lg);
  margin-top: var(--space-xs);
  margin-bottom: var(--space-xs);
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: var(--space-sm);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.sidebar nav ul.sub-nav.expanded {
  max-height: 500px;
}

.sidebar nav li.has-subnav > a {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Clickable toggle button for subnav expand/collapse */
.sidebar nav li.has-subnav > a .subnav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar nav li.has-subnav > a .subnav-toggle::before {
  content: '+';
}

.sidebar nav li.has-subnav.expanded > a .subnav-toggle::before {
  content: '−';
}

.sidebar nav li.has-subnav > a .subnav-toggle:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.sidebar nav ul.sub-nav li {
  margin-bottom: 2px;
}

.sidebar nav ul.sub-nav a {
  font-size: 0.85rem;
  padding: var(--space-xs) var(--space-sm);
  color: rgba(255, 255, 255, 0.65);
}

.sidebar nav ul.sub-nav a:hover,
.sidebar nav ul.sub-nav a.active {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar nav ul.sub-nav a.active {
  border-left: 2px solid var(--color-accent);
  background: rgba(237, 137, 54, 0.1);
}

.module-number {
  font-weight: 700;
  color: var(--color-accent);
  margin-right: var(--space-sm);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--space-3xl);
  max-width: calc(var(--max-width) + var(--sidebar-width) + var(--space-3xl) * 2);
}

.content {
  max-width: var(--max-width);
}

/* Module Header */
.module-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: white;
  padding: var(--space-3xl);
  margin: calc(-1 * var(--space-3xl));
  margin-bottom: var(--space-2xl);
  position: relative;
  overflow: hidden;
}

.module-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(237, 137, 54, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.module-header h1 {
  color: white;
  border-bottom-color: var(--color-accent);
  position: relative;
  z-index: 1;
}

.module-meta {
  display: flex;
  gap: var(--space-xl);
  margin-top: var(--space-md);
  position: relative;
  z-index: 1;
}

.module-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Learning Objectives Box */
.learning-objectives {
  background: linear-gradient(135deg, var(--color-bg-alt) 0%, #e2e8f0 100%);
  border-left: 4px solid var(--color-accent);
  padding: var(--space-xl);
  margin: var(--space-2xl) 0;
  border-radius: 0 8px 8px 0;
}

.learning-objectives h3 {
  color: var(--color-primary);
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.learning-objectives ul {
  margin: var(--space-md) 0 0 var(--space-lg);
}

.learning-objectives li {
  margin-bottom: var(--space-sm);
}

/* Code Tabs */
.code-tabs {
  margin: var(--space-xl) 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.tab-buttons {
  display: flex;
  background: #313244;
  border-bottom: 1px solid #45475a;
}

.tab-button {
  padding: var(--space-sm) var(--space-xl);
  background: transparent;
  border: none;
  color: #a6adc8;
  font-family: var(--font-code);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.tab-button:hover {
  color: #cdd6f4;
  background: rgba(255, 255, 255, 0.05);
}

.tab-button.active {
  color: #cdd6f4;
  background: var(--color-code-bg);
}

.tab-button.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
}

.tab-button[data-lang="python"].active::after {
  background: #f9e2af;
}

.tab-button[data-lang="stata"].active::after {
  background: #89b4fa;
}

.tab-button[data-lang="r"].active::after {
  background: #a6e3a1;
}

.tab-content {
  display: none;
  background: var(--color-code-bg);
}

.tab-content.active {
  display: block;
}

/* ===========================================
   CODE BLOCKS - CATPPUCCIN MOCHA THEME
   Much better readability with softer colors
   =========================================== */
pre {
  margin: 0;
  padding: var(--space-lg);
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.9rem;
  line-height: 1.7;
  background: var(--color-code-bg);
  color: var(--color-code-text);
}

code {
  font-family: var(--font-code);
}

/* Syntax Highlighting - Catppuccin Mocha inspired */
.code-keyword {
  color: #cba6f7;  /* Mauve - for keywords like import, def, if */
  font-weight: 500;
}

.code-string {
  color: #a6e3a1;  /* Green - for strings */
}

.code-comment {
  color: #6c7086;  /* Overlay0 - for comments, clearly muted */
  font-style: italic;
}

.code-function {
  color: #89b4fa;  /* Blue - for function names */
}

.code-number {
  color: #fab387;  /* Peach - for numbers */
}

.code-operator {
  color: #89dceb;  /* Sky - for operators */
}

.code-variable {
  color: #f5c2e7;  /* Pink - for variables */
}

.code-package {
  color: #f9e2af;  /* Yellow - for packages/modules */
}

/* Code inside pre blocks (code images) - inherit color from pre or use default */
pre code {
  color: var(--color-code-text);  /* Light text for dark backgrounds */
  background: none;
  font-weight: normal;
}

/* Inline code outside of pre blocks - red color for visibility */
:not(pre) > code {
  color: #c92a2a;
  font-size: 0.95em;
  font-weight: 500;
}

/* Info Boxes */
.info-box {
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
  border-radius: 8px;
  position: relative;
}

.info-box.tip {
  background: #f0fff4;
  border-left: 4px solid var(--color-success);
}

.info-box.warning {
  background: #fffaf0;
  border-left: 4px solid var(--color-accent);
}

.info-box.note {
  background: #ebf8ff;
  border-left: 4px solid var(--color-secondary);
}

.info-box-title {
  font-weight: 600;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
  font-size: 0.95rem;
}

th, td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: var(--color-bg-alt);
  font-weight: 600;
  color: var(--color-primary);
}

tr:hover {
  background: var(--color-bg-alt);
}

/* ===========================================
   INTERACTIVE SCREENSHOT SYSTEM
   Hotspots with hover tooltips
   =========================================== */

/* Screenshot container - clean layout */
.screenshot-container {
  position: relative;
  margin: var(--space-2xl) 0;
  border-radius: 8px;
  overflow: visible;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  background: #1e1e1e;
}

/* The IDE mockup visual styling */
.screenshot-container .ide-mockup {
  position: relative;
  border-radius: 8px;
  overflow: visible;
}

.screenshot-container .ide-mockup .ide-titlebar {
  border-radius: 8px 8px 0 0;
}

.screenshot-container img {
  display: block;
  width: 100%;
  height: auto;
}

/* Hotspot markers */
.hotspot {
  position: absolute;
  width: 28px;
  height: 28px;
  background: var(--color-accent);
  border: 3px solid white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  z-index: 100;
}

.hotspot:hover {
  transform: scale(1.2);
  background: #dd6b20;
  z-index: 1000;
}

.hotspot::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--color-accent);
  animation: pulse 2s infinite;
  z-index: -1;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  70% {
    transform: scale(1.8);
    opacity: 0;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

/* Tooltip - uses fixed positioning via JS for guaranteed visibility */
.hotspot-tooltip {
  position: fixed;
  background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: 8px;
  width: 280px;
  max-width: 280px;
  font-size: 0.85rem;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 99999;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Tooltip visibility controlled by JS since tooltips are moved to body */
/* The .hotspot:hover selector no longer works after moving to body */

/* Position classes for arrow direction (JS handles actual positioning) */
.hotspot-tooltip.top,
.hotspot-tooltip.bottom,
.hotspot-tooltip.left,
.hotspot-tooltip.right {
  /* These classes only control the arrow direction now */
  /* The JS sets actual top/left with fixed positioning */
}

/* Arrow for tooltips - positioned based on direction class */
.hotspot-tooltip::after {
  content: '';
  position: absolute;
  border: 8px solid transparent;
}

/* Arrow points DOWN (tooltip is above the hotspot) */
.hotspot-tooltip.top::after {
  top: 100%;
  left: 20px;
  border-top-color: #2c5282;
}

/* Arrow points UP (tooltip is below the hotspot) */
.hotspot-tooltip.bottom::after {
  bottom: 100%;
  left: 20px;
  border-bottom-color: #1a365d;
}

/* Arrow points RIGHT (tooltip is to the left of hotspot) */
.hotspot-tooltip.left::after {
  left: 100%;
  top: 20px;
  border-left-color: #2c5282;
}

/* Arrow points LEFT (tooltip is to the right of hotspot) */
.hotspot-tooltip.right::after {
  right: 100%;
  top: 20px;
  border-right-color: #1a365d;
}

.hotspot-tooltip h4 {
  color: var(--color-accent-light);
  margin: 0 0 var(--space-sm) 0;
  font-size: 1rem;
}

.hotspot-tooltip p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

/* Screenshot caption */
.screenshot-caption {
  background: var(--color-bg-alt);
  padding: var(--space-md) var(--space-lg);
  font-size: 0.9rem;
  color: var(--color-text-light);
  border-top: 1px solid var(--color-border);
}

/* Screenshot placeholder (SVG-based, no external images needed) */
.screenshot-placeholder {
  background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
  padding: var(--space-xl);
  min-height: 400px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* IDE mockup styles */
.ide-mockup {
  background: #1e1e1e;
  border-radius: 8px;
  overflow: hidden;
}

.ide-titlebar {
  background: #323232;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ide-titlebar-dots {
  display: flex;
  gap: 6px;
}

.ide-titlebar-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.ide-titlebar-dot.red { background: #ff5f56; }
.ide-titlebar-dot.yellow { background: #ffbd2e; }
.ide-titlebar-dot.green { background: #27ca40; }

.ide-titlebar-title {
  color: #808080;
  font-size: 0.85rem;
  margin-left: auto;
  margin-right: auto;
}

.ide-content {
  display: flex;
  min-height: 350px;
}

.ide-sidebar {
  width: 200px;
  background: #252526;
  border-right: 1px solid #3c3c3c;
  padding: var(--space-md);
}

.ide-sidebar-title {
  color: #808080;
  font-size: 0.75rem;
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

.ide-sidebar-item {
  color: #cccccc;
  font-size: 0.85rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
}

.ide-sidebar-item:hover {
  background: #2a2d2e;
}

.ide-sidebar-item.active {
  background: #37373d;
}

.ide-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ide-tabs {
  background: #252526;
  display: flex;
  border-bottom: 1px solid #3c3c3c;
}

.ide-tab {
  padding: 8px 16px;
  color: #808080;
  font-size: 0.85rem;
  border-right: 1px solid #3c3c3c;
  cursor: pointer;
}

.ide-tab.active {
  background: #1e1e1e;
  color: #ffffff;
}

.ide-editor {
  flex: 1;
  padding: var(--space-md);
  font-family: var(--font-code);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #d4d4d4;
}

.ide-terminal {
  background: #1e1e1e;
  border-top: 1px solid #3c3c3c;
  padding: var(--space-md);
  font-family: var(--font-code);
  font-size: 0.8rem;
  color: #cccccc;
  min-height: 100px;
}

.ide-terminal-prompt {
  color: #4ec9b0;
}

/* Guide cards - for linking to subpages */
.guide-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-2xl) 0;
}

.guide-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-xl);
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.guide-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--color-accent);
}

.guide-card-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
}

.guide-card h3 {
  margin-top: 0;
  margin-bottom: var(--space-sm);
  color: var(--color-primary);
}

.guide-card p {
  margin: 0;
  color: var(--color-text-light);
  font-size: 0.95rem;
}

/* Figures */
figure {
  margin: var(--space-2xl) 0;
}

figure img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

figcaption {
  text-align: center;
  font-style: italic;
  color: var(--color-text-light);
  margin-top: var(--space-md);
  font-size: 0.9rem;
}

/* Citations */
.citation {
  background: var(--color-bg-alt);
  padding: var(--space-lg);
  border-radius: 8px;
  margin: var(--space-xl) 0;
  font-size: 0.95rem;
}

.citation-title {
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
}

/* Navigation Footer */
.nav-footer {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 2px solid var(--color-border);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-alt);
  border-radius: 8px;
  border-bottom: none;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.nav-link.prev::before {
  content: '←';
}

.nav-link.next::after {
  content: '→';
}

/* Table of Contents */
.toc {
  background: var(--color-bg-alt);
  padding: var(--space-xl);
  border-radius: 8px;
  margin: var(--space-2xl) 0;
}

.toc h3 {
  margin-top: 0;
  margin-bottom: var(--space-md);
}

.toc ul {
  list-style: none;
  margin: 0;
}

.toc li {
  margin-bottom: var(--space-sm);
  padding-left: var(--space-lg);
  position: relative;
}

.toc li::before {
  content: '§';
  position: absolute;
  left: 0;
  color: var(--color-accent);
  font-weight: 600;
}

/* Language badges */
.lang-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lang-badge.python {
  background: var(--color-python);
  color: white;
}

.lang-badge.stata {
  background: var(--color-stata);
  color: white;
}

.lang-badge.r {
  background: var(--color-r);
  color: white;
}

/* Mathematical notation */
.equation {
  display: block;
  text-align: center;
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  background: var(--color-bg-alt);
  border-radius: 8px;
  overflow-x: auto;
}

/* Lead paragraph */
.lead {
  font-size: 1.25rem;
  color: var(--color-text-light);
  line-height: 1.8;
  margin-bottom: var(--space-xl);
}

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--color-accent);
  padding-left: var(--space-lg);
  margin: var(--space-xl) 0;
  font-style: italic;
  color: var(--color-text-light);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: var(--space-xl);
  }
  
  .module-header {
    margin: calc(-1 * var(--space-xl));
    margin-bottom: var(--space-xl);
    padding: var(--space-xl);
  }
  
  .mobile-menu-toggle {
    display: block;
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    z-index: 101;
    padding: var(--space-md);
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    font-size: 1.5rem;
  }
  
  .guide-cards {
    grid-template-columns: 1fr;
  }
  
  .hotspot-tooltip {
    width: 200px;
    max-width: 200px;
    font-size: 0.75rem;
    padding: var(--space-sm) var(--space-md);
  }

  /* On mobile, position tooltips to avoid edge clipping */
  .hotspot-tooltip.left,
  .hotspot-tooltip.right {
    width: 180px;
    max-width: 180px;
  }
  
  .ide-sidebar {
    display: none;
  }
}

@media (min-width: 1025px) {
  .mobile-menu-toggle {
    display: none;
  }
}

/* Print styles */
@media print {
  .sidebar, .mobile-menu-toggle, .nav-footer {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
    padding: 0;
  }
  
  .hotspot {
    display: none;
  }
}

/* Smooth scroll offset for fixed elements */
:target {
  scroll-margin-top: var(--space-xl);
}

/* ===========================================
   PASSWORD PROTECTION OVERLAY
   =========================================== */
.password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--color-primary) 0%, #0d1f3c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.password-modal {
  background: white;
  padding: var(--space-3xl);
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  max-width: 800px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
}

.password-modal .course-description {
  text-align: left;
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 4px solid var(--color-primary);
}

.password-modal .course-description h3 {
  margin: 0 0 1rem 0;
  color: var(--color-primary);
  font-size: 1.1rem;
}

.password-modal .module-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.password-modal .module-list li {
  padding: 0.5rem 0.75rem;
  background: white;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--color-text);
  border: 1px solid #e2e8f0;
}

.password-modal .module-list li strong {
  color: var(--color-primary);
}

.password-modal .access-note {
  margin: 1.5rem 0;
  padding: 1rem;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #92400e;
}

.password-modal .access-note a {
  color: #d97706;
  font-weight: 600;
}

.password-modal .password-form {
  max-width: 350px;
  margin: 0 auto;
}

.password-modal h2 {
  margin-top: 0;
  color: var(--color-primary);
  font-size: 1.75rem;
}

.password-modal p {
  color: var(--color-text);
}

.password-modal input[type="password"] {
  width: 100%;
  padding: var(--space-md);
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: var(--space-md);
  transition: border-color 0.2s ease;
}

.password-modal input[type="password"]:focus {
  outline: none;
  border-color: var(--color-accent);
}

.password-modal button {
  width: 100%;
  padding: var(--space-md);
  font-size: 1rem;
  font-weight: 600;
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.password-modal button:hover {
  background: #dd6b20;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(237, 137, 54, 0.4);
}

/* ===========================================
   CHATBOT WIDGET
   =========================================== */
.chatbot-widget {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 9999;
  display: block !important;
}

.chatbot-toggle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  font-size: 2.5rem;
}

.chatbot-toggle:hover {
  background: var(--color-secondary);
  transform: scale(1.05);
}

.chatbot-panel {
  position: absolute;
  bottom: 115px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 2 * var(--space-xl));
  height: 500px;
  max-height: calc(100vh - 150px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.chatbot-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chatbot-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chatbot-header h3 {
  margin: 0;
  font-size: 1rem;
  color: white;
}

.chatbot-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chatbot-close:hover {
  opacity: 1;
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.chat-message {
  max-width: 85%;
  padding: var(--space-sm) var(--space-md);
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-message p {
  margin: 0;
}

.chat-message.user {
  background: var(--color-primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  background: var(--color-bg-alt);
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chatbot-input-area {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-sm);
}

.chatbot-input-area textarea {
  flex: 1;
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  resize: none;
}

.chatbot-input-area textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.chatbot-input-area button {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.chatbot-input-area button:hover {
  background: #dd6b20;
}

/* Mobile adjustments for chatbot */
@media (max-width: 480px) {
  .chatbot-widget {
    bottom: var(--space-md);
    right: var(--space-md);
  }

  .chatbot-panel {
    width: calc(100vw - 2 * var(--space-md));
    height: calc(100vh - 100px);
    bottom: 65px;
  }

  .chatbot-toggle {
    width: 50px;
    height: 50px;
  }
}

/* Hide chatbot and password overlay in print */
@media print {
  .chatbot-widget,
  .password-overlay {
    display: none !important;
  }
}

/* ===========================================
   RUN CODE BUTTON & OUTPUT SIMULATION
   Shows simulated output for code examples
   =========================================== */

/* Run button styling */
.run-btn {
  background: #22c55e;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
  display: none; /* Hidden by default, shown for active tab */
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  transition: background 0.2s ease;
}

.run-btn::before {
  content: '▶';
  font-size: 0.7rem;
}

.run-btn:hover {
  background: #16a34a;
}

/* Show run button only for active tab */
.tab-content.active .run-btn {
  display: inline-flex;
}

/* Output simulation container */
.output-simulation {
  background: #1e1e1e;
  border-radius: 8px;
  margin: 1rem 0;
  overflow: hidden;
  font-family: var(--font-code);
  font-size: 0.8rem;
  display: none;
}

.output-simulation.visible {
  display: block;
}

.output-header {
  background: #333;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ccc;
  font-size: 0.75rem;
}

.output-body {
  padding: 1rem;
  color: #d4d4d4;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 350px;
  overflow-y: auto;
}

/* Output syntax highlighting */
.output-body .out-green {
  color: #4ec9b0;
}

.output-body .out-yellow {
  color: #dcdcaa;
}

.output-body .out-blue {
  color: #569cd6;
}

.output-body .out-num {
  color: #b5cea8;
}

.output-body .out-str {
  color: #ce9178;
}

.output-body .out-comment {
  color: #6a9955;
}

/* Close button for output */
.close-output {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
}

.close-output:hover {
  color: white;
}

/* New format: code-output-wrapper for Module 00 setup guides */
.code-output-wrapper {
  margin: 1rem 0 2rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.code-output-wrapper .code-output {
  background: #1e1e1e;
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-code);
  font-size: 0.85rem;
}

.code-output-wrapper .output-header {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #e2e8f0;
  font-size: 0.8rem;
  font-family: var(--font-body);
  border-bottom: 1px solid #4a5568;
}

.code-output-wrapper .output-icon {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-output-wrapper .output-content {
  padding: 1rem 1.25rem;
  color: #d4d4d4;
  overflow-x: auto;
  max-height: 450px;
  overflow-y: auto;
  line-height: 1.5;
}

.code-output-wrapper .output-content pre {
  margin: 0;
  background: transparent;
  padding: 0;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Output syntax highlighting classes */
.output-prompt {
  color: #4ec9b0;
  font-weight: 600;
}

.output-result {
  color: #d4d4d4;
}

.output-comment {
  color: #6a9955;
  font-style: italic;
}
