/* Base variables (dark is default) */
:root {
  --bg: #0b0f15;
  --panel: #0f1520;
  --text: #d6deeb;
  --muted: #8b9cb0;
  --accent: #6cf1ff;
  --success: #7CFC98;
  --warning: #f7df1e;
  --error: #ff6b6b;
  --link: #77b7ff;
  --prompt-user: #4ae3b5;
  --prompt-host: #77b7ff;
  --prompt-path: #9aa5b1;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
  --border: rgba(255,255,255,0.1);
  --pane-border: #30363d;
  --pane-active: #58a6ff;
}

body.theme-light {
  --bg: #fafafa;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #0ea5e9;
  --success: #16a34a;
  --warning: #a16207;
  --error: #dc2626;
  --link: #1d4ed8;
  --prompt-user: #0ea5e9;
  --prompt-host: #14b8a6;
  --prompt-path: #6b7280;
  --border: rgba(0,0,0,0.1);
  --pane-border: #d1d5db;
  --pane-active: #0ea5e9;
}

body.theme-matrix {
  --bg: #000000;
  --panel: #000000;
  --text: #d1fae5;
  --muted: #10b981;
  --accent: #34d399;
  --success: #34d399;
  --warning: #a7f3d0;
  --error: #f87171;
  --link: #6ee7b7;
  --prompt-user: #34d399;
  --prompt-host: #6ee7b7;
  --prompt-path: #10b981;
  --border: rgba(52,211,153,0.2);
  --pane-border: #065f46;
  --pane-active: #34d399;
}

body.theme-retro {
  --bg: #1b1b1b;
  --panel: #111111;
  --text: #f8f1e5;
  --muted: #e0c9a6;
  --accent: #f59e0b;
  --success: #a3e635;
  --warning: #fde68a;
  --error: #ef4444;
  --link: #fbbf24;
  --prompt-user: #f59e0b;
  --prompt-host: #fbbf24;
  --prompt-path: #e0c9a6;
  --border: rgba(245,158,11,0.2);
  --pane-border: #78350f;
  --pane-active: #f59e0b;
}

body.theme-catppuccin {
  --bg: #1e1e2e;
  --panel: #181825;
  --text: #cdd6f4;
  --muted: #6c7086;
  --accent: #cba6f7;
  --success: #a6e3a1;
  --warning: #f9e2af;
  --error: #f38ba8;
  --link: #89b4fa;
  --prompt-user: #94e2d5;
  --prompt-host: #89b4fa;
  --prompt-path: #fab387;
  --shadow: 0 8px 30px rgba(0,0,0,0.5);
  --border: rgba(203,166,247,0.2);
  --pane-border: #313244;
  --pane-active: #cba6f7;
}

body.theme-tokyo-night {
  --bg: #1a1b26;
  --panel: #16161e;
  --text: #c0caf5;
  --muted: #565f89;
  --accent: #bb9af7;
  --success: #9ece6a;
  --warning: #e0af68;
  --error: #f7768e;
  --link: #7aa2f7;
  --prompt-user: #73daca;
  --prompt-host: #7aa2f7;
  --prompt-path: #ff9e64;
  --shadow: 0 8px 30px rgba(0,0,0,0.6);
  --border: rgba(187,154,247,0.2);
  --pane-border: #292e42;
  --pane-active: #bb9af7;
}

body.theme-nord {
  --bg: #2e3440;
  --panel: #3b4252;
  --text: #eceff4;
  --muted: #4c566a;
  --accent: #88c0d0;
  --success: #a3be8c;
  --warning: #ebcb8b;
  --error: #bf616a;
  --link: #5e81ac;
  --prompt-user: #88c0d0;
  --prompt-host: #81a1c1;
  --prompt-path: #d08770;
  --shadow: 0 8px 30px rgba(0,0,0,0.4);
  --border: rgba(136,192,208,0.2);
  --pane-border: #434c5e;
  --pane-active: #88c0d0;
}

body.theme-dracula {
  --bg: #282a36;
  --panel: #21222c;
  --text: #f8f8f2;
  --muted: #6272a4;
  --accent: #bd93f9;
  --success: #50fa7b;
  --warning: #f1fa8c;
  --error: #ff5555;
  --link: #8be9fd;
  --prompt-user: #50fa7b;
  --prompt-host: #8be9fd;
  --prompt-path: #ffb86c;
  --shadow: 0 8px 30px rgba(0,0,0,0.5);
  --border: rgba(189,147,249,0.2);
  --pane-border: #44475a;
  --pane-active: #bd93f9;
}

