/* 
   =========================================
   ARDUINO LEARNING PLATFORM - STYLES
   =========================================
   Panduan Personalisasi:
   - Warna Utama: Cari "--arduino-teal" atau "--primary"
   - Font: Cari "font-family" di bagian Section 1 (Root)
   - Komponen: Cari section yang sesuai untuk button, card, dll.
   =========================================
*/

/* =========================================
   1. VARIABLES & ROOT
   ========================================= */
:root {
  /* --- WARNA UTAMA --- */
  --arduino-teal: #00979c;
  --arduino-orange: #f39300;

  --primary: #00979c;
  --primary-light: #e6f5f6;
  --primary-hover: #008184;

  --secondary: #f39300;
  --secondary-light: #fff5e6;

  --success: #10b981;
  --success-light: #ecfdf5;

  --warning: #f59e0b;
  --warning-light: #fffbeb;

  --error: #ef4444;
  --error-light: #fef2f2;

  /* --- NEUTRAL TONES --- */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* --- BACKGROUND & TEXT --- */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;

  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* --- BORDER & RADIUS --- */
  --border-color: #e2e8f0;
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  --border-radius-xl: 30px;

  /* --- MODERN SHADOWS --- */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 40px -10px rgba(0, 0, 0, 0.12);

  --transition-speed: 0.3s;

  /* Syntax Highlighting Tokens */
  --syntax-comment: #64748b;
  --syntax-keyword: #00979C;
  --syntax-string: #10b981;
  --syntax-func: #f39300;
}

/* =========================================
   2. BASE STYLES
   ========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', 'Nunito', sans-serif;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all var(--transition-speed) ease;
  font-weight: 500;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: none;
}

/* =========================================
   3. (RESERVED FOR FUTURE GLOBAL SECTIONS)
   ========================================= */

/* =========================================
   4. SHARED UI COMPONENTS
   ========================================= */

/* --- Cards --- */
.card {
  background-color: var(--bg-surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--slate-100);
  padding: 40px;
  width: 100%;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--border-radius-xl);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 4px 14px 0 rgba(0, 151, 156, 0.39);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 6px 20px rgba(0, 151, 156, 0.23);
  transform: translateY(-2px);
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--slate-100);
  color: var(--slate-700);
}

.btn-secondary:hover {
  background-color: var(--slate-200);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  transition: all 0.2s;
}

.btn-icon i {
  font-size: 1.25rem;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  font-size: 1.1rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--slate-50);
  border: 1px solid var(--slate-300);
  border-radius: var(--border-radius-sm);
  color: var(--slate-800);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  transition: all 0.2s;
}


.input-wrapper .form-control {
  padding-left: 42px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* --- Alerts --- */
.alert {
  padding: 16px 20px;
  border-radius: var(--border-radius-md);
  margin-bottom: 24px;
  font-size: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  font-weight: 500;
  line-height: 1.6;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.alert-info {
  background-color: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}

.alert-success {
  background-color: var(--emerald-50);
  color: var(--emerald-600);
  border-color: rgba(5, 150, 105, 0.2);
}

.alert-error,
.alert-danger {
  background-color: var(--rose-50);
  color: var(--rose-600);
  border-color: rgba(225, 29, 72, 0.2);
}

.alert-warning {
  background-color: #fffbeb;
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.3);
  border-left: 4px solid var(--amber-500);
}

/* --- Debug Corner & Badges --- */
.debug-corner {
  background: var(--warning-light) !important;
  padding: 24px !important;
  border-radius: var(--border-radius-lg) !important;
  border: 1px solid rgba(245, 158, 11, 0.1) !important;
  margin: 32px 0 !important;
  box-shadow: var(--shadow-md);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-info {
  background-color: var(--slate-100);
  color: var(--slate-600);
}

.badge-success {
  background-color: var(--emerald-50);
  color: var(--emerald-600);
}

/* --- Tables --- */
.table-responsive {
  overflow-x: auto;
  width: 100%;
  border: 1px solid var(--slate-100);
  border-radius: var(--border-radius-lg);
  margin: 32px 0;
  box-shadow: var(--shadow-md);
  background: white;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
}

.data-table th {
  background: var(--slate-50);
  color: var(--slate-800) !important;
  font-weight: 700;
  padding: 16px 20px;
  text-align: left;
  border-bottom: 2px solid var(--slate-100);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-100);
  border-right: 1px solid var(--slate-50);
  color: var(--slate-700);
  font-size: 0.95rem;
  line-height: 1.6;
}

.data-table td:last-child {
  border-right: none;
}

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

.data-table tr:nth-child(even) {
  background-color: #fafbfd;
}

.data-table tr:hover {
  background-color: var(--primary-light) !important;
}

.module-content code, .data-table code {
  background: var(--slate-100);
  color: var(--arduino-teal);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-family: 'Fira Code', monospace;
  font-size: 0.9em;
}

/* =========================================
   4. LAYOUTS (Admin & App)
   ========================================= */

/* --- Admin Dashboard --- */
.admin-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--slate-200);
  padding: 0 24px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  color: var(--slate-900);
}

