/**
 * Workspace, Toolbox, & Integrated Hardware Dashboard Styles
 * Tailored for school Chromebooks and STEM classrooms.
 */

/* ==========================================================================
   1. Toolbox & Palette
   ========================================================================== */

.wedo-toolbox {
  width: var(--toolbox-width, 360px);
  min-width: 280px;
  max-width: 650px;
  height: 100%;
  display: flex;
  background: #f9fafb;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 20;
  box-shadow: 2px 0 6px rgba(0,0,0,0.03);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.wedo-toolbox.trash-active {
  background: #fef2f2 !important;
  border-right: 2px dashed #ef4444 !important;
  box-shadow: inset 0 0 15px rgba(239, 68, 68, 0.25) !important;
}

.wedo-toolbox.trash-active::after {
  content: '🗑️ Drop to Delete';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ef4444;
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.block-dragging-trash {
  opacity: 0.55 !important;
  filter: grayscale(0.5) drop-shadow(0 0 8px #ef4444) !important;
  transform: scale(0.92) !important;
}

.toolbox-category-nav {
  width: 72px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  overflow-y: auto;
  flex-shrink: 0;
}

.toolbox-cat-btn {
  width: 60px;
  min-height: 52px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 2px;
  transition: all 0.15s ease;
}

.toolbox-cat-btn:hover {
  background: #f1f5f9;
}

.toolbox-cat-btn.active {
  background: #e2e8f0;
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}

.cat-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.cat-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: #475569;
  text-align: center;
  line-height: 1.1;
}

.toolbox-flyout {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  overflow-y: auto;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  scrollbar-width: thin;
}

.toolbox-flyout::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.toolbox-flyout::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.toolbox-flyout::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.toolbox-flyout-header {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 6px;
  border-bottom: 2px solid currentColor;
  margin-bottom: 6px;
}

.toolbox-make-var-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #d97706;
  cursor: pointer;
  align-self: flex-start;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.15s ease;
}

.toolbox-make-var-btn:hover {
  background: #fffbeb;
  border-color: #f59e0b;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(245, 158, 11, 0.2);
}

.toolbox-block-item {
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: block;
  width: max-content;
  max-width: none;
  margin-bottom: 8px;
  transition: transform 0.1s;
}

.toolbox-block-item:hover {
  transform: translateY(-1px);
}

.toolbox-block-item:active {
  cursor: grabbing;
}

/* Toolbox Resize Handle */
.toolbox-resizer {
  position: absolute;
  top: 0;
  right: -5px;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 50;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.toolbox-resizer::after {
  content: '';
  width: 2px;
  height: 24px;
  border-radius: 2px;
  background: #cbd5e1;
  transition: background 0.15s, height 0.15s;
}

.toolbox-resizer:hover::after,
.toolbox-resizer.is-resizing::after {
  background: #0284c7;
  height: 48px;
  width: 3px;
}

.toolbox-resizer:hover,
.toolbox-resizer.is-resizing {
  background: rgba(2, 132, 199, 0.1);
}

/* ==========================================================================
   2. Workspace Canvas
   ========================================================================== */

.wedo-workspace {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  overflow: auto;
  background-color: #ffffff;
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 24px 24px;
}

.workspace-canvas {
  width: 3200px;
  height: 2400px;
  position: relative;
  touch-action: none;
}

/* Magnetic Snap Highlight */
.workspace-snap-indicator {
  position: absolute;
  height: 6px;
  background: #f59e0b;
  border-radius: 3px;
  box-shadow: 0 0 10px #fbbf24, 0 0 4px #d97706;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.15s ease;
}

/* ==========================================================================
   3. Hardware Dashboard & Live Telemetry Sidebar (Integrated Right Column)
   ========================================================================== */

.wedo-dashboard-sidebar {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f1f5f9;
}

.dash-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Base Card Styling */
.dash-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.dash-card:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,0.07);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 6px;
}

.card-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-hint {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
}

/* Pulse animation when user clicks Hub button in top toolbar */
.highlight-pulse {
  animation: pulseHighlight 1.2s ease-in-out;
}

@keyframes pulseHighlight {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37,99,235,0.7); border-color: #2563eb; }
  50% { transform: scale(1.02); box-shadow: 0 0 0 8px rgba(37,99,235,0); border-color: #2563eb; }
  100% { transform: scale(1); border-color: #e2e8f0; }
}

/* --- Section 1: Connection Card --- */
.hub-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hub-avatar {
  width: 44px;
  height: 44px;
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hub-studs {
  position: absolute;
  top: -5px;
  display: flex;
  gap: 6px;
}

.hub-studs span {
  width: 10px;
  height: 5px;
  background: #cbd5e1;
  border-radius: 2px 2px 0 0;
}

.hub-led-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #ffffff;
  box-shadow: 0 0 4px rgba(0,0,0,0.15);
  transition: all 0.3s;
}

.hub-meta {
  flex: 1;
  overflow: hidden;
}

.hub-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hub-title-row h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-xs {
  padding: 1px 5px;
  font-size: 0.68rem;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
}

.btn-xs:hover {
  background: #e2e8f0;
}

.hub-subtext {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 1px;
  line-height: 1.25;
}

.battery-readout {
  display: flex;
  align-items: center;
  gap: 6px;
}

#dashBatteryText {
  font-size: 0.78rem;
  font-weight: 800;
  color: #334155;
}

.battery-bar {
  width: 36px;
  height: 9px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.battery-fill {
  width: 0%;
  height: 100%;
  background: #22c55e;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.connection-actions-row {
  display: flex;
  gap: 8px;
}

.scan-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  padding-top: 2px;
}

