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

:root {
  /* Default theme - green */
  --primary-color: #0f0;
  --secondary-color: #073;
  --background: #000;
  --terminal-bg: #111;
  --header-bg: #222;
  --text-color: #0f0;
  --shadow-color: rgba(0, 255, 0, 0.4);
  --link-color: #0ff;
  --file-color: #fff;
  --directory-color: #0af;
  
  /* Background animation */
  --particle-color: rgba(0, 255, 0, 0.1);
  --matrix-color: rgba(0, 255, 0, 0.05);
  --font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
}

/* Blue hacker theme */
body[data-theme="blue"] {
  --primary-color: #00ffff;
  --secondary-color: #007777;
  --background: #001122;
  --terminal-bg: #003366;
  --header-bg: #004488;
  --text-color: #00ffff;
  --shadow-color: rgba(0, 255, 255, 0.4);
  --link-color: #ff00ff;
  --file-color: #ffffff;
  --directory-color: #ffff00;
  --particle-color: rgba(0, 255, 255, 0.1);
  --matrix-color: rgba(0, 255, 255, 0.05);
}

/* Cyber blue theme */
body[data-theme="cyber-blue"] {
  --primary-color: #0080ff;
  --secondary-color: #004499;
  --background: #000510;
  --terminal-bg: #001122;
  --header-bg: #002244;
  --text-color: #0080ff;
  --shadow-color: rgba(0, 128, 255, 0.4);
  --link-color: #80ff00;
  --file-color: #ffffff;
  --directory-color: #ff8000;
  --particle-color: rgba(0, 128, 255, 0.1);
  --matrix-color: rgba(0, 255, 255, 0.05);
}

/* Matrix blue theme */
body[data-theme="matrix-blue"] {
  --primary-color: #00ccff;
  --secondary-color: #0088aa;
  --background: #001122;
  --terminal-bg: #003344;
  --header-bg: #005566;
  --text-color: #00ccff;
  --shadow-color: rgba(0, 204, 255, 0.4);
  --link-color: #ffcc00;
  --file-color: #ffffff;
  --directory-color: #ff6600;
  --particle-color: rgba(0, 204, 255, 0.1);
  --matrix-color: rgba(0, 204, 255, 0.05);
}

body {
  background: var(--background);
  color: var(--text-color);
  font-family: var(--font-family);
  height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Optimized background animation */
#background-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  background: var(--particle-color);
  border-radius: 50%;
  pointer-events: none;
  animation: float 15s infinite linear;
}

@keyframes float {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-10vh) scale(1);
    opacity: 0;
  }
}

/* Matrix animation */
.matrix-column {
  position: absolute;
  top: -50px;
  font-family: var(--font-family);
  font-size: 12px;
  color: var(--matrix-color);
  animation: matrix-fall 4s linear infinite;
  line-height: 1.2;
}

@keyframes matrix-fall {
  0% {
    transform: translateY(-50px);
  }
  100% {
    transform: translateY(100vh);
  }
}