.admin-brand i {
  color: var(--primary);
}

.admin-nav {
  display: flex;
  gap: 16px;
}

.admin-nav-item {
  color: var(--slate-600);
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-nav-item:hover,
.admin-nav-item.active {
  background: var(--slate-100);
  color: var(--slate-900);
}

.admin-content {
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* --- App Layout (Simulation/Learning) --- */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-body);
  background-image: radial-gradient(at 0% 0%, hsla(182, 100%, 96%, 1) 0, transparent 50%), radial-gradient(at 50% 0%, hsla(38, 100%, 96%, 1) 0, transparent 50%);
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--slate-100);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-xl);
}

.app-sidebar-header {
  padding: 32px 24px;
  border-bottom: 1px solid var(--slate-100);
  text-align: center;
  background: var(--bg-sidebar);
}

.app-sidebar-logo {
  font-size: 3rem;
  color: var(--arduino-teal);
}

.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-section {
  border-bottom: 1px solid var(--slate-50);
}

.sidebar-section-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--slate-700);
}

.sidebar-section-header:hover {
  background: var(--slate-50);
  color: var(--primary);
}

.sidebar-section.active .sidebar-section-header {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-section-content {
  display: none;
  border-top: 1px solid var(--slate-50);
}

.sidebar-section.active .sidebar-section-content {
  display: block;
}

.sidebar-section-header .chevron {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.8rem;
  opacity: 0.5;
}

.sidebar-section.active .sidebar-section-header .chevron {
  transform: rotate(180deg);
  opacity: 1;
}

.app-module-list {
  list-style: none;
  padding: 8px 12px;
}

.app-module-item {
  padding: 14px 16px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: 0.3s;
  margin-bottom: 6px;
}

.app-module-item:hover {
  background: var(--slate-100);
}

.app-module-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  border: 1px solid rgba(0, 151, 156, 0.1);
}

/* --- App Main --- */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  transition: margin-left 0.3s ease;
}

.app-header {
  height: 70px; /* Slightly smaller for better screen usage */
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 10px rgba(0,0,0,0.02);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-menu-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
  border: none;
  border-radius: 12px;
  color: var(--slate-600);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.app-menu-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-2px);
}

.app-header-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--slate-900);
}

/* --- User Profile & Dropdown --- */
.app-user-profile {
  position: relative;
}

.user-dropdown-btn {
  background: white;
  border: 1px solid var(--slate-100);
  padding: 8px 16px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: var(--shadow-sm);
}

.user-dropdown-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.app-user-name {
  font-weight: 700;
  color: var(--slate-700);
  font-size: 0.95rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
}

.dropdown-arrow {
  color: var(--slate-400);
  font-size: 0.8rem;
  transition: transform 0.3s;
}

.user-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: 120%;
  right: 0;
  width: 240px;
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--slate-100);
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
}

.user-dropdown.active .user-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

.dropdown-header strong {
  display: block;
  font-size: 1rem;
  color: var(--slate-900);
}

.dropdown-header span {
  font-size: 0.8rem;
  color: var(--slate-500);
}

.dropdown-divider {
  height: 1px;
  background: var(--slate-100);
  margin: 8px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  color: var(--slate-600);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--slate-50);
  color: var(--primary);
}

.dropdown-item.logout-item:hover {
  background: var(--error-light);
  color: var(--error);
}

/* --- Sidebar Overlays --- */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  scroll-behavior: smooth;
}

.app-content-inner {
  max-width: 850px;
  margin: 0 auto;
}

/* =========================================
   5. INTERACTIVE LEARNING COMPONENTS
   ========================================= */

/* --- Code Editor --- */
.code-editor {
  background: var(--slate-900);
  border-radius: var(--border-radius-md);
  overflow: visible; /* Allow content to manage its own scrolling */
  margin: 24px 0;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--slate-800);
}

.code-header {
  background: var(--slate-800);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--slate-400);
  font-family: var(--font-main);
  border-bottom: 1px solid var(--slate-700);
  flex-wrap: wrap;
  gap: 10px;
}

.editor-filename {
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  color: var(--slate-300);
  font-weight: 500;
}