.dash-select {
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  font-size: 0.72rem;
  background: #ffffff;
  color: #334155;
  outline: none;
  max-width: 220px;
}

/* Button styles */
.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}

.btn-primary {
  background: #2563eb;
  color: white;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}
.btn-secondary:hover { background: #cbd5e1; }

.btn-danger {
  background: #ef4444;
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: #f59e0b !important;
  color: white !important;
}

/* --- Section 2: Motor Actions & Turning Gears (Individual Cards) --- */
.dash-motor-card {
  gap: 8px;
  animation: fadeInCard 0.25s ease-out;
}

@keyframes fadeInCard {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.motor-unit-card-body {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 14px;
}

.motors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.motor-unit {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.motor-unit-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #475569;
}

.port-type-badge {
  background: #e2e8f0;
  color: #64748b;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

.port-type-badge.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.gear-stage {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gear-svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.gear-rotator {
  transform-origin: 50px 50px;
}

@keyframes spinGearCw {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spinGearCcw {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

.motor-speed-box {
  width: 100%;
  text-align: center;
}

.speed-indicator {
  font-size: 0.72rem;
  font-weight: 800;
  color: #64748b;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  transition: all 0.2s;
}

.speed-indicator.running {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  box-shadow: 0 0 6px rgba(59,130,246,0.25);
}

/* --- Section 3: Live Sensor Telemetry --- */
.sensors-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sensor-unit {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sensor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sensor-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
}

.sensor-reading {
  font-size: 0.8rem;
  font-weight: 800;
  color: #0369a1;
  background: #e0f2fe;
  padding: 2px 8px;
  border-radius: 6px;
}

.dist-meter-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.dist-meter-fill {
  width: 0%;
  height: 100%;
  background: #22c55e;
  border-radius: 4px;
  transition: width 0.2s ease, background-color 0.2s ease;
}

.dist-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: #94a3b8;
  font-weight: 600;
}

/* 2D Compass for Tilt Sensor */
.tilt-compass-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}

.tilt-compass {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tilt-mid-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tilt-node {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #64748b;
  transition: all 0.2s;
}

.tilt-node.tilt-center {
  border-radius: 50%;
  font-weight: bold;
}

.tilt-node.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
  box-shadow: 0 0 10px rgba(2,132,199,0.5);
  transform: scale(1.15);
}

/* --- Section 2: Hub RGB LED Card (Below Connection) --- */
.dash-led-card {
  gap: 8px;
}

.led-preview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}

.dash-led-orb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 2px solid #ffffff;
  box-shadow: 0 0 4px rgba(0,0,0,0.15);
  transition: all 0.25s;
  flex-shrink: 0;
}

.led-preview-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.led-caption {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.led-hex-badge {
  font-family: monospace;
  font-size: 0.72rem;
  color: #3b82f6;
  font-weight: 700;
}

.led-swatches-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  padding-top: 2px;
}

.color-swatch-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.12s, box-shadow 0.12s;
  padding: 0;
  line-height: 1;
}

.color-swatch-btn:hover {
  transform: scale(1.18);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 2;
}

.color-swatch-btn:active {
  transform: scale(0.95);
}

/* --- Section 4: Live Sensor Telemetry (Connected vs Unconnected) --- */
.sensors-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sensor-unit {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.3s ease;
}

.sensor-unit.sensor-connected {
  background: #ffffff;
  border-color: #93c5fd;
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.08);
  opacity: 1;
  filter: none;
}

.sensor-unit.sensor-unconnected {
  opacity: 0.42;
  filter: grayscale(0.85);
  background: #f1f5f9;
  border: 1.5px dashed #cbd5e1;
}

.sensor-unit.sensor-unconnected:hover {
  opacity: 0.65;
}

.sensor-title-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sensor-port-tag {
  font-size: 0.62rem;
  font-weight: 700;
  color: #94a3b8;
}

.sensor-port-tag.active {
  color: #16a34a;
}

.sensor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sensor-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
}

.sensor-reading {
  font-size: 0.8rem;
  font-weight: 800;
  color: #0369a1;
  background: #e0f2fe;
  padding: 2px 8px;
  border-radius: 6px;
}

.dist-meter-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.dist-meter-fill {
  width: 0%;
  height: 100%;
  background: #22c55e;
  border-radius: 4px;
  transition: width 0.2s ease, background-color 0.2s ease;
}

.dist-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: #94a3b8;
  font-weight: 600;
}

/* 2D Compass for Tilt Sensor */
.tilt-compass-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
}

.tilt-compass {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tilt-mid-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tilt-node {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #64748b;
  transition: all 0.2s;
}

.tilt-node.tilt-center {
  border-radius: 50%;
  font-weight: bold;
}

.tilt-node.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
  box-shadow: 0 0 10px rgba(2,132,199,0.5);
  transform: scale(1.15);
}

/* --- Section 5: Code Output Display Screen --- */
.dash-output-card {
  gap: 8px;
}

.screen-body {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  text-align: center;
  background: #1e293b;
  color: #38bdf8;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
}

.screen-text {
  font-family: monospace, system-ui;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  word-break: break-word;
  transition: transform 0.2s;
}

.screen-text-flash {
  animation: textFlash 0.3s ease-out;
}

@keyframes textFlash {
  0% { transform: scale(1.1); color: #ffffff; }
  100% { transform: scale(1); color: #38bdf8; }
}

/* Variable Monitor Badge (Scratch Style) */
.variable-monitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ff8c1a;
  color: white;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  align-self: flex-start;
}

.variable-monitor-badge .var-val {
  background: #db6e00;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.78rem;
}
