:root {
  --primary-bg: #0f1724;
  --secondary-bg: #0b1220;
  --terminal-bg: rgba(0, 0, 0, 0.25);
  --text-primary: #e6eef8;
  --text-secondary: #9ad0ff;
  --text-success: #7ee787;
  --text-error: #ff7676;
  --text-warning: #ffa657;
  --accent-green: #00ff99;
  --border-light: rgba(255, 255, 255, 0.03);
  --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--primary-bg);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.container {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Terminal Card */
.terminal-card {
  background: linear-gradient(135deg, var(--secondary-bg), #07101a);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

/* Card Header */
.card-header {
  background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border-bottom: 1px solid var(--border-light);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .card-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.badge {
  background: linear-gradient(45deg, #7ee787, #00ff99) !important;
  color: #000 !important;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.header-tagline {
  color: #9ad0ff;
  font-size: 0.85rem;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-outline-secondary {
  color: #9ad0ff;
  border-color: #9ad0ff;
}

.btn-outline-secondary:hover {
  background: #9ad0ff;
  color: #000;
}

.btn-outline-danger {
  color: #ff7676;
  border-color: #ff7676;
}

.btn-outline-danger:hover {
  background: #ff7676;
  color: #000;
}

.btn-outline-success {
  color: #7ee787;
  border-color: #7ee787;
}

.btn-outline-success:hover {
  background: #7ee787;
  color: #000;
}

/* Terminal Body */
.terminal-body {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  min-height: 60vh;
  max-height: 70vh;
  overflow: auto;
  padding: 1.25rem;
  background: var(--terminal-bg);
  scroll-behavior: smooth;
  position: relative;
}

/* Custom scrollbar for terminal */
.terminal-body::-webkit-scrollbar {
  width: 8px;
}

.terminal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Prompt Line */
#prompt-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#prompt {
  color: var(--text-success);
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
}

#cmdline {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: red;
  font-family: inherit;
  font-size: 0.9rem;
  min-width: 0; /* Allow shrinking */
  caret-color: var(--text-success);
}

#cmdline::after {
  content: '|';
  display: inline-block;
  margin-left: 2px;
  animation: blink 1.2s infinite;
  color: var(--text-success);
  font-weight: bold;
}

/* Output Styles */
.output-line {
  color: white;
  white-space: pre-wrap;
  margin-bottom: 0.5rem;
  word-wrap: break-word;
  line-height: 1.4;
}

.output-cmd {
  color: var(--text-secondary);
  font-weight: 500;
}

.output-err {
  color: var(--text-error);
  background: rgba(255, 118, 118, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border-left: 3px solid var(--text-error);
}

.output-success {
  color: var(--text-success);
  background: rgba(126, 231, 135, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border-left: 3px solid var(--text-success);
}

.output-hint {
  color: var(--text-warning);
  background: rgba(255, 166, 87, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border-left: 3px solid var(--text-warning);
  font-style: italic;
}

/* Card Footer */
.card-footer {
  background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border-top: 1px solid var(--border-light);
  padding: 0.75rem 1.25rem;
  font-size: 0.8rem;
  color: #9ad0ff;
}

.card-footer code {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  color: var(--text-success);
  font-size: 0.75rem;
}

/* Animations */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.output-line, .output-cmd, .output-err, .output-success, .output-hint {
  animation: fadeIn 0.2s ease-out;
}

/* Nano Modal - Responsive */
.nano-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(5px);
}

.nano-window {
  width: 100%;
  height: 80%;
  max-width: 900px;
  background: #101823;
  box-shadow: 0 20px 60px rgba(0, 255, 153, 0.3);
  border-radius: 8px;
  border: 2px solid var(--accent-green);
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.nano-header {
  background: linear-gradient(90deg, var(--accent-green), #7ee787);
  color: #000;
  padding: 0.75rem 1rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 6px 6px 0 0;
}

.nano-footer {
  background: linear-gradient(90deg, var(--accent-green), #7ee787);
  color: #000;
  padding: 0.5rem;
  font-size: 0.75rem;
  text-align: center;
  font-weight: 500;
  border-radius: 0 0 6px 6px;
}

#nano-editor {
  flex: 1;
  background: var(--primary-bg);
  color: var(--accent-green);
  border: none;
  padding: 1rem;
  font-family: 'SF Mono', Monaco, monospace;
  resize: none;
  outline: none;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Mobile Optimizations */
@media (max-width: 767px) {
  .container {
    padding: 0.5rem;
  }
  
  .terminal-body {
    min-height: 50vh;
    max-height: 60vh;
    padding: 1rem;
    font-size: 0.85rem;
  }
  
  .card-header {
    padding: 0.75rem 1rem;
  }
  
  .header-controls {
    justify-content: center;
  }
  
  .btn {
    flex: 1;
    min-width: 80px;
    text-align: center;
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
  }
  
  #prompt-line {
    margin-top: 0.5rem;
    padding: 0.4rem;
  }
  
  #prompt {
    font-size: 0.8rem;
  }
  
  #cmdline {
    font-size: 0.8rem;
  }
  
  .nano-window {
    height: 85%;
    margin: 0.5rem;
  }
  
  .nano-header {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
  }
  
  #nano-editor {
    padding: 0.8rem;
    font-size: 0.85rem;
  }
}

/* Tablet Optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
  .container {
    padding: 1.5rem;
  }
  
  .terminal-body {
    min-height: 55vh;
    max-height: 65vh;
  }
  
  .nano-window {
    height: 75%;
    margin: 2rem;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  .terminal-body {
    min-height: 65vh;
    max-height: 75vh;
  }
}

/* Loading animation for initial load */
.terminal-card {
  animation: cardAppear 0.5s ease-out;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Focus states for accessibility */
.btn:focus,
#cmdline:focus,
#nano-editor:focus {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

/* Selection colors */
::selection {
  background: rgba(126, 231, 135, 0.3);
  color: inherit;
}

::-moz-selection {
  background: rgba(126, 231, 135, 0.3);
  color: inherit;
}