.editor-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-controls .btn {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.run-btn {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
}

.run-btn:hover {
  background-color: #00767a !important;
  transform: translateY(-1px);
}

.reset-btn {
  background: transparent !important;
  border: 1px solid var(--slate-600) !important;
  color: var(--slate-400) !important;
}

.reset-btn:hover {
  background: rgba(255,255,255,0.05) !important;
  color: white !important;
}

.code-content {
  background: var(--slate-900);
  position: relative;
  min-height: 100px;
  overflow-y: visible !important;
  overflow-x: auto !important; /* Enable horizontal scroll */
  width: 100%;
}

.editor-main-area {
  display: grid;
  position: relative;
  overflow: visible !important;
  width: fit-content; /* Only as wide as needed */
  min-width: 100%;    /* But at least full width */
}

.editor-main-area textarea {
  grid-area: 1 / 1;
  padding: 24px;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: white;
  font-family: 'Fira Code', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  z-index: 2;
  outline: none;
  resize: none;
  overflow: hidden !important;
  white-space: pre;
  word-wrap: normal;
  letter-spacing: normal;
  text-transform: none;
  tab-size: 4;
  -moz-tab-size: 4;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0;
  text-rendering: optimizeSpeed; /* Consistency over beauty */
}

.editor-main-area pre {
  grid-area: 1 / 1;
  padding: 24px;
  pointer-events: none;
  color: var(--slate-50);
  font-family: 'Fira Code', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  overflow: visible !important;
  white-space: pre;
  word-wrap: normal;
  letter-spacing: normal;
  text-transform: none;
  tab-size: 4;
  -moz-tab-size: 4;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0;
  text-rendering: optimizeSpeed;
}

/* --- Premium Syntax Highlighting (Prism Overrides) --- */
.token.comment, .token.prolog, .token.doctype, .token.pi { color: #64748b; font-style: italic; }
.token.punctuation { color: #94a3b8; }
.token.namespace { opacity: .7; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #fbbf24; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #34d399; }
.token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: #fca5a5; }
.token.atrule, .token.attr-value, .token.keyword { color: #38bdf8; font-weight: 600; }
.token.function, .token.class-name { color: #818cf8; }
.token.regex, .token.important, .token.variable { color: #f472b6; }
.token.important, .token.bold { font-weight: bold; }
.token.italic { font-style: italic; }

/* --- Simulator Components --- */
.arduino-sim-area {
  position: relative;
  background: white;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--slate-100);
  overflow: hidden;
  margin-top: 32px;
  box-shadow: var(--shadow-inner);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sim-hardware {
  transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  transform-origin: center center;
}

/* --- Simulator D-Pad Hidden by default (Logic in app.js) --- */

/* --- Sensor Panel --- */
.sensor-control-panel {
  background: #f8fafc;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  border: 1px solid var(--slate-100);
}

.sensor-control-panel input[type=range] {
  appearance: none;
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  outline: none;
}

.sensor-control-panel input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary);
  border: 3px solid white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 151, 156, 0.3);
  transition: transform 0.1s;
}

.sensor-control-panel input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* --- Quizzes --- */
.multi-quiz-wrapper {
  margin-top: 60px;
  padding-top: 40px;
  border-top: 2px dashed var(--slate-200);
}

.quiz-header {
  margin-bottom: 32px;
  text-align: center;
}

.quiz-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--slate-900);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.quiz-title i {
  color: var(--primary);
}

.quiz-instructions {
  font-size: 1.1rem;
  color: var(--slate-500);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

.quiz-container {
  background: white;
  border: 1px solid var(--slate-100);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  margin: 40px 0;
  box-shadow: var(--shadow-md);
}

.quiz-question {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--slate-800);
  margin-bottom: 20px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-option {
  padding: 18px 24px;
  background: var(--slate-50);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: 0.3s;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--slate-100);
}

.quiz-option:hover {
  background: var(--slate-100);
  transform: translateY(-2px);
}

.quiz-option.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--arduino-teal);
}

.quiz-option.correct {
  background: var(--emerald-50);
  border-color: var(--success);
  color: var(--emerald-600);
}

.quiz-option.wrong {
  background: var(--rose-50);
  border-color: var(--error);
  color: var(--rose-600);
}

/* --- Bento Dashboard --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.bento-card {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-md);
  transition: 0.3s;
  border: 1px solid var(--slate-100);
}

.bento-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* =========================================
   6. ARDUINO SIMULATION ENGINE
   ========================================= */

.arduino-sim-area {
  background: var(--slate-50);
  padding: 40px;
  border-radius: var(--border-radius-lg);
  margin: 24px 0;
  border: 2px solid var(--arduino-teal);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-height: 400px;
}

.sim-hardware {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.1s;
  cursor: grab;
}

.sim-hardware:active {
  cursor: grabbing;
}

.arduino-console {
  background: #0f172a;
  color: #94a3b8;
  padding: 12px 20px;
  border-radius: 0 0 12px 12px;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  border: 1px solid var(--slate-800);
  border-top: none;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.arduino-console.running {
  color: var(--warning);
}

.arduino-console.success {
  color: var(--success);
}

.arduino-console.error {
  color: var(--error);
}

.zoom-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--slate-200);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.zoom-btn:hover {
  background: var(--slate-50);
  color: var(--primary);
  transform: translateY(-2px);
}

/* =========================================
   7. ANIMATIONS
   ========================================= */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

@keyframes floatUp {
  from {
    transform: translateY(110vh) rotate(0deg);
    opacity: 0;
  }

  to {
    transform: translateY(-100px) rotate(360deg);
    opacity: 0;
  }
}

/* =========================================
   8. RESPONSIVE DESIGN (Consolidated)
   ========================================= */

/* Desktop Specific Split View */
@media (min-width: 1025px) {
  .module-split-view {
    display: flex;
    height: calc(100vh - 85px);
  }

  .theory-pane {
    flex: 1;
    border-right: 1px solid var(--slate-100);
    padding: 32px;
    overflow-y: auto;
    background: white;
  }

  .simulator-pane {
    width: 50%;
    padding: 32px;
    background: var(--slate-50);
    border-left: 1px solid var(--slate-100);
    overflow-y: auto;
  }

  .simulator-hidden .simulator-pane {
    width: 0;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
  }
}

/* Tablet Adjustments */
@media (max-width: 1024px) {
  #toggle-simulator-btn {
    display: none !important;
  }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    transform: translateX(-100%);
    width: 300px;
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .app-header {
    height: 60px;
    padding: 0 15px;
  }

  .app-header-title {
    font-size: 1.1rem;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-content {
    padding: 20px 12px;
  }

  .mac-btns {
    display: none;
  }

  .code-header {
    padding: 10px 15px;
  }

  .editor-info {
    order: 2;
    width: 100%;
    font-size: 0.85rem;
    background: rgba(0, 151, 156, 0.05);
    padding: 4px 10px;
    border-radius: 4px;
    text-align: center;
  }

  .editor-filename {
    order: 1;
    font-size: 0.85rem;
  }

  .app-user-name,
  .dropdown-arrow {
    display: none;
  }
}

/* =========================================
   9. FOOTER
   ========================================= */
.app-footer {
  padding: 24px;
  text-align: center;
  color: var(--slate-500);
  font-size: 0.9rem;
  border-top: 1px solid var(--slate-50);
  margin-top: auto;
  background-color: var(--bg-surface);
}

/* =========================================
   10. MISC & ICONS
   ========================================= */
.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- FIX: Toggle Simulator Button State --- */
#toggle-simulator-btn.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}
/* =========================================
   11. LEARNING MATERIALS & SIMULATOR REFINEMENTS
   ========================================= */

.module-content h1 {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--slate-900);
  margin-bottom: 28px;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.module-content h2 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--slate-800);
  margin: 56px 0 24px;
  letter-spacing: -0.02em;
}

