/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
  /* New FLB Brand Colors */
  --flb-cyan: #0086cb;
  /* RGB 0, 134, 203 */
  --flb-blue: #00255e;
  /* RGB 0, 40, 94 */

  /* Semantic Variables - Default (Dark Mode) */
  --bg-color: var(--flb-blue);
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --primary: var(--flb-cyan);
  --secondary: #10b981;
  /* Keeping green for success/correct/secondary actions */
  --quiz-accent: #f59e0b;
  --card-bg: rgba(255, 255, 255, 0.1);
  --card-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

/* Light Mode Overrides */
body.light-mode {
  --bg-color: #ffffff;
  --text-main: var(--flb-blue);
  --text-muted: rgba(0, 37, 94, 0.75);
  --card-bg: rgba(0, 134, 203, 0.05);
  /* Very light cyan tint */
  --card-border: rgba(0, 40, 94, 0.15);
  --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Calibri', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  /* Mobile Default: Stacked */
  min-height: 100vh;
  overflow-x: hidden;
  /* Prevent horizontal scroll */
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 1001;
  /* Above sidebar */
  backdrop-filter: blur(10px);
}

.header-toggle-btn {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  margin-right: 1rem;
  padding: 0.5rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.header-title {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 700;
}

/* Sidebar (Mobile Header) */
.sidebar {
  width: 280px;
  background: var(--card-bg);
  border-right: 1px solid var(--card-border);
  padding: 1.5rem;
  /* padding-top: 80px;  REMOVED: Sidebar now starts physically below header */
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
  height: calc(100vh - 60px);
  /* Full height minus header */
  position: fixed;
  top: 60px;
  /* Starts below header */
  left: -280px;
  /* Hidden by default on mobile */
  z-index: 1000;
  transition: transform 0.3s ease-in-out, left 0.3s ease-in-out;
  backdrop-filter: blur(10px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar.open {
  left: 0;
}

/* Desktop Sidebar Behavior (Collapsible) */
@media (min-width: 769px) {
  .sidebar {
    left: 0;
    /* Always visible by default on desktop */
    padding-top: 80px;
    transform: translateX(0);
  }

  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-collapsed .main-content {
    margin-left: 0;
  }

  .main-content {
    margin-left: 300px;
    /* Space for sidebar */
    transition: margin-left 0.3s ease-in-out;
  }

  /* Hide specific Mobile-Only header elements in sidebar if any */
  .sidebar-header-mobile {
    display: none;
  }
}

.sidebar-header-mobile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.close-sidebar-btn {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 2rem;
  cursor: pointer;
}



.logo-area h1 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

.control-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* Slider Customization */
input[type=range] {
  width: 100%;
  accent-color: var(--primary);
  margin-bottom: 0.5rem;
  height: 24px;
  /* Touchable height */
}

.level-indicator {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: bold;
  text-align: center;
}

/* Unified Menu Buttons */
.nav-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-btn {
  width: 100%;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  padding: 0.8rem;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 1rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nav-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* Light Mode for Nav Buttons */
body.light-mode .nav-btn {
  background: #f1f5f9;
  color: var(--flb-blue);
  border: 1px solid #e2e8f0;
}

body.light-mode .nav-btn.active {
  background: var(--flb-cyan);
  color: white;
  border-color: var(--flb-cyan);
}

body.light-mode .nav-btn:hover:not(.active) {
  background: #e2e8f0;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.5rem;
  padding-top: 80px;
  /* Space for fixed header */
  position: relative;
  width: 100%;
}

.main-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 20%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.15) 0%, transparent 20%);
  pointer-events: none;
  z-index: -1;
}

.section {
  display: none;
  max-width: 100%;
  /* Full width on mobile */
  margin: 0 auto;
  animation: fadeIn 0.5s ease-out;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Learning Cards */
.scenario-box {
  background: linear-gradient(135deg, rgba(0, 134, 203, 0.1), rgba(0, 134, 203, 0.05));
  /* FLB-Cyan */
  border: 1px solid rgba(0, 134, 203, 0.2);
  padding: 1.25rem;
  border-radius: 1rem;
  margin-bottom: 2rem;
  border-left: 4px solid var(--primary);
}

.layer-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--glass-shadow);
}

/* Disabled hover on touch devices usually, keeping for consistency */
.layer-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.layer-header {
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
  /* Allow wrapping on very small screens */
  gap: 0.5rem;
  cursor: pointer;
  /* Clickable */
  user-select: none;
}