/* Global reset */
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 8px 12px;
  background: var(--panel);
  color: var(--text);
}

/* Tmux-style container */
.tmux-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  height: 100vh;
  background: var(--bg);
  position: relative;
}

/* Tmux panes */
.tmux-pane {
  background: var(--panel);
  border: 1px solid var(--pane-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tmux-pane.active {
  border-color: var(--pane-active);
}

/* Pane headers */
.tmux-pane-header {
  background: linear-gradient(to bottom, rgba(255,255,255,0.05), transparent);
  border-bottom: 1px solid var(--pane-border);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pane-number {
  background: var(--accent);
  color: var(--bg);
  padding: 0 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
}

.pane-title {
  color: var(--muted);
  font-size: 13px;
}

/* Left pane (main terminal) */
.tmux-left {
  grid-row: 1 / 2;
  grid-column: 1 / 2;
  border-right: 2px solid var(--pane-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Right column container */
.tmux-right {
  grid-row: 1 / 2;
  grid-column: 2 / 3;
  display: grid;
  grid-template-rows: 40% 60%;
}

/* Right panes */
.tmux-right-top {
  border-bottom: 1px solid var(--pane-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tmux-right-bottom {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Output areas */
.output { 
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 0; /* Important for flex scrolling */
}

.tmux-left .output {
  padding-bottom: 0;
}

.pane-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0; /* Important for flex scrolling */
}

.output .line { display: block; margin-bottom: 2px; }
.output .muted { color: var(--muted); }
.output .accent { color: var(--accent); font-weight: bold; }
.output .accent-glow { 
  color: var(--accent); 
  text-shadow: 0 0 10px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}
.output a { color: var(--link); text-decoration: none; }
.output a:hover { text-decoration: underline; }

/* Clickable commands in welcome text */
.output strong a {
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.output strong a:hover {
  color: var(--link);
  text-shadow: 0 0 5px var(--accent);
  text-decoration: none;
}
.output strong { color: var(--accent); font-weight: 600; }
.output .error { color: var(--error); }
.output .success { color: var(--success); }
.output .warning { color: var(--warning); }
.output .at { color: var(--muted); }
.output .user { color: var(--prompt-user); }
.output .host { color: var(--prompt-host); }
.output .path { color: var(--prompt-path); }

/* Input form */
.input-form {
  flex-shrink: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--pane-border);
  background: linear-gradient(to top, rgba(0,0,0,0.1), transparent);
}

.prompt-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.prompt {
  color: var(--muted);
}
.prompt .user { color: var(--prompt-user); }
.prompt .host { color: var(--prompt-host); }
.prompt .path { color: var(--prompt-path); }

.input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  width: 100%;
}

/* Tmux status bar */
.tmux-status-bar {
  grid-column: 1 / -1;
  grid-row: 2 / 3;
  background: var(--pane-border);
  color: var(--text);
  padding: 2px 8px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 13px;
  border-top: 1px solid var(--pane-border);
}

.status-left {
  display: flex;
  gap: 12px;
}

.status-center {
  text-align: center;
}

.status-right {
  text-align: right;
}

.status-item {
  color: var(--muted);
}

.status-item:first-child {
  color: var(--accent);
}

/* Info and status sections */
.info-section, .status-section, .neofetch-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.neofetch-section .line {
  white-space: pre;
  font-size: 13px;
  line-height: 1.2;
}

.info-label {
  color: var(--accent);
  font-weight: 600;
}

/* No-JS fallback */
.no-js {
  max-width: 980px;
  margin: 24px auto;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Scrollbar styling */
.output::-webkit-scrollbar {
  width: 8px;
}

.output::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}

.output::-webkit-scrollbar-thumb {
  background: var(--pane-border);
  border-radius: 4px;
}

.output::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Contact Form Styles */
.contact-form-container {
  padding: 10px;
}

.cli-form {
  margin-top: 10px;
}

.form-group {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

.form-label {
  color: var(--muted);
  min-width: 80px;
  font-size: 0.9em;
}

.form-input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--pane-border);
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.9em;
  border-radius: 2px;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
}

.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

.form-button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 6px 16px;
  font-family: inherit;
  font-size: 0.9em;
  cursor: pointer;
  border-radius: 2px;
  transition: opacity 0.2s;
}

.form-button:hover {
  opacity: 0.8;
}

.form-button:active {
  transform: translateY(1px);
}

#form-feedback {
  margin-top: 10px;
}

#form-feedback .success {
  color: var(--success);
}

#form-feedback .error {
  color: var(--error);
}

/* CRT refresh animation for neofetch */
.crt-refresh-line {
  position: relative;
}

.crt-char {
  display: inline-block;
  transition: all 0.1s ease-in-out;
}

.crt-char.flicker {
  opacity: 0;
  transform: scale(0.7);
  filter: blur(1px);
  background: rgba(255, 255, 255, 0.2);
}

.crt-char.scanning {
  opacity: 0.5;
  transform: scale(0.95);
  filter: blur(0.5px);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  text-shadow: 0 0 2px rgba(255,255,255,0.5);
}

.crt-char.flash {
  opacity: 1;
  transform: scale(1.05);
  color: var(--accent);
  background: rgba(255,255,255,0.1);
  text-shadow: 0 0 6px var(--accent);
  filter: brightness(1.8);
}

.crt-scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent, 
    transparent,
    var(--accent), 
    rgba(255,255,255,0.8),
    var(--accent),
    transparent,
    transparent
  );
  opacity: 0.7;
  animation: scanlineMove linear forwards;
  box-shadow: 0 0 3px var(--accent);
}