.module-content h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--slate-800);
  margin: 40px 0 20px;
}

.module-content p {
  color: var(--slate-600);
  line-height: 1.8;
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

/* --- Premium Syntax Highlighting --- */
.token.comment, .token.prolog, .token.doctype, .token.pi { color: #64748b !important; font-style: italic; }
.token.punctuation { color: #94a3b8 !important; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #fbbf24 !important; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #34d399 !important; }
.token.operator, .token.entity, .token.url { color: #fca5a5 !important; }
.token.atrule, .token.attr-value, .token.keyword { color: #38bdf8 !important; font-weight: 600; }
.token.function, .token.class-name { color: #818cf8 !important; }
.token.regex, .token.important, .token.variable { color: #f472b6 !important; }

/* --- Simulator D-Pad Premium --- */
.dpad-container {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: none; /* Only show when zoomed (JS-controlled) */
  grid-template-areas: 
    ". up ."
    "left reset right"
    ". down .";
  gap: 8px;
  z-index: 30;
  padding: 10px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: var(--shadow-lg);
}

.dpad-btn {
  width: 40px;
  height: 40px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-600);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: var(--shadow-sm);
}

.dpad-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 151, 156, 0.3);
}

.dpad-btn.reset { 
  background: var(--primary-light); 
  color: var(--primary); 
  border-color: var(--primary-border); 
  grid-area: reset;
}

.dpad-btn.up { grid-area: up; }
.dpad-btn.down { grid-area: down; }
.dpad-btn.left { grid-area: left; }
.dpad-btn.right { grid-area: right; }

/* --- Sensor Control Refinements --- */
.sensor-control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: white;
  padding: 28px;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--slate-100);
  box-shadow: var(--shadow-md);
}

.sensor-control-panel input[type=range] {
  appearance: none;
  width: 100%;
  height: 8px;
  background: #f1f5f9;
  border-radius: 10px;
  outline: none;
  border: 1px solid #e2e8f0;
}

.sensor-control-panel input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--primary);
  border: 4px solid white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 151, 156, 0.4);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sensor-control-panel input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 6px 15px rgba(0, 151, 156, 0.5);
}

