/* Windows 95 Explorer Style */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --win95-bg: #c0c0c0;
  --win95-white: #ffffff;
  --win95-dark: #808080;
  --win95-darker: #404040;
  --win95-blue: #000080;
  --win95-title-blue: #0a246a;
  --win95-title-gradient: linear-gradient(90deg, #0a246a 0%, #a6caf0 100%);
  --win95-light-blue: #d4e4f7;
  --win95-highlight: #0000ff;
  --win95-text: #000000;
  --win95-window-bg: #ece9d8;
  --success: #008000;
  --error: #cc0000;
  --warning: #ff8c00;
  --border-light: #dfdfdf;
  --border-dark: #808080;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--win95-light-blue);
  color: var(--win95-text);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* Classic beveled border effect */
.bevel-out {
  border: 2px solid;
  border-color: var(--win95-white) var(--win95-dark) var(--win95-dark) var(--win95-white);
}

.bevel-in {
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
}

/* Navigation - Title Bar Style */
.navbar {
  background: var(--win95-title-gradient);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  border-bottom: 2px solid var(--win95-dark);
  color: white;
}

.nav-brand {
  color: white;
  text-decoration: none;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.nav-brand:hover {
  color: #ffff00;
}

.nav-breadcrumb {
  color: white;
  flex: 1;
  font-size: 0.9rem;
}

.nav-breadcrumb a {
  color: #ffff99;
  text-decoration: underline;
  cursor: pointer;
}

.nav-breadcrumb a:hover {
  color: #ffff00;
}

.nav-breadcrumb .separator {
  margin: 0 0.5rem;
  color: #a6caf0;
}

.pyodide-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: white;
  background: rgba(0,0,0,0.2);
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffcc00;
  animation: pulse 1.5s infinite;
}

.status-dot.ready {
  background: #00ff00;
  animation: none;
}

.status-dot.error {
  background: #ff0000;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 128, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  text-align: center;
  max-width: 400px;
  background: var(--win95-bg);
  border: 2px solid;
  border-color: var(--win95-white) var(--win95-dark) var(--win95-dark) var(--win95-white);
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--win95-dark);
  border-top-color: var(--win95-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-message {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--win95-text);
  font-weight: bold;
}

.progress-bar {
  height: 20px;
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  background: var(--win95-blue);
  width: 0%;
  transition: width 0.3s ease;
}

.loading-hint {
  font-size: 0.85rem;
  color: var(--win95-darker);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--win95-bg);
  border: 2px solid;
  border-color: var(--win95-white) var(--win95-dark) var(--win95-dark) var(--win95-white);
  padding: 1.5rem;
  max-width: 420px;
  text-align: left;
}

.modal-content h3 {
  margin-bottom: 1rem;
  color: var(--win95-text);
  background: var(--win95-title-gradient);
  color: white;
  padding: 0.25rem 0.5rem;
  margin: -1.5rem -1.5rem 1rem -1.5rem;
  font-size: 0.9rem;
}

.modal-note {
  font-size: 0.9rem;
  color: var(--win95-darker);
  margin: 1rem 0;
  padding: 0.5rem;
  background: var(--win95-white);
  border: 1px solid var(--win95-dark);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Home page */
.home-header {
  text-align: center;
  margin-bottom: 2rem;
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 1.5rem;
}

.home-header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
  color: var(--win95-title-blue);
}

.subtitle {
  color: var(--win95-darker);
  font-size: 1rem;
}

.tech-note {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #ffffcc;
  border: 1px solid #cccc00;
  font-size: 0.8rem;
  color: var(--win95-darker);
  text-align: left;
}

.tech-note strong {
  color: var(--win95-text);
}

.tech-note a {
  color: var(--win95-blue);
}

.overall-progress {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--win95-bg);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
}

.overall-progress .progress-bar {
  width: 200px;
  margin: 0;
  height: 16px;
}

/* Module grid */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.module-card {
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-white) var(--win95-dark) var(--win95-dark) var(--win95-white);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.1s;
  position: relative;
}