@keyframes scanlineMove {
  0% { 
    transform: translateX(-100%);
    opacity: 0;
  }
  5% { 
    opacity: 0.7;
  }
  95% { 
    opacity: 0.7;
  }
  100% { 
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Terminal line animations */
.terminal-line {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.4s ease-out;
}

.terminal-line.animate {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

.terminal-line.typewriter {
  overflow: hidden;
  white-space: nowrap;
  width: 0;
  transition: width 0.6s steps(40, end), opacity 0.2s ease-out;
}

.terminal-line.typewriter.animate {
  width: 100% !important;
  opacity: 1 !important;
}

/* Cursor effect for last line */
.terminal-line.with-cursor::after {
  content: '▋';
  color: var(--accent);
  animation: cursorBlink 1s infinite;
  margin-left: 2px;
}

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

/* Banner animations */
.banner-line {
  transition: all 0.8s ease-out;
}

.banner-line.border-line.animate {
  transform: scaleX(1) !important;
  opacity: 1 !important;
}

.banner-line.ascii-line.animate {
  transform: translateX(0) !important;
  opacity: 1 !important;
}

.banner-line.tagline.animate {
  transform: translateY(0) !important;
  opacity: 1 !important;
}

.banner-line.animate {
  opacity: 1 !important;
}


.banner-glow {
  animation: bannerPulse 3s ease-in-out infinite;
}

@keyframes bannerPulse {
  0%, 100% { 
    text-shadow: 0 0 5px var(--accent);
    opacity: 1;
  }
  50% { 
    text-shadow: 0 0 15px var(--accent), 0 0 20px var(--accent);
    opacity: 0.9;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .banner-line,
  .terminal-line {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    width: auto !important;
  }
  .banner-glow {
    animation: none !important;
  }
  .terminal-line.with-cursor::after {
    animation: none !important;
  }
  .crt-char,
  .crt-char.flicker,
  .crt-char.flash,
  .crt-char.scanning {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    background: none !important;
    text-shadow: none !important;
    color: inherit !important;
  }
  .crt-scanline {
    animation: none !important;
    display: none !important;
  }
}

/* Selection */
::selection { background: rgba(119,183,255,0.28); }

/* Mobile responsive */
@media (max-width: 768px) {
  .tmux-container {
    grid-template-columns: 1fr;
    grid-template-rows: 2fr 1fr 1fr auto;
  }
  
  .tmux-left {
    grid-column: 1;
    grid-row: 1 / 2;
    border-right: none;
    border-bottom: 2px solid var(--pane-border);
  }
  
  .tmux-right {
    grid-column: 1;
    grid-row: 2 / 4;
    grid-template-rows: 1fr 1fr;
  }
  
  .tmux-right-top {
    grid-row: 1;
  }
  
  .tmux-right-bottom {
    grid-row: 2;
  }
  
  .tmux-status-bar {
    grid-row: 4;
  }
  
  .pane-number {
    font-size: 11px;
    padding: 0 4px;
  }
  
  .tmux-pane-header {
    padding: 3px 6px;
  }
  
  body {
    font-size: 13px;
  }
}