.sensor-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.sensor-value-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.9rem;
}

/* Virtual Push Buttons Styling */
.virtual-buttons-container {
  border-top: 1px solid var(--slate-100);
  padding-top: 20px;
  margin-top: 5px;
}

.virtual-buttons-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate-500);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.virtual-buttons-label::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
}

.virtual-buttons-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.sim-digital-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.1s ease;
  box-shadow: 0 3px 0 #cbd5e1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sim-digital-btn i {
  font-size: 1.1rem;
  color: var(--primary);
}

.sim-digital-btn:hover {
  background: white;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #cbd5e1;
}

.sim-digital-btn:active,
.sim-digital-btn.active {
  background: #e0f2f1;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(3px);
  box-shadow: 0 0 0 #cbd5e1;
}

@media (max-width: 600px) {
  .sim-digital-btn {
    flex: 1;
    justify-content: center;
    min-width: 140px;
  }
}

/* --- SVG Button Interaction Overlays --- */
.sim-btn-overlay {
  fill: rgba(239, 68, 68, 0.2);
  stroke: #ef4444;
  stroke-width: 2px;
  stroke-dasharray: 4;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none; /* Only interactive during simulation */
}

/* Show overlays only when simulation is active */
.sim-active .sim-btn-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  animation: svgPulse 2s infinite ease-in-out;
}

.sim-btn-overlay.pressed {
  fill: rgba(239, 68, 68, 0.5);
  stroke-width: 4px;
  stroke-dasharray: none;
  animation: none !important;
}

@keyframes svgPulse {
  0% {
    stroke-opacity: 0.8;
    stroke-width: 2px;
    transform: scale(1);
    transform-origin: center;
  }
  50% {
    stroke-opacity: 0.4;
    stroke-width: 4px;
    transform: scale(1.1);
    transform-origin: center;
  }
  100% {
    stroke-opacity: 0.8;
    stroke-width: 2px;
    transform: scale(1);
    transform-origin: center;
  }
}

/* --- Serial Monitor (Console Output) --- */
.output-console {
  background: #020617; /* Deeper terminal background */
  color: #34d399; /* Terminal green */
  padding: 16px;
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  border-top: 1px solid var(--slate-800);
  max-height: 135px; /* Roughly 5 lines + padding */
  overflow-y: auto;
  display: none;
  position: relative;
  z-index: 10;
}

.output-console.show {
  display: block;
}

.output-console.error {
  border-top: 1px solid rgba(239, 68, 68, 0.3);
}

.console-line {
  margin-bottom: 4px;
  word-break: break-all;
  white-space: pre-wrap;
}

.console-line i {
  margin-right: 8px;
  font-size: 0.75rem;
}

/* Custom Scrollbar for Terminal */
.output-console::-webkit-scrollbar {
  width: 8px;
}

.output-console::-webkit-scrollbar-track {
  background: #0f172a;
}

.output-console::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}

.output-console::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* --- Exam Specific Refinements --- */
.exam-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.exam-icon-wrapper {
  width: 52px;
  height: 52px;
  background: var(--primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 4px 15px rgba(0, 151, 156, 0.25);
}

.exam-description {
  margin-bottom: 40px;
  border-left: 6px solid var(--primary);
  padding: 8px 0 8px 24px;
  background: rgba(0, 151, 156, 0.02);
  border-radius: 0 12px 12px 0;
}

.submission-status {
  margin-right: auto;
}

.submission-status span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.85rem;
}

.status-revision {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fef3c7;
}

.status-locked {
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #d1fae5;
}

.status-pending {
  color: var(--slate-500);
  background: var(--slate-50);
  border: 1px solid var(--slate-100);
}

.editor-actions {
  display: flex;
  gap: 12px;
}

.btn-disabled {
  background: #f8fafc;
  color: #94a3b8;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: not-allowed;
}
