@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Mono:wght@400;700&display=swap');

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: linear-gradient(135deg, #2c001e 0%, #300a24 50%, #2c001e 100%);
  --bg-terminal: rgba(48, 10, 36, 0.95);
  --border-color: #5e2750;
  --text-primary: #ffffff;
  --text-green: #8ae234;
  --text-blue: #729fcf;
  --text-yellow: #ddd500;
  --text-red: #ff6c60;
  --text-gray: #d3d7cf;
  --prompt-bg: rgba(138, 226, 52, 0.05);
}

[data-theme="light"] {
  --bg-primary: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
  --bg-terminal: rgba(255, 255, 255, 0.95);
  --border-color: #cccccc;
  --text-primary: #000000;
  --text-green: #008000;
  --text-blue: #0066cc;
  --text-yellow: #cc6600;
  --text-red: #cc0000;
  --text-gray: #666666;
  --prompt-bg: rgba(0, 128, 0, 0.05);
}

[data-theme="matrix"] {
  --bg-primary: linear-gradient(135deg, #000000 0%, #001100 50%, #000000 100%);
  --bg-terminal: rgba(0, 20, 0, 0.95);
  --border-color: #00ff00;
  --text-primary: #00ff00;
  --text-green: #00ff00;
  --text-blue: #00aa00;
  --text-yellow: #00cc00;
  --text-red: #ff0000;
  --text-gray: #006600;
  --prompt-bg: rgba(0, 255, 0, 0.05);
}

[data-theme="retro"] {
  --bg-primary: linear-gradient(135deg, #2a1810 0%, #3d2817 50%, #2a1810 100%);
  --bg-terminal: rgba(61, 40, 23, 0.95);
  --border-color: #ff6600;
  --text-primary: #ffaa00;
  --text-green: #ff6600;
  --text-blue: #ffcc00;
  --text-yellow: #ff9900;
  --text-red: #ff3300;
  --text-gray: #cc8800;
  --prompt-bg: rgba(255, 102, 0, 0.05);
}

[data-theme="cyberpunk"] {
  --bg-primary: linear-gradient(135deg, #0a0a23 0%, #1a0a3a 50%, #0a0a23 100%);
  --bg-terminal: rgba(26, 10, 58, 0.95);
  --border-color: #ff00ff;
  --text-primary: #00ffff;
  --text-green: #ff00ff;
  --text-blue: #00ffff;
  --text-yellow: #ffff00;
  --text-red: #ff0080;
  --text-gray: #8080ff;
  --prompt-bg: rgba(255, 0, 255, 0.05);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Ubuntu Mono', 'Liberation Mono', 'DejaVu Sans Mono', monospace;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(138, 226, 52, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(114, 159, 207, 0.05) 0%, transparent 50%);
  z-index: 1;
}

.terminal-container {
  width: min(95vw, 1200px);
  height: min(90vh, 800px);
  display: none; /* Initially hidden, changed to flex by JS */
  flex-direction: column;
  position: relative;
  z-index: 2;
}

.terminal-tabs {
  display: flex;
  background: var(--bg-terminal);
  border: 2px solid var(--border-color);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 0;
  overflow-x: auto;
}

.tab {
  background: rgba(0, 0, 0, 0.3);
  border: none;
  border-right: 1px solid var(--border-color);
  color: var(--text-gray);
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  font-size: 13px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tab.active {
  background: var(--bg-terminal);
  color: var(--text-green);
  border-bottom: 2px solid var(--text-green);
}

.tab-close {
  background: var(--text-red);
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  color: white;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.tab-close:hover {
  opacity: 1;
}

.tab-add {
  background: var(--text-green);
  border: none;
  color: var(--bg-terminal);
  padding: 10px 15px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  margin-left: auto;
  transition: all 0.3s ease;
}

.tab-add:hover {
  background: var(--text-blue);
}

.terminal {
  flex: 1;
  background: var(--bg-terminal);
  border: 2px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(94, 39, 80, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  overflow: hidden;
  transition: all 0.3s ease;
}

.terminal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(45deg, transparent 49%, rgba(255, 255, 255, 0.02) 50%, transparent 51%),
    linear-gradient(-45deg, transparent 49%, rgba(255, 255, 255, 0.02) 50%, transparent 51%);
  background-size: 20px 20px;
  pointer-events: none;
  z-index: 1;
}

.terminal-header {
  background: linear-gradient(180deg, var(--border-color) 0%, rgba(94, 39, 80, 0.8) 100%);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.window-controls {
  display: flex;
  gap: 8px;
}

.window-control {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.close { background: #ff5f56; }
.minimize { background: #ffbd2e; }
.maximize { background: #27ca3f; }

.window-control:hover {
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.terminal-title {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.terminal-output {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 15px;
  white-space: pre-wrap;
  line-height: 1.5;
  letter-spacing: 0.3px;
  position: relative;
  z-index: 2;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  scroll-behavior: smooth;
}

.terminal-output::-webkit-scrollbar {
  width: 8px;
}

.terminal-output::-webkit-scrollbar-track {
  background: rgba(94, 39, 80, 0.2);
  border-radius: 4px;
}

.terminal-output::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
  transition: background 0.3s ease;
}

.terminal-output::-webkit-scrollbar-thumb:hover {
  background: var(--text-green);
}

.prompt {
  color: var(--text-green);
  font-weight: bold;
  margin-right: 8px;
  user-select: none;
  font-size: 15px;
  text-shadow: 0 0 4px rgba(138, 226, 52, 0.3);
}

.input-area {
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  min-width: 2ch;
  flex: 1;
  border: none;
  padding: 0;
  white-space: pre;
  caret-color: var(--text-green);
}

.input-area:focus {
  background: var(--prompt-bg);
  border-radius: 3px;
}

.input-area.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--text-green);
  animation: typewriter 1s steps(40) 1s forwards, blink 1s infinite;
}

.loading-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--text-gray);
  border-top: 2px solid var(--text-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

.cursor {
  background: var(--text-green);
  width: 2px;
  height: 1.2em;
  display: inline-block;
  animation: blink 1.2s infinite;
  margin-left: 2px;
  box-shadow: 0 0 4px rgba(138, 226, 52, 0.5);
}

.text-green-500, .text-green-400 {
  color: var(--text-primary);
}

.text-green-500 {
  color: var(--text-green);
  text-shadow: 0 0 4px rgba(138, 226, 52, 0.3);
}

.command-output {
  color: var(--text-gray);
  margin: 4px 0;
  animation: fadeInUp 0.3s ease-out;
}

.error-text {
  color: var(--text-red);
  text-shadow: 0 0 4px rgba(255, 108, 96, 0.3);
}

.directory-color {
  color: var(--text-blue);
  font-weight: bold;
  text-shadow: 0 0 4px rgba(114, 159, 207, 0.3);
}

.file-color {
  color: var(--text-primary);
}

.executable-color {
  color: var(--text-green);
  font-weight: bold;
}

.cli-line {
  display: flex;
  align-items: center;
  margin: 2px 0;
  transition: background-color 0.2s ease;
}

.cli-line:hover {
  background: var(--prompt-bg);
  border-radius: 4px;
  padding: 2px 4px;
  margin: 2px -4px;
}

.welcome-text {
  background: linear-gradient(45deg, var(--text-green), var(--text-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: bold;
  font-size: 16px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.ubuntu-logo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 15px;
  vertical-align: middle;
  padding: 2px;
  animation: logoGlow 3s ease-in-out infinite;
}

.logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 10px currentColor;
  filter: brightness(1.2);
  transition: all 0.3s ease;
  animation: dotPulse 2s ease-in-out infinite;
}

.logo-dot:nth-child(1) {
  animation-delay: 0s;
}

.logo-dot:nth-child(2) {
  animation-delay: 0.3s;
}

.logo-dot:nth-child(3) {
  animation-delay: 0.6s;
}

.logo-dot:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px currentColor;
}

@keyframes logoGlow {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.1);
  }
}

@keyframes dotPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.welcome-line {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 0;
  position: relative;
  z-index: 3;
}

#matrix-loader {
  position: fixed;
  z-index: 100;
  top: 0; 
  left: 0;
  width: 100vw; 
  height: 100vh;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.7s ease;
  pointer-events: all;
}

#matrix-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.ubuntu-boot-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.boot-logo-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  animation: bootPulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 20px currentColor;
}

.boot-logo-dot:nth-child(1) {
  background: #E95420;
  color: #E95420;
  animation-delay: 0s;
}

.boot-logo-dot:nth-child(2) {
  background: #EF7B1D;
  color: #EF7B1D;
  animation-delay: 0.3s;
}

.boot-logo-dot:nth-child(3) {
  background: #E95420;
  color: #E95420;
  animation-delay: 0.6s;
}

@keyframes bootPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.boot-text {
  color: var(--text-primary);
  font-family: 'Ubuntu Mono', monospace;
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(138, 226, 52, 0.3);
}

.boot-subtitle {
  color: var(--text-blue);
  font-family: 'Ubuntu Mono', monospace;
  font-size: 16px;
  text-align: center;
  margin-bottom: 30px;
}

.progress-container {
  width: 300px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--text-green), var(--text-blue));
  width: 0%;
  border-radius: 3px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(138, 226, 52, 0.5);
}

.progress-text {
  color: var(--text-gray);
  font-family: 'Ubuntu Mono', monospace;
  font-size: 14px;
  text-align: center;
  margin-top: 15px;
}

.matrix-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.1;
  z-index: -1;
}

@media (max-width: 768px) {
  .terminal-container {
    width: 98vw;
    height: 95vh;
  }
  
  .terminal {
    border-radius: 0 0 8px 8px;
  }
  
  .terminal-tabs {
    border-radius: 8px 8px 0 0;
  }
  
  .terminal-output {
    padding: 15px;
    font-size: 14px;
  }
  
  .prompt, .input-area {
    font-size: 14px;
  }
  
  .ubuntu-logo {
    gap: 3px;
    margin-right: 10px;
  }
  
  .logo-dot {
    width: 10px;
    height: 10px;
  }
  
  .welcome-text {
    font-size: 14px;
  }
  
  .welcome-line {
    margin-bottom: 10px;
    padding: 6px 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.terminal-container {
  animation: fadeInUp 0.8s ease-out;
}