/* Top bar – Phase 2 */
#topBar {
  flex-shrink: 0;
}
#roomLink {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

/* ----- Whiteboard General Styles ----- */
* { user-select: none; box-sizing: border-box; }
body { overflow: hidden; font-family: 'Inter', system-ui, sans-serif; margin: 0; }
#canvasWrapper { transform-origin: 0 0; transition: transform 0.05s linear; width: fit-content; }
.tool-btn {
  transition: all 0.15s;
  border-radius: 12px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  cursor: pointer;
}
.tool-btn.active { background: #e0e7ff; border-color: #6366f1; color: #4f46e5; }
.tool-btn:hover { background: #f1f5f9; }
.color-circle {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border 0.1s;
}
.color-circle.selected { border-color: #1e293b; }
.slider-thumb::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; background: #4f46e5; border-radius: 50%; cursor: pointer; }

/* Widget common */
.html-widget, .coord-plane-widget, .calc-widget {
  position: absolute;
  background: transparent;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  overflow: hidden;
  z-index: 1000;
  min-width: 250px;
  min-height: 150px;
  resize: both;
}
.widget-header {
  background: #f39c12;
  padding: 6px 10px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  color: white;
  font-weight: bold;
  font-size: 12px;
}
.widget-close {
  background: none; border: none; color: white; font-size: 16px; cursor: pointer;
}
.widget-content { width: 100%; height: calc(100% - 32px); background: white; }
iframe { width: 100%; height: 100%; border: none; background: white; }
.resize-handle {
  position: absolute; bottom: 5px; right: 5px; width: 15px; height: 15px;
  background: #f39c12; border-radius: 0 0 10px 0; cursor: nw-resize;
}

/* Coordinate plane */
.coord-plane-widget .widget-header { background: #3498db; }
.coord-plane-widget .resize-handle { background: #3498db; }
.coord-canvas { width: 100%; height: 100%; display: block; }

/* Minimap */
/* Minimap – live preview with viewfinder and cursors */
#minimapContainer {
  position: fixed;
  bottom: 80px;
  /* right is set dynamically by JS (sidebar‑aware) */
  background: #f8fafc;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  padding: 4px;
  display: none;
  z-index: 100;
  width: 180px;
  height: 120px;
  border: 1px solid #cbd5e1;
}

#minimapViewfinder {
  position: absolute;
  border: 2px solid #ef4444;
  background: rgba(239, 68, 68, 0.2);
  pointer-events: none;
  border-radius: 3px;
  display: none;
  z-index: 10;
}

/* Individual cursor dots on the minimap */
.minimap-cursor-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #3b82f6;   /* default student color */
  border: 1px solid white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
}

.minimap-cursor-dot.teacher {
  background: #ef4444;
}

/* Color popover */
.color-popover {
  position: absolute;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  padding: 8px;
  z-index: 2000;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 180px;
}
.color-shade {
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  border: 1px solid #e2e8f0;
}
.color-shade:hover { transform: scale(1.1); }

/* ----- TI‑84 Plus Calculator Widget Styles ----- */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Share+Tech+Mono&family=Rajdhani:wght@300;500;700&display=swap');

.calc-widget .widget-header {
  background: linear-gradient(90deg, #1a3a5c, #1f4570, #1a3a5c) !important;
  border-bottom: 2px solid #0a1825;
}
.calc-widget .widget-content {
  background: linear-gradient(160deg, #1e2d3d 0%, #162433 40%, #0f1c2a 100%) !important;
  padding: 0 !important;
}
.calculator-body {
  width: 100%; height: 100%; padding: 12px 14px 16px; position: relative;
  user-select: none; display: flex; flex-direction: column;
}
.calculator-body::before, .calculator-body::after {
  content: '';
  position: absolute;
  width: 5px;
  top: 60px; bottom: 40px;
  background: linear-gradient(to bottom, #0d1b28, #1a2d40, #0d1b28);
  border-radius: 3px;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.8);
}
.calculator-body::before { left: 6px; }
.calculator-body::after { right: 6px; }

.header-strip {
  background: linear-gradient(90deg, #1a3a5c, #1f4570, #1a3a5c);
  border-radius: 8px 8px 0 0;
  padding: 4px 10px 3px;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0a1825;
}
.ti-logo {
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.model-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  font-weight: 300;
  color: #a0c8e8;
  letter-spacing: 2px;
}
.plus-badge {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  background: #d44000;
  border-radius: 3px;
  padding: 1px 5px;
}

.screen-bezel {
  background: linear-gradient(135deg, #2a3f52 0%, #1d3048 50%, #243a4d 100%);
  border-radius: 6px;
  padding: 8px 8px 6px;
  margin: 4px 0 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
  border: 1.5px solid #0e1e2d;
}
.screen-label-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.screen-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 8px;
  color: #4a7fa5;
  letter-spacing: 2px;
}
.screen {
  background: #8fa882;
  width: 100%;
  height: 100px;
  border-radius: 3px;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6), inset 2px 2px 8px rgba(0,0,0,0.3);
  overflow: hidden;
}
.screen::before {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 5px),
                  repeating-linear-gradient(90deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 5px);
  pointer-events: none;
}
.ti-graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #bdd4e6;
}
.ti-entry-line {
  background: #bdd4e6;
  border: 2px inset #2c4c6e;
  margin-top: 4px;
  padding: 2px 4px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  min-height: 22px;
  color: #000;
}

.fn-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.fn-key {
  background: linear-gradient(180deg, #2e4d68 0%, #1e3a52 100%);
  border-radius: 4px;
  padding: 4px 2px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 0 #0a1a28, 0 3px 5px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  border: 1px solid #0d2035;
  transition: 0.08s;
}
.fn-key:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a1a28, 0 2px 3px rgba(0,0,0,0.4); }
.fn-key .k-label {
  font-family: 'Rajdhani', sans-serif;
  font-size: 8px;
  font-weight: 700;
  color: #cee4f4;
}

.nav-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 70px;
  gap: 4px;
  margin-bottom: 6px;
}
.dpad-cell {
  grid-column: 5;
  grid-row: 1 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dpad {
  width: 64px; height: 64px;
  position: relative;
}
.dpad-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #2a3a4a 0%, #1a2a38 60%, #0f1e2c 100%);
  box-shadow: 0 3px 0 #071020, 0 4px 8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
  border: 2px solid #0a1828;
}
.dpad-h, .dpad-v {
  position: absolute;
  background: linear-gradient(180deg, #253545 0%, #1a2838 50%, #253545 100%);
  border: 1px solid #0a1828;
}
.dpad-h { width: 100%; height: 33%; top: 33%; left: 0; }
.dpad-v { height: 100%; width: 33%; left: 33%; top: 0; }
.dpad-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 18px; height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #1a2a3a 0%, #0f1e2c 100%);
  border: 2px solid #0a1828;
  z-index: 2;
}
.dpad-arrow {
  position: absolute;
  color: #7ab0d0;
  font-size: 10px;
  font-weight: bold;
  z-index: 3;
  cursor: pointer;
}
.dpad-up { top: 2px; left: 50%; transform: translateX(-50%); }
.dpad-down { bottom: 2px; left: 50%; transform: translateX(-50%); }
.dpad-left { left: 2px; top: 50%; transform: translateY(-50%); }
.dpad-right { right: 2px; top: 50%; transform: translateY(-50%); }

.main-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.btn {
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  transition: 0.08s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 30px;
}
.btn:active { transform: translateY(2px); }
.btn-inner {
  width: 100%; height: 100%;
  border-radius: 4px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2px;
}
.btn-top {
  font-family: 'Rajdhani', sans-serif;
  font-size: 6px;
  font-weight: 700;
  position: absolute;
  top: -9px; left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  color: #f0c040;
}
.btn-top.alpha { color: #70d870; }
.btn-main {
  font-family: 'Rajdhani', sans-serif;
  font-size: 9px;
  font-weight: 700;
  color: #e8eef4;
  text-transform: uppercase;
}
.btn-sub {
  font-family: 'Share Tech Mono', monospace;
  font-size: 6px;
  color: #7aa0c0;
}
.btn-dark {
  background: linear-gradient(180deg, #3a3a42 0%, #252530 100%);
  box-shadow: 0 2px 0 #111118, 0 3px 6px rgba(0,0,0,0.5);
  border: 1px solid #1a1a22;
}
.btn-2nd {
  background: linear-gradient(180deg, #d0a000 0%, #a07800 100%);
  box-shadow: 0 2px 0 #604800;
  border: 1px solid #805a00;
}
.btn-2nd .btn-main { color: #fff8e0; }
.btn-alpha {
  background: linear-gradient(180deg, #2a8030 0%, #1a5a20 100%);
  box-shadow: 0 2px 0 #0a2a0e;
  border: 1px solid #0d3a14;
}
.btn-alpha .btn-main { color: #d0f0d0; }
.btn-enter {
  background: linear-gradient(180deg, #c03a00 0%, #8a2800 100%);
  box-shadow: 0 3px 0 #3a1000;
  border: 1px solid #5a1800;
}
.btn-enter .btn-main { color: #ffd0b0; }
.btn-on {
  background: linear-gradient(180deg, #2a2a32 0%, #1a1a22 100%);
  box-shadow: 0 2px 0 #080810;
}
.btn-clear {
  background: linear-gradient(180deg, #3a2a1a 0%, #2a1c10 100%);
  box-shadow: 0 2px 0 #0e0a06;
  border: 1px solid #1a1008;
}
.btn-clear .btn-main { color: #e8c090; }
.btn-num {
  background: linear-gradient(180deg, #383840 0%, #28282e 100%);
  box-shadow: 0 2px 0 #101014;
}
.btn-num .btn-main { color: #e0e8f0; font-size: 13px; }
.btn-op {
  background: linear-gradient(180deg, #1e3a58 0%, #142a42 100%);
  box-shadow: 0 2px 0 #071020;
}
.btn-op .btn-main { color: #a8d0f0; font-size: 13px; }

.port-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.port {
  height: 5px;
  background: linear-gradient(90deg, #0a1828, #1a2d3d, #0a1828);
  border-radius: 3px;
  border: 1px solid #071020;
  flex: 1;
  max-width: 30px;
}
/* Enable scrollbars for panning */
#canvasContainer {
  overflow: hidden;
}

#rightSidebar {
  padding-top: 48px;   /* push content below fixed header */
}

/* Loading spinner for HTML widget */
.widget-spinner .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  #bottomToolbar { gap: 2px; padding: 4px 8px; }
  .tool-btn.w-10.h-10 { width: 32px; height: 32px; }
}