.layer-header::after {
  content: '▼';
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.3s ease;
  margin-left: auto;
}

.layer-card.collapsed .layer-header::after {
  transform: rotate(-90deg);
}

.layer-card.collapsed .layer-header {
  border-bottom: none;
  /* Remove border when collapsed */
}

.layer-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
  margin-right: 0.5rem;
}

.layer-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  /* Stacked content on mobile */
  gap: 1.5rem;
  transition: all 0.3s ease-in-out;
  max-height: 2000px;
  /* Limit for animation */
  overflow: hidden;
  opacity: 1;
}

.layer-card.collapsed .layer-content {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  pointer-events: none;
}

.layer-info h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.layer-info h3:first-child {
  margin-top: 0;
}

.example-box {
  background: rgba(16, 185, 129, 0.1);
  padding: 1rem;
  border-radius: 0.5rem;
  border-left: 3px solid var(--secondary);
  font-size: 0.95rem;
}

code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #fbbf24;
  word-break: break-word;
  /* Handle long codes on mobile */
}

/* Quiz Styles */
.quiz-header {
  display: flex;
  flex-direction: column;
  /* Stacked header on mobile */
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.score-badge {
  background: var(--quiz-accent);
  color: black;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-weight: bold;
  align-self: flex-start;
}

.question-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 1.5rem;
  border-radius: 1rem;
}

.question-text {
  font-size: 1.15rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 1rem;
  /* Good touch target */
  border-radius: 0.5rem;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

.option-btn.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.2);
}

.option-btn.correct {
  border-color: var(--secondary);
  background: rgba(16, 185, 129, 0.2);
}

.option-btn.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
}

.feedback-area {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 0.5rem;
  animation: fadeIn 0.3s;
}

.feedback-correct {
  background: rgba(16, 185, 129, 0.1);
  color: var(--secondary);
  border: 1px solid var(--secondary);
}

.feedback-wrong {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid #ef4444;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 1rem 1.5rem;
  /* Larger touch area */
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  margin-top: 1.5rem;
  width: 100%;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Utils */
.hidden {
  display: none !important;
}

/* Interactive Elements */
.interactive-item {
  cursor: pointer;
  border-bottom: 1px dashed var(--text-muted);
  transition: all 0.2s;
  margin-right: 0.5rem;
  display: inline-block;
  padding: 2px 0;
  /* Slight padding for touch */
}

.interactive-item:hover {
  color: var(--primary);
  border-bottom: 1px solid var(--primary);
}

.match-item.status-correct {
    border: 2px solid var(--secondary) !important;
    background: rgba(16, 185, 129, 0.2) !important;
}

.match-item.status-wrong {
    border: 2px solid #ef4444 !important;
    background: rgba(239, 68, 68, 0.2) !important;
}

.interactive-item.hardware {
  color: #e0f2fe;
}

body.light-mode .interactive-item.hardware {
  color: var(--flb-blue);
  font-weight: bold;
}

.interactive-item.protocol {
  font-family: 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fce7f3;
  border-bottom: none;
}

body.light-mode .interactive-item.protocol {
  color: var(--flb-blue);
  background: rgba(0, 134, 203, 0.1);
  /* Light Cyan background */
  font-weight: bold;
}

.interactive-item.protocol:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.light-mode .interactive-item.protocol:hover {
  background: rgba(0, 134, 203, 0.2);
}

/* Detail Views */
.detail-container {
  padding: 0 1.25rem 1.25rem 1.25rem;
  animation: slideDown 0.3s ease-out;
}

.detail-box {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--card-border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-top: 0.5rem;
  position: relative;
  box-shadow: var(--glass-shadow);
}

.detail-box.hardware {
  border-left: 3px solid var(--primary);
}

.detail-box.protocols {
  border-left: 3px solid #f472b6;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: var(--text-main);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  /* Easy to tap */
  cursor: pointer;
  line-height: 1;
  padding: 0 0.5rem;
}

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Glossary & Tooltips */
.glossary-term {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  position: relative;
  color: #a5f3fc;
  font-weight: 500;
}

body.light-mode .glossary-term {
  color: var(--flb-blue);
  border-bottom-color: var(--flb-blue);
}

/* Visualization Tooltips */
.viz-info-content .interactive-item {
  position: relative;
  cursor: help;
  /* Question mark cursor */
  border-bottom: 1px dotted rgba(255, 255, 255, 0.8);
  text-decoration: none !important;
  /* No underline */
  display: inline-block;
  color: white !important;
  /* Inherit white */
}

/* Tooltip container must allow overflow if needed, but absolute positioning relates to nearest positioned ancestor. 
   If interactive-item is relative, tooltip is relative to IT. */

.viz-info-content .interactive-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  /* Move up a bit more */
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: white;
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  /* Very high z-index */
  border: 1px solid var(--primary);
  text-align: center;
  pointer-events: none;
  display: block;
  /* Ensure display */
}