.module-card:hover {
  background: var(--win95-light-blue);
}

.module-card:active {
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
}

.module-card .module-number {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--win95-blue);
  color: white;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
}

.module-card h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  padding-right: 35px;
  color: var(--win95-title-blue);
}

.module-card .module-info {
  color: var(--win95-darker);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.module-card .load-flag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.15rem 0.4rem;
  margin-left: 0.5rem;
  color: white;
  background: var(--warning);
}

.module-card .load-flag[style*="ef4444"] {
  background: var(--error) !important;
}

.module-card .loaded-flag {
  color: var(--success);
  font-size: 0.8rem;
  font-weight: bold;
}

.module-card .module-progress {
  margin-top: 0.5rem;
}

.module-card .progress-bar {
  height: 12px;
}

/* Module page */
.module-header {
  margin-bottom: 1.5rem;
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 1rem;
}

.module-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--win95-title-blue);
}

.module-header p {
  color: var(--win95-darker);
}

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.exercise-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-white) var(--win95-dark) var(--win95-dark) var(--win95-white);
  padding: 0.75rem 1rem;
  cursor: pointer;
}

.exercise-card:hover {
  background: var(--win95-light-blue);
}

.exercise-card:active {
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
}

.exercise-card.completed {
  border-left: 4px solid var(--success);
}

.exercise-num {
  background: var(--win95-bg);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--win95-blue);
}

.exercise-card.completed .exercise-num {
  background: var(--success);
  color: white;
  border-color: #006600 #00aa00 #00aa00 #006600;
}

.exercise-title {
  flex: 1;
}

.exercise-check {
  color: var(--success);
  font-size: 1.25rem;
  font-weight: bold;
}

/* Exercise page layout */
.exercise-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
}

/* Sidebar */
.sidebar {
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 0.75rem;
  height: fit-content;
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.sidebar h3 {
  font-size: 0.8rem;
  color: var(--win95-darker);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--win95-dark);
  padding-bottom: 0.25rem;
}

.sidebar-module {
  margin-bottom: 0.125rem;
}

.sidebar-module a {
  display: block;
  padding: 0.35rem 0.5rem;
  color: var(--win95-text);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
}

.sidebar-module a:hover {
  background: var(--win95-light-blue);
}

.sidebar-module.active a {
  background: var(--win95-blue);
  color: white;
}

/* Sidebar back link */
.sidebar-back {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--win95-dark);
}

.sidebar-back a {
  color: var(--win95-blue);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
}

.sidebar-back a:hover {
  text-decoration: underline;
}

/* Sidebar exercises */
.sidebar-exercises {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-exercise a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.4rem;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--win95-text);
  text-decoration: none;
}

.sidebar-exercise a:hover {
  background: var(--win95-light-blue);
}

.sidebar-exercise.active a {
  background: var(--win95-blue);
  color: white;
}

.sidebar-exercise.completed a {
  color: var(--success);
}

.sidebar-exercise.completed.active a {
  background: var(--win95-blue);
  color: white;
}

.sidebar-exercise .ex-num {
  color: var(--win95-darker);
  min-width: 1.2rem;
}

.sidebar-exercise.active .ex-num {
  color: white;
}

.sidebar-exercise .ex-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-exercise .ex-check {
  color: var(--success);
  font-size: 0.75rem;
}

.sidebar-exercise.active .ex-check {
  color: white;
}

/* Exercise main content */
.exercise-main {
  min-width: 0;
}

.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 0.75rem;
}

.exercise-header h1 {
  font-size: 1.1rem;
  color: var(--win95-title-blue);
}

.nav-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Buttons - Windows 95 style */
.btn {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: var(--win95-bg);
  color: var(--win95-text);
  border: 2px solid;
  border-color: var(--win95-white) var(--win95-dark) var(--win95-dark) var(--win95-white);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  font-family: inherit;
}

.btn:hover {
  background: #d4d4d4;
}

