/* ==========================================================================
   Terminal Design System & Dynamic Themes
   ========================================================================== */

:root {
  /* Matrix Theme (Default) */
  --bg-color: #0d1117;
  --terminal-bg: rgba(13, 17, 23, 0.92);
  --header-bg: #161b22;
  --text-main: #00ff66;
  --text-dim: #00b347;
  --prompt-user: #00ffcc;
  --prompt-path: #38bdf8;
  --dir-color: #38bdf8;
  --file-color: #e2e8f0;
  --exe-color: #f43f5e;
  --accent-color: #00ff66;
  --glow-color: rgba(0, 255, 102, 0.25);
  --font-family: 'Fira Code', 'JetBrains Mono', monospace;
  --border-color: rgba(0, 255, 102, 0.2);
}

/* Dracula Theme */
body.theme-dracula {
  --bg-color: #1e1e2e;
  --terminal-bg: rgba(30, 30, 46, 0.94);
  --header-bg: #181825;
  --text-main: #f8f8f2;
  --text-dim: #a6adc8;
  --prompt-user: #ff79c6;
  --prompt-path: #8be9fd;
  --dir-color: #8be9fd;
  --file-color: #f8f8f2;
  --exe-color: #ff5555;
  --accent-color: #bd93f9;
  --glow-color: rgba(189, 147, 249, 0.25);
  --border-color: rgba(189, 147, 249, 0.3);
}

/* Cyberpunk Theme */
body.theme-cyberpunk {
  --bg-color: #050510;
  --terminal-bg: rgba(10, 10, 26, 0.94);
  --header-bg: #12122b;
  --text-main: #00f0ff;
  --text-dim: #8096b8;
  --prompt-user: #ff007f;
  --prompt-path: #ffe600;
  --dir-color: #ffe600;
  --file-color: #00f0ff;
  --exe-color: #ff007f;
  --accent-color: #ff007f;
  --glow-color: rgba(255, 0, 127, 0.3);
  --border-color: rgba(0, 240, 255, 0.3);
}

/* Retro Amber Theme */
body.theme-amber {
  --bg-color: #120c02;
  --terminal-bg: rgba(20, 14, 4, 0.95);
  --header-bg: #211606;
  --text-main: #ffb000;
  --text-dim: #cc8800;
  --prompt-user: #ffd000;
  --prompt-path: #ff9900;
  --dir-color: #ff9900;
  --file-color: #ffca43;
  --exe-color: #ff5500;
  --accent-color: #ffb000;
  --glow-color: rgba(255, 176, 0, 0.3);
  --border-color: rgba(255, 176, 0, 0.3);
}

/* Monokai Theme */
body.theme-monokai {
  --bg-color: #272822;
  --terminal-bg: rgba(39, 40, 34, 0.94);
  --header-bg: #1e1f1c;
  --text-main: #a6e22e;
  --text-dim: #75715e;
  --prompt-user: #f92672;
  --prompt-path: #66d9ef;
  --dir-color: #66d9ef;
  --file-color: #f8f8f2;
  --exe-color: #fd971f;
  --accent-color: #a6e22e;
  --glow-color: rgba(166, 226, 46, 0.25);
  --border-color: rgba(166, 226, 46, 0.3);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
}

/* Scanline Overlay */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  opacity: 0.6;
}

/* Matrix Background Canvas */
#matrix-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  opacity: 0.15;
  pointer-events: none;
}

/* Right Side Snakes & Ladders Grid Container */
.snakes-ladders-container {
  position: fixed;
  right: 20px;
  top: 60px;
  width: 220px;
  height: 340px;
  z-index: 85;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.mini-board-grid {
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(to right, var(--border-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border-color) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.25;
}

.game-node {
  position: absolute;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.github-cat-node {
  cursor: pointer;
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.8));
}

.github-cat-node:hover {
  transform: scale(1.2) rotate(-10deg);
}

.grid-obstacle-node {
  cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4));
  transition: transform 0.2s ease;
}

.grid-obstacle-node:hover {
  transform: scale(1.3);
}

.obstacle-icon {
  font-size: 18px;
  color: var(--prompt-user);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 6px;
}

.cat-icon {
  font-size: 28px;
  color: var(--file-color);
  background: var(--bg-color);
  border-radius: 50%;
  padding: 4px;
  border: 2px solid var(--prompt-path);
  box-shadow: 0 0 10px var(--glow-color);
}