/* Full header */
.main-header {
  background: var(--header-bg);
  border-bottom: 2px solid var(--primary-color);
  padding: 15px 20px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 100;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.logo {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary-color);
  text-shadow: 0 0 10px var(--shadow-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.theme-selector {
  background: var(--terminal-bg);
  border: 1px solid var(--primary-color);
  color: var(--text-color);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 13px;
  min-width: 140px;
  cursor: pointer;
}

.animation-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 12px;
  background: var(--terminal-bg);
  border: 1px solid var(--primary-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.animation-toggle:hover {
  background: var(--primary-color);
  color: var(--background);
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 20px;
  background: var(--background);
  border-radius: 10px;
  border: 1px solid var(--primary-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-switch.active {
  background: var(--primary-color);
}

.toggle-switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-color);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch.active::before {
  left: 22px;
  background: var(--background);
}

/* Navigation menu */
.nav-menu {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.nav-item {
  background: transparent;
  border: 1px solid var(--primary-color);
  color: var(--text-color);
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--primary-color);
  transition: left 0.3s ease;
  z-index: -1;
}

.nav-item:hover::before,
.nav-item.active::before {
  left: 0;
}

.nav-item:hover,
.nav-item.active {
  color: var(--background);
  box-shadow: 0 0 15px var(--shadow-color);
}

/* Main content */
.content-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  overflow: hidden;
}

/* Terminal */
.terminal-container {
  flex: 1;
  margin: 0 20px;
  margin-top: 10px;
  margin-bottom: 20px;
  position: relative;
}

.terminal {
  width: 100%;
  height: 100%;
  background: var(--terminal-bg);
  border-radius: 8px;
  box-shadow: 0 0 30px var(--shadow-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 2px solid var(--primary-color);
  position: relative;
}

.ssh-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 1000;
  color: var(--primary-color);
}

.ssh-connection {
  text-align: center;
  animation: sshPulse 2s infinite;
}

@keyframes sshPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.ssh-loading {
  width: 200px;
  height: 4px;
  background: var(--background);
  border-radius: 2px;
  margin: 20px 0;
  overflow: hidden;
}

.ssh-progress {
  height: 100%;
  background: var(--primary-color);
  border-radius: 2px;
  animation: sshLoading 3s ease-in-out;
}

@keyframes sshLoading {
  0% { width: 0; }
  100% { width: 100%; }
}

.header {
  background: var(--header-bg);
  padding: 8px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--primary-color);
  font-size: 14px;
}

.title {
  color: var(--text-color);
  font-weight: 500;
}

.buttons {
  display: flex;
  gap: 8px;
}

.btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: scale(1.2);
}

.minimize { background: #ff5f56; }
.maximize { background: #ffbd2e; }
.close { background: #27c93f; }

.body {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) var(--terminal-bg);
  scroll-behavior: smooth;
}

.body::-webkit-scrollbar {
  width: 8px;
}

.body::-webkit-scrollbar-track {
  background: var(--terminal-bg);
}

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

/* Enhanced scroll indicators */
.scroll-indicator {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.scroll-indicator.visible {
  opacity: 0.7;
}

.scroll-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-color);
}

.scroll-dot.active {
  background: var(--link-color);
}

/* Scroll to top button */
.scroll-to-top {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--terminal-bg);
  border: 1px solid var(--primary-color);
  color: var(--text-color);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s ease;
  font-size: 14px;
  z-index: 100;
}

.scroll-to-top.visible {
  opacity: 0.7;
}

.scroll-to-top:hover {
  opacity: 1;
  background: var(--primary-color);
  color: var(--background);
}

.input-line {
  display: flex;
  padding: 0 15px 15px;
  align-items: center;
  gap: 8px;
  position: relative;
}

.prompt {
  color: var(--text-color);
  user-select: none;
  font-weight: 500;
  white-space: nowrap;
}

#command-input {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-family: var(--font-family);
  font-size: 15px;
  flex: 1;
  outline: none;
  padding: 0;
}

#command-input::placeholder {
  color: var(--secondary-color);
}

#command-input:focus {
  text-shadow: 0 0 5px var(--shadow-color);
}

.line {
  margin-bottom: 8px;
  word-break: break-word;
}

.line.no-animation {
  animation: none !important;
}

.output.no-animation {
  animation: none !important;
}

