/* 
  Minimalist Light-Theme Design System for Full-Screen 3D Stack Simulator
  Sidebars Layout: Left Sidebar (Operations & Info), Right Sidebar (1D Array & Trace), Center (Clean 3D World)
*/

:root {
  --bg-canvas: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --border-subtle: rgba(226, 232, 240, 0.9);
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-violet: #8b5cf6;
  --accent-amber: #f59e0b;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.11);
}

* {
  box-sizing: border-box;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-family: 'DM Sans', 'Lexend', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Fullscreen 3D Viewport */
#viewport-container {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #f1f5f9 100%);
}

#three-canvas {
  width: 100vw;
  height: 100vh;
  display: block;
  outline: none;
  cursor: grab;
}

#three-canvas:active {
  cursor: grabbing;
}

/* Glassmorphism Panels */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  border-radius: 18px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-lg);
}

/* In-Canvas Floating Sidebars Layout */
.hud-sidebar-left {
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 16px;
  width: 310px;
  max-width: calc(50vw - 24px);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 25;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.hud-sidebar-right {
  position: absolute;
  top: 16px;
  bottom: 16px;
  right: 16px;
  width: 320px;
  max-width: calc(50vw - 24px);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 25;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

/* Top Center Floating Strip */
.hud-center-top {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 30;
  width: max-content;
  max-width: calc(100vw - 680px);
}

/* Allow interactive HUD components to receive clicks and prevent dragging canvas */
.hud-interactive {
  pointer-events: auto !important;
  user-select: none;
}

/* Bottom Center Floating Hint */
.hud-center-bottom {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  white-space: nowrap;
}

/* 3D Character Speech / Status Bubble */
.character-speech-bubble {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  padding: 8px 20px;
  border-radius: 9999px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.character-speech-bubble.active {
  opacity: 1;
  transform: translateY(0);
}

.character-speech-bubble .bot-icon-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

/* Camera Bar Buttons */
.cam-btn {
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 9999px;
  color: var(--text-muted);
  cursor: pointer !important;
  pointer-events: auto !important;
  transition: all 0.2s ease;
  user-select: none;
}

.cam-btn:hover {
  color: var(--text-main);
  background: rgba(241, 245, 249, 0.9);
}

.cam-btn.active {
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

#toggle-fullscreen {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* Minimalist Button System */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8.5px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.btn-action:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.btn-push {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
}
.btn-push:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 5px 14px rgba(16, 185, 129, 0.35);
}

.btn-pop {
  background: #f43f5e;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(244, 63, 94, 0.25);
}
.btn-pop:hover:not(:disabled) {
  background: #e11d48;
  box-shadow: 0 5px 14px rgba(244, 63, 94, 0.35);
}

.btn-peek {
  background: #8b5cf6;
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(139, 92, 246, 0.25);
}
.btn-peek:hover:not(:disabled) {
  background: #7c3aed;
  box-shadow: 0 5px 14px rgba(139, 92, 246, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}
.btn-secondary:hover:not(:disabled) {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

/* Vertical 1D Memory Array Visualization (Right Sidebar) */
.memory-array-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.memory-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.memory-index {
  width: 32px;
  text-align: right;
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

.memory-box {
  flex: 1;
  height: 38px;
  border-radius: 9px;
  border: 1.5px dashed #cbd5e1;
  background: rgba(248, 250, 252, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fira Code', monospace;
  font-weight: 700;
  font-size: 14px;
  color: #64748b;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.memory-box.filled {
  border-style: solid;
  border-color: #3b82f6;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.12);
  transform: translateX(2px);
}

.memory-box.tos {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
  box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.22);
}

.memory-box.peeked {
  border-color: #8b5cf6 !important;
  background: #f5f3ff !important;
  color: #5b21b6 !important;
  animation: pulse-peek 1.2s infinite alternate;
}

@keyframes pulse-peek {
  0% { transform: scale(1); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2); }
  100% { transform: scale(1.04); box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.35); }
}

.memory-pointer-tag {
  width: 58px;
  font-size: 9.5px;
  font-weight: 700;
  font-family: 'Fira Code', monospace;
}

/* Pseudocode block & live line highlighting */
.code-container {
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.5;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  overflow-x: auto;
}

.code-line {
  display: block;
  padding: 1px 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.code-line.active-line {
  background: rgba(59, 130, 246, 0.35);
  color: #ffffff;
  border-left: 3px solid #60a5fa;
  font-weight: 600;
}

/* Operation Log */
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #f1f5f9;
  font-size: 11px;
  transition: background 0.15s ease;
}

.log-item:hover {
  background: #f8fafc;
}

.tag-push {
  background: #ecfdf5;
  color: #065f46;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
}

.tag-pop {
  background: #fff1f2;
  color: #9f1239;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
}

.tag-peek {
  background: #f5f3ff;
  color: #5b21b6;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