.hf-node {
  top: 10px;
  right: 10px;
  cursor: pointer;
  filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.8));
  animation: pulse-hf 2s infinite ease-in-out;
}

@keyframes pulse-hf {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.node-emoji {
  font-size: 34px;
}

/* Terminal Header */
.terminal-header {
  position: relative;
  z-index: 10;
  height: 42px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  user-select: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.window-controls {
  display: flex;
  gap: 8px;
}

.window-controls .btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
}

.window-controls .btn.close { background-color: #ff5f56; }
.window-controls .btn.minimize { background-color: #ffbd2e; }
.window-controls .btn.maximize { background-color: #27c93f; }

.terminal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.header-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--font-family);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-btn:hover {
  background: var(--accent-color);
  color: #000;
  box-shadow: 0 0 10px var(--glow-color);
}

/* Main Terminal Layout */
.terminal-wrapper {
  position: relative;
  z-index: 10;
  height: calc(100vh - 42px - 45px);
  background-color: var(--terminal-bg);
  padding: 20px 260px 20px 20px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) transparent;
}

.terminal-wrapper::-webkit-scrollbar {
  width: 8px;
}

.terminal-wrapper::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 4px;
}

/* Persistent Header Banner (Never Cleared) */
.persistent-banner {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border-color);
}

.banner-title-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-color);
  letter-spacing: 0.5px;
}

.banner-info-subtitle {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
  margin-top: 6px;
}

/* Ascii Art / Banner */
.ascii-art {
  font-size: 14px;
  line-height: 1.15;
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--glow-color);
  font-weight: bold;
  overflow-x: auto;
}

/* Output Formatting */
.terminal-output {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 100%;
}

.history-item {
  margin-bottom: 8px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.cmd-executed {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  font-weight: 600;
}

.cmd-output {
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  color: var(--text-main);
}

/* Ascii Art / Banner */
.ascii-art {
  font-size: 11px;
  line-height: 1.15;
  color: var(--accent-color);
  text-shadow: 0 0 8px var(--glow-color);
  font-weight: bold;
}

/* Input Line */
.input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.prompt-user {
  color: var(--prompt-user);
  font-weight: bold;
}

.prompt-path {
  color: var(--prompt-path);
  font-weight: bold;
}

.prompt-symbol {
  color: var(--text-main);
  font-weight: bold;
}

.input-wrapper {
  position: relative;
  flex-grow: 1;
  display: flex;
  align-items: center;
}

#cli-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  caret-color: var(--accent-color);
}

/* Quick Toolbar */
.quick-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 45px;
  background-color: var(--header-bg);
  border-top: 1px solid var(--border-color);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-toolbar::-webkit-scrollbar {
  display: none;
}

.toolbar-label {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  font-weight: bold;
}

.quick-cmd {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--font-family);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.quick-cmd:hover {
  background: var(--accent-color);
  color: #000;
  box-shadow: 0 0 8px var(--glow-color);
}

/* Highlighted Text Styles in Terminal Output */
.dir-name {
  color: var(--dir-color);
  font-weight: bold;
}

.file-name {
  color: var(--file-color);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--accent-color);
  font-size: 12px;
  margin: 2px 4px 2px 0;
}

.highlight {
  color: var(--accent-color);
  font-weight: bold;
}

.link {
  color: var(--prompt-path);
  text-decoration: underline;
  cursor: pointer;
}

.link:hover {
  color: var(--accent-color);
}

.badge {
  background-color: var(--accent-color);
  color: #000;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: bold;
  font-size: 11px;
}

/* GUI Card Modal */
.gui-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.gui-modal.active {
  display: flex;
}

.gui-content {
  background: var(--header-bg);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 850px;
  max-height: 85vh;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.gui-header {
  padding: 16px 20px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gui-header h2 {
  font-size: 16px;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.gui-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
}

.gui-close:hover {
  color: #ff5f56;
}

.gui-body {
  padding: 24px;
  overflow-y: auto;
  color: var(--text-main);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .terminal-wrapper {
    padding-right: 20px;
  }
  .snakes-ladders-container {
    opacity: 0.3;
    pointer-events: none;
  }
}

@media (max-width: 768px) {
  html, body {
    font-size: 13px;
  }
  .ascii-art {
    font-size: 7px;
  }
  .terminal-wrapper {
    padding: 12px;
  }
  .header-btn span {
    display: none;
  }
}