.glossary-term::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: normal;
  width: max-content;
  max-width: 200px;
  /* Smaller max width for mobile */
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
  margin-bottom: 5px;
  font-weight: normal;
  text-align: center;
}

.glossary-term:hover::after {
  opacity: 1;
}

/* AI Prompt Box */
.ai-prompt-box {
  margin-top: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 0.8rem;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-label {
  font-weight: bold;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prompt-text {
  font-family: 'Courier New', monospace;
  background: #0f172a;
  padding: 0.6rem;
  border-radius: 4px;
  color: #e2e8f0;
  user-select: all;
  border-left: 3px solid var(--primary);
  overflow-x: auto;
  /* Scroll if too wide on mobile */
}

/* Quiz Badges & Progress */
.quiz-progress {
  display: flex;
  flex-wrap: wrap;
  /* Wrap on mobile */
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  gap: 0.5rem;
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #1e293b;
}

.badge-easy {
  background-color: #86efac;
}

.badge-medium {
  background-color: #fca5a5;
}

.badge-hard {
  background-color: #f87171;
  color: white;
  border: 1px solid #ef4444;
}

/* End Screen Summary */
.summary-list {
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.summary-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  padding: 1rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
}

.summary-item.summary-correct {
  border-left: 3px solid var(--secondary);
}

.summary-item.summary-wrong {
  border-left: 3px solid #ef4444;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 1rem;
}

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

.text-green {
  color: var(--secondary);
  font-weight: bold;
}

.text-red {
  color: #ef4444;
  font-weight: bold;
}

.summary-explanation {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

/* ------------------------------------------------------------------ */
/* DESKTOP OVERRIDES                                                  */
/* ------------------------------------------------------------------ */

@media (min-width: 768px) {
  body {
    flex-direction: row;
    /* Side-by-side */
    height: 100vh;
    overflow: hidden;
    /* Scroll in containers */
  }

  /* Sidebar Fixed Width */
  .sidebar {
    width: 300px;
    height: calc(100% - 60px);
    /* Full height minus header */
    position: fixed;
    /* Fixed on desktop too to stay under header */
    top: 60px;
    left: 0;
    border-right: 1px solid var(--card-border);
    border-bottom: none;
    padding: 2rem;
    gap: 2rem;
    overflow-y: auto;
  }

  /* Hide burger on desktop - handled by header now, removed older class */

  .sidebar-header-mobile {
    display: none;
  }

  /* Main Content Area */
  .main-content {
    overflow-y: auto;
    padding: 2rem;
    padding-top: 80px;
    /* Keep space for header content-wise */
    margin-left: 300px;
    /* Ensure content starts after fixed sidebar */
  }

  .section {
    max-width: 1000px;
    /* Limit width for reading comfort */
  }

  .layer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  }

  .layer-header {
    padding: 1rem 1.5rem;
  }

  .layer-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    /* Split layout for cards */
    gap: 2rem;
    padding: 1.5rem;
  }

  .quiz-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .score-badge {
    align-self: center;
  }

  .question-card {
    padding: 2rem;
  }

  .question-text {
    font-size: 1.25rem;
  }

  .detail-container {
    padding: 0 1.5rem 1.5rem 1.5rem;
  }

  .close-btn {
    font-size: 1.5rem;
  }

  .glossary-term::after {
    max-width: 250px;
  }
}

/* Impressum Link */
.impressum-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  border-bottom: 1px dotted var(--text-muted);
  transition: color 0.2s, border-bottom 0.2s;
}

.impressum-link:hover {
  color: var(--primary);
  border-bottom: 1px solid var(--primary);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: var(--glass-shadow);
}

/* Visualization Module Styles */
.viz-stage {
  display: grid;
  grid-template-columns: 1fr 0.5fr 1fr;
  gap: 1rem;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  padding: 2rem;
  border-radius: 1rem;
  min-height: 400px;
  align-items: center;
  border: 1px solid var(--card-border);
}