.typing::after {
  content: '_';
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.output {
  color: var(--file-color);
  margin: 6px 0;
  white-space: pre-wrap;
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  /* RTL fix for mixed content */
  unicode-bidi: plaintext;
  text-align: left;
  direction: ltr;
}

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

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

.link { 
  color: var(--link-color); 
  text-decoration: underline; 
  cursor: pointer; 
  transition: all 0.3s ease;
}

.link:hover {
  text-shadow: 0 0 5px currentColor;
}

/* Search Results */
.search-result {
  background: var(--terminal-bg);
  border: 1px solid var(--primary-color);
  border-radius: 4px;
  padding: 10px;
  margin: 8px 0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.search-result:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

.search-highlight {
  background: var(--link-color);
  color: var(--background);
  padding: 0 2px;
  border-radius: 2px;
}

/* Analytics Dashboard */
.analytics-container {
  background: var(--terminal-bg);
  border: 1px solid var(--primary-color);
  border-radius: 6px;
  padding: 20px;
  margin: 10px 0;
}

.analytics-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--secondary-color);
  border-radius: 4px;
  padding: 15px;
  text-align: center;
}

.stat-number {
  font-size: 24px;
  font-weight: bold;
  color: var(--link-color);
  display: block;
}

.stat-label {
  font-size: 12px;
  color: var(--text-color);
  opacity: 0.8;
  margin-top: 5px;
}

.most-used-commands {
  margin-top: 20px;
}

.command-bar {
  display: flex;
  align-items: center;
  margin: 5px 0;
}

.command-name {
  min-width: 100px;
  font-weight: bold;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--background);
  border-radius: 4px;
  margin: 0 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.5s ease;
}

/* Easter Egg Styles */
.glitch {
  animation: glitch 0.3s infinite;
}

@keyframes glitch {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

/* API Status Indicator */
.api-status {
  position: fixed;
  top: 10px;
  right: 10px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 5px;
}

.api-status.online {
  background: rgba(0, 255, 0, 0.2);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.api-status.offline {
  background: rgba(255, 0, 0, 0.2);
  color: #ff0000;
  border: 1px solid #ff0000;
}

/* Mobile responsive */
@media (max-width: 768px) {
  body {
    height: 100vh;
    overflow: hidden;
  }
  
  .main-header {
    padding: 10px 15px;
  }
  
  .header-top {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 10px;
  }
  
  .logo {
    font-size: 18px;
    justify-content: center;
  }
  
  .theme-controls {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .theme-selector {
    width: 100%;
    min-width: unset;
  }
  
  .animation-toggle {
    width: 100%;
    justify-content: center;
  }
  
  .nav-menu {
    justify-content: flex-start;
    padding: 0;
  }
  
  .nav-item {
    font-size: 12px;
    padding: 8px 12px;
    flex-shrink: 0;
  }
  
  .content-container {
    height: calc(100vh - 180px);
    margin: 0;
  }
  
  .terminal-container {
    margin: 0;
    padding: 0 10px;
  }
  
  .terminal {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  .body {
    padding: 12px;
    font-size: 14px;
  }
  
  .header {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .input-line {
    padding: 0 12px 12px;
  }
  
  #command-input {
    font-size: 14px;
  }

  .api-status {
    top: 5px;
    right: 5px;
    font-size: 10px;
    padding: 4px 8px;
  }

  .analytics-stats {
    grid-template-columns: 1fr;
  }

  /* Hide scroll indicators on mobile */
  .scroll-indicator,
  .scroll-to-top {
    display: none !important;
  }
}

/* Auto dark mode for those who prefer dark mode */
@media (prefers-color-scheme: dark) {
  body:not([data-theme]) {
    --primary-color: #00ff00;
    --secondary-color: #007700;
    --background: #000000;
    --terminal-bg: #111111;
    --header-bg: #222222;
    --text-color: #00ff00;
    --shadow-color: rgba(0, 255, 0, 0.4);
    --link-color: #00ffff;
    --file-color: #ffffff;
    --directory-color: #0088ff;
    --particle-color: rgba(0, 255, 0, 0.1);
    --matrix-color: rgba(0, 255, 0, 0.05);
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .particle,
  .matrix-column,
  .fade-in,
  .typing::after,
  .loading,
  .btn:hover,
  .nav-item::before,
  .help-item:hover {
    animation: none;
    transition: none;
  }
}
