/* Moxi Examples - Shared styles */

/* Pixel fonts for mini-gui and other components */
@font-face {
  font-family: 'PixelOperator8';
  src: url('./assets/custom-fonts/pixel_operator/PixelOperator8.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'PixelOperator8-Bold';
  src: url('./assets/custom-fonts/pixel_operator/PixelOperator8-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}

@font-face {
  font-family: 'PixelOperator';
  src: url('./assets/custom-fonts/pixel_operator/PixelOperator.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'PixelOperator-Bold';
  src: url('./assets/custom-fonts/pixel_operator/PixelOperator-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #1a1a1a;
  color: #ffffff;
  overflow: hidden;
}

.container {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 280px;
  min-width: 280px;
  flex-shrink: 0;
  background: #2a2a2a;
  border-right: 1px solid #3a3a3a;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
}

#sidebar::-webkit-scrollbar {
  width: 8px;
}

#sidebar::-webkit-scrollbar-track {
  background: #2a2a2a;
}

#sidebar::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
  background: #666;
}

@media (max-width: 768px) {
  #sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid #3a3a3a;
  }

  .container {
    flex-direction: column;
  }
}

.example-btn {
  width: 100%;
  background: #333;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.example-btn:hover {
  background: #3a3a3a;
  border-color: #555;
  transform: translateX(4px);
}

.example-btn.active {
  background: #004d66;
  border-color: #00d4ff;
}

.example-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #fff;
}

.example-desc {
  font-size: 13px;
  color: #999;
  line-height: 1.4;
}

.header {
  background: #252526;
  border-bottom: 1px solid #3a3a3a;
  margin: -20px -20px 20px -20px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 41px;
}

.header .npm-badge {
  display: inline-block;
  margin-bottom: 10px;
}

.header .npm-badge img {
  height: 20px;
}

.header h1 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: #00d4ff;
  letter-spacing: 1px;
}

.header p {
  font-size: 14px;
  color: #999;
}

/* Category Accordion */
.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  margin-top: 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s;
  user-select: none;
}

.category-header:first-of-type {
  margin-top: 0;
}

.category-header:hover {
  background: #383838;
}

.category-chevron {
  font-size: 10px;
  color: #888;
  width: 12px;
  text-align: center;
  transition: transform 0.2s;
}

.category-name {
  font-size: 12px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
}

.category-count {
  font-size: 11px;
  color: #666;
  background: #383838;
  padding: 2px 6px;
  border-radius: 10px;
}

.category-examples {
  overflow: hidden;
  max-height: 1000px;
  transition: max-height 0.3s ease-out, opacity 0.2s;
  opacity: 1;
  padding-left: 4px;
}

.category-examples.collapsed {
  max-height: 0;
  opacity: 0;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  position: relative;
  overflow: hidden;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: #252526;
  border-bottom: 1px solid #3a3a3a;
  padding: 0 12px;
  flex-shrink: 0;
}

.tabs-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tabs-github {
  display: flex;
  align-items: center;
  color: #969696;
  transition: color 0.2s;
}

.tabs-github:hover {
  color: #ffffff;
}

.tabs-npm-badge {
  display: flex;
  align-items: center;
}

.tabs-npm-badge img {
  height: 18px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #969696;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #cccccc;
}

.tab-btn.active {
  color: #ffffff;
  border-bottom-color: #007acc;
}

.error {
  background: #4a0000;
  color: #ff6b6b;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #660000;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.loading {
  color: #999;
  font-size: 14px;
}

/* Canvas Container */
#canvas-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  position: relative;
  overflow: hidden;
  flex: 1;
  min-width: 0;
  transition: flex 0.2s ease;
}

#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Code Container */
#code-container {
  background: #1e1e1e;
  overflow: hidden;
  position: relative;
  display: none;
  flex-direction: column;
  flex: 0 0 50%;
  min-height: 300px;
  border-top: 1px solid #3a3a3a;
}

/* Show code container when code tab is active */
#app.code-view #code-container {
  display: flex;
}

/* When code view is active, canvas takes remaining space */
#app.code-view #canvas-container {
  flex: 1;
  min-height: 0;
}

/* Show resize handle when code view is active */
#app.code-view .resize-handle {
  display: block;
}

/* Hide resize handle when code is hidden */
#app.code-hidden .resize-handle {
  display: none;
}

/* Code Header with Copy Button */
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #252526;
  border-bottom: 1px solid #3a3a3a;
  flex-shrink: 0;
}

.code-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.code-header-title {
  font-size: 13px;
  font-weight: 600;
  color: #cccccc;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.toggle-code-btn {
  background: transparent;
  border: 1px solid #3a3a3a;
  color: #cccccc;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.toggle-code-btn:hover {
  background: #3a3a3a;
  border-color: #555;
  color: #ffffff;
}

.toggle-code-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.copy-btn {
  background: #0e639c;
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-btn:hover {
  background: #1177bb;
}

.copy-btn:active {
  background: #0a4d73;
}

.copy-btn.copied {
  background: #0e7a0e;
}

.copy-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Code Editor Container */
.code-editor-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* CodeMirror styles */
#code-container .cm-editor {
  height: 100%;
  font-size: 14px;
}

/* Resize handle between canvas and code */
.resize-handle {
  height: 4px;
  background: #3a3a3a;
  cursor: row-resize;
  flex-shrink: 0;
  transition: background 0.2s;
  position: relative;
}

.resize-handle:hover {
  background: #007acc;
}

.resize-handle::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  bottom: -2px;
}

/* CodeMirror scrollbar (VS Code style) */
#code-container .cm-scroller::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

#code-container .cm-scroller::-webkit-scrollbar-track {
  background: #1e1e1e;
}

#code-container .cm-scroller::-webkit-scrollbar-thumb {
  background: #424242;
  border: 3px solid #1e1e1e;
  border-radius: 7px;
}

#code-container .cm-scroller::-webkit-scrollbar-thumb:hover {
  background: #4e4e4e;
}