.viz-col-title {
  text-align: center;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Light Mode Override for specific Viz Elements if needed, 
   but Stage has dark background so white text is good. 
   Unless user meant OUTSIDE the stage? */
body.light-mode .viz-header h3 {
  color: var(--flb-blue);
}

.stack-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.viz-layer {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 0.5rem;
  text-align: center;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.3s;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.viz-layer.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.viz-middle {
  position: relative;
  height: 100%;
  display: flex;
  justify-content: center;
}

.viz-connection-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  opacity: 0.3;
}

.data-packet {
  position: absolute;
  font-size: 1.5rem;
  z-index: 10;
  transition: all 0.5s ease-in-out;
  /* Default position hidden or centered */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.data-packet.visible {
  opacity: 1;
}

/* Info Popup */
/* Info Popup */
.viz-info-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--primary);
  border-radius: 0.5rem;
  padding: 1.5rem;
  width: 300px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 20;
  backdrop-filter: blur(10px);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color: white !important;
  /* Force white text */
}

@keyframes popIn {
  from {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }

  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.viz-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  font-weight: bold;
  color: white !important;
  /* Force white header */
}

.viz-info-row {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.viz-select {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  padding: 0.5rem;
  border-radius: 0.5rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .viz-stage {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 2rem;
  }

  .viz-middle {
    height: 50px;
    /* Space for packet to travel between stacks visually if we stacked them vertically */
    display: none;
    /* Hide middle line on mobile for simpler vertical stacking? Or keep it? */
  }

  /* On mobile, maybe better to just use absolute positioning relative to container for packet? 
       Actually, the grid columns 1fr 0.5fr 1fr is hard on mobile.
       Let's stack: Client Top, Server Bottom.
    */

  .viz-stage {
    display: flex;
    flex-direction: column;
  }

  .viz-middle {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--card-border);
    margin: 1rem 0;
  }

  .data-packet {
    /* Packet will need custom positioning logic on mobile or simple center */
  }
}

/* --- Stationen-Lernen Styles --- */

#stations-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.station-overview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.station-score-display {
  background: var(--card-bg);
  border: 1px solid var(--primary);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-weight: bold;
  font-size: 1.1rem;
}

.score-highlight {
  color: var(--secondary);
  font-size: 1.2rem;
}

.station-intro {
  margin-bottom: 2rem;
  color: var(--text-muted);
}

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

.station-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 1.5rem;
  border-radius: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 200px;
}

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

.station-card.completed {
  border-color: var(--secondary);
  background: rgba(16, 185, 129, 0.05);
  /* Very light green tint */
}

.station-card-header h3 {
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.status-icon {
  display: inline-block;
  background: var(--secondary);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.station-progress {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: bold;
}

/* Station Detail View */
.station-detail-view {
  animation: fadeIn 0.3s ease-out;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  margin-bottom: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.btn-back:hover {
  color: var(--primary);
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 2rem;
}

.task-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  padding: 1.5rem;
  position: relative;
}

.task-card.mandatory {
  border-left: 4px solid var(--primary);
}

.task-card.bonus {
  border-left: 4px solid var(--quiz-accent);
}

.task-card.correct {
  border-color: var(--secondary);
  background: rgba(16, 185, 129, 0.05);
}

/* Red border for wrong answer card */
.task-card.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}


.task-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.task-badge {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: bold;
}

.task-badge.mandatory {
  background: rgba(0, 134, 203, 0.2);
  color: #a5f3fc;
}

.task-badge.bonus {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
}

body.light-mode .task-badge.bonus {
  background: rgba(245, 158, 11, 0.3);
  color: #92400e;
  /* Darker amber for readability */
  border: 1px solid rgba(245, 158, 11, 0.4);
}



.task-question {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.task-options {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.task-feedback {
  margin-top: 1.5rem;
  animation: slideDown 0.3s ease-out;
}

.feedback-box {
  padding: 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
}

.feedback-box.success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  /* Lighter green for dark mode readability */
}

/* Light mode override for success text */
body.light-mode .feedback-box.success {
  color: #047857;
  /* Darker green */
}

.feedback-box.error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

body.light-mode .feedback-box.error {
  color: #b91c1c;
}

/* --- Ordering Task Styles --- */
.ordering-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.ordering-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 0.8rem;
  border-radius: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.ordering-item:hover {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.05);
}

.item-text {
  font-weight: 500;
}

.order-controls {
  display: flex;
  gap: 0.2rem;
}

.order-controls button {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-main);
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.order-controls button:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.order-controls button:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}