.btn:active {
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
}

.btn:disabled {
  color: var(--win95-dark);
  cursor: not-allowed;
}

.btn-primary {
  background: var(--win95-blue);
  color: white;
  border-color: #0000cc #000066 #000066 #0000cc;
}

.btn-primary:hover {
  background: #0000aa;
}

.btn-primary:active {
  border-color: #000066 #0000cc #0000cc #000066;
}

.btn-nav {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

/* Docstring */
.docstring {
  background: var(--win95-white);
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 1rem;
  margin-bottom: 1rem;
}

.docstring pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--win95-text);
}

/* Setup code */
.setup-code {
  margin-bottom: 1rem;
}

.setup-code h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--win95-title-blue);
}

.readonly-badge {
  font-size: 0.7rem;
  color: var(--win95-darker);
  background: var(--win95-bg);
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--win95-dark);
  font-weight: normal;
}

.setup-code pre {
  background: #fffff8;
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 0.75rem;
  overflow-x: auto;
}

.setup-code code {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.9rem;
  color: var(--win95-text);
}

/* Editor section */
.editor-section {
  margin-bottom: 1rem;
}

.editor-section h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--win95-title-blue);
}

.editor-section .CodeMirror {
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  font-size: 0.95rem;
  height: auto;
  min-height: 120px;
}

.editor-actions {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.auto-save-indicator {
  font-size: 0.75rem;
  color: var(--success);
  margin-left: auto;
  font-style: italic;
}

/* Output section */
.output-section {
  margin-bottom: 1rem;
}

.output-section h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--win95-title-blue);
}

.output-section pre {
  background: #000000;
  color: #00ff00;
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 0.75rem;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* Result section */
.result-section {
  margin-bottom: 1rem;
}

.result-pass, .result-fail {
  padding: 0.75rem 1rem;
  font-weight: bold;
  font-size: 1rem;
  border: 2px solid;
}

.result-pass {
  background: #ccffcc;
  border-color: #009900 #00cc00 #00cc00 #009900;
  color: #006600;
}

.result-fail {
  background: #ffcccc;
  border-color: #990000 #cc0000 #cc0000 #990000;
  color: #660000;
}

.result-hint {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #ffffcc;
  border: 1px solid #cccc00;
  font-size: 0.85rem;
  color: var(--win95-darker);
}

/* Scratchpad */
.scratchpad-section {
  margin-top: 1.5rem;
  border: 2px solid;
  border-color: var(--win95-white) var(--win95-dark) var(--win95-dark) var(--win95-white);
  background: var(--win95-bg);
}

.scratchpad-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  user-select: none;
  font-weight: bold;
  font-size: 0.9rem;
  color: var(--win95-title-blue);
}

.scratchpad-header:hover {
  background: var(--win95-light-blue);
}

.scratchpad-arrow {
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.scratchpad-section.open .scratchpad-arrow {
  transform: rotate(90deg);
}

.scratchpad-hint {
  font-weight: normal;
  font-size: 0.8rem;
  color: var(--win95-darker);
  font-style: italic;
  margin-left: auto;
}

.scratchpad-body {
  border-top: 1px solid var(--win95-dark);
  padding: 0.75rem;
  background: var(--win95-white);
}

.scratchpad-body .CodeMirror {
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  font-size: 0.9rem;
  height: auto;
  min-height: 80px;
}

.scratchpad-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.scratchpad-output {
  margin-top: 0.5rem;
  background: #000000;
  color: #00ff00;
  border: 2px solid;
  border-color: var(--win95-dark) var(--win95-white) var(--win95-white) var(--win95-dark);
  padding: 0.5rem;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 150px;
  overflow-y: auto;
  min-height: 2rem;
}

.scratchpad-output:empty::before {
  content: 'Output will appear here...';
  color: #666666;
}

/* Responsive */
@media (max-width: 800px) {
  .exercise-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .container {
    padding: 1rem;
  }

  .navbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pyodide-status {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}