/* --- Matching Task Styles --- */
.matching-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.matching-pool-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.matching-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 50px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  border: 1px dashed var(--card-border);
}

.matching-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.match-group {
  flex: 1;
  min-width: 200px;
  /* Stack on mobile */
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.group-title {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.5rem;
  font-size: 0.9rem;
  font-weight: bold;
  text-align: center;
  border-bottom: 1px solid var(--card-border);
}

.group-area {
  padding: 0.5rem;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.match-item {
  background: var(--card-bg);
  border: 1px solid var(--primary);
  padding: 0.5rem 0.8rem;
  border-radius: 0.4rem;
  font-size: 0.9rem;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s;
  background: rgba(0, 134, 203, 0.2);
  /* Tinted */
}

.match-item.interactive:hover {
  background: var(--primary);

  color: white;
}

/* --- Drag & Drop Feedback --- */
.match-item[draggable="true"] {

  cursor: grab;
}

.match-item[draggable="true"]:active {
  cursor: grabbing;
}

.match-group {
  transition: border-color 0.2s, background-color 0.2s;
}

.match-group:hover,
.group-area:hover {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.05);
}

.matching-pool {
  min-height: 80px;
  /* Ensure drop target is large enough */
}


/* --- Cloze (Lückentext) Styles --- */
.cloze-text {
  line-height: 2;
  font-size: 1.05rem;
}

.cloze-select {
  background: var(--card-bg);
  color: var(--primary);
  border: 1px solid var(--card-border);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 1rem;
  margin: 0 0.3rem;
  font-weight: bold;
  cursor: pointer;
}

.cloze-select:disabled {
  cursor: default;
  opacity: 1;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: rgba(0, 134, 203, 0.1);
  padding: 0.2rem 0.5rem;
}

.cloze-select option {
  background: #1e293b;
  /* Dark background for options */
  color: white;
}


.match-item.interactive:active {
  transform: scale(0.95);
}


.match-item.locked {
  cursor: default;
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--card-border);
}

/* --- OSI Table Styles (Station 5) --- */
.osi-table-container {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.osi-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.osi-table th,
.osi-table td {
  border: 1px solid var(--card-border);
  padding: 0.5rem;
  text-align: center;
}

.osi-table th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--primary);
}

.layer-num {
  font-weight: bold;
  color: var(--text-muted);
  width: 40px;
}

.drop-cell {
  background: rgba(0, 0, 0, 0.1);
  height: 60px;
  /* Minimum height for drop target */
  vertical-align: middle;
  transition: background 0.2s;
}

.drop-cell:hover {
  background: rgba(255, 255, 255, 0.05);
}


.drop-cell .match-item {
  margin: 0 auto;
}

/* Reset Button Styles */
.btn-reset {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
  transition: all 0.2s;
}


.btn-reset:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: #ef4444;
}

/* Attempts & Hints */
.attempts-badge {
  font-size: 0.8rem;
  color: #ef4444;
  font-weight: bold;
  margin-left: 0.5rem;
  background: rgba(239, 68, 68, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.hint-star {
  cursor: pointer;
  font-size: 1.2rem;
  margin-right: 0.5rem;
  color: #fbbf24;
  transition: transform 0.2s;
  user-select: none;
}

.hint-star:hover {
  transform: scale(1.2) rotate(15deg);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
}

/* Overview Stats */
.station-stats {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-weight: bold;
}

.stat-correct {
  color: #34d399;
}

.stat-wrong {
  color: #f87171;
}

/* Validation Feedback for Drag Items */
.match-item.prop-correct {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  color: #065f46;
}

.match-item.prop-wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  color: #7f1d1d;
}
/* --- Zahlungsverzug Strainer Additions --- */

.cloze-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    color: inherit;
    font-family: inherit;
    font-size: 1rem;
    margin: 0 4px;
}

.cloze-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.2);
}

option {
    background: #1e293b; /* Fallback dark bg for options */
    color: white;
}

body.light-mode option {
    background: white;
    color: black;
}

/* General Input Styling for Calculators */
input[type="text"], input[type="number"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
} 

input[type="text"]:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
}

.station-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary) !important;
    background: rgba(255, 255, 255, 0.15) !important;
}

body.light-mode .station-card:hover {
    background: rgba(0, 134, 203, 0.1) !important;
}
