/* =========================================================
   RESET
========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* =========================================================
   THEME VARIABLES
========================================================= */
:root {
  --bg-main: #0b0c10;
  --text-main: #c5c6c7;
  --terminal-bg: #1f2833;
  --terminal-header-bg: #151a22;
  --terminal-border: #0b0c10;
  --prompt-color: #66ff66;
  --command-highlight: #61dafb;
  --command-text: #ffffff;
  --output-text: #c5c6c7;
  --error-text: #ff6b81;
  --shadow-color: rgba(0, 0, 0, 0.6);
}

.light-theme {
  --bg-main: #f6f7fb;
  --text-main: #1b1f23;
  --terminal-bg: #ffffff;
  --terminal-header-bg: #e4e7ec;
  --terminal-border: #c9d1d9;
  --prompt-color: #008000;
  --command-highlight: #007acc;
  --command-text: #111827;
  --output-text: #374151;
  --error-text: #b91c1c;
  --shadow-color: rgba(15, 23, 42, 0.25);
}

/* =========================================================
   EXTRA COLOR THEMES
========================================================= */
html[data-color-theme="matrix"] {
  --bg-main: #020617;
  --text-main: #bbf7d0;
  --terminal-bg: #020617;
  --terminal-header-bg: #020617;
  --terminal-border: #022c22;
  --prompt-color: #22c55e;
  --command-highlight: #4ade80;
  --command-text: #bbf7d0;
  --output-text: #86efac;
  --error-text: #f97373;
  --shadow-color: rgba(16, 185, 129, 0.35);
}

html[data-color-theme="ubuntu"] {
  --bg-main: #2c001e;
  --text-main: #f2e5ff;
  --terminal-bg: #300a24;
  --terminal-header-bg: #2c001e;
  --terminal-border: #5e2750;
  --prompt-color: #f89406;
  --command-highlight: #fbbf24;
  --command-text: #fef3c7;
  --output-text: #e5e7eb;
  --error-text: #fb7185;
  --shadow-color: rgba(0, 0, 0, 0.6);
}

html[data-color-theme="retro-green"] {
  --bg-main: #020b03;
  --text-main: #7ee787;
  --terminal-bg: #000000;
  --terminal-header-bg: #000000;
  --terminal-border: #134e4a;
  --prompt-color: #22c55e;
  --command-highlight: #4ade80;
  --command-text: #bbf7d0;
  --output-text: #22c55e;
  --error-text: #f97373;
  --shadow-color: rgba(16, 185, 129, 0.4);
}

html[data-color-theme="dracula"] {
  --bg-main: #282a36;
  --text-main: #f8f8f2;
  --terminal-bg: #1e1f29;
  --terminal-header-bg: #191a21;
  -- Hawaiian: #44475a;
  --prompt-color: #50fa7b;
  --command-highlight: #bd93f9;
  --command-text: #f8f8f2;
  --output-text: #f8f8f2;
  --error-text: #ff5555;
  --shadow-color: rgba(0, 0, 0, 0.6);
}

/* =========================================================
   BASE LAYOUT
========================================================= */
html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   TERMINAL CONTAINER
========================================================= */
.terminal-container {
  width: min(100%, 900px);
  height: min(80vh, 650px);
  background: var(--terminal-bg);
  border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================
   HEADER (STICKY)
========================================================= */
.terminal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--terminal-header-bg);
  border-bottom: 1px solid var(--terminal-border);
}

.terminal-buttons {
  display: flex;
  gap: 0.4rem;
}

.btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

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

.terminal-title {
  color: #9da5b4;
  font-size: 0.8rem;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-toggle {
  border: none;
  background: transparent;
  color: #9da5b4;
  cursor: pointer;
  font-size: 0.9rem;
}

/* =========================================================
   TERMINAL BODY
========================================================= */
.terminal-body {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  font-size: 0.9rem;
}

.line {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.prompt {
  color: var(--prompt-color);
  margin-right: 0.4rem;
}

.command-highlight {
  color: var(--command-highlight);
}

.command-text {
  color: var(--command-text);
}

.output-text {
  color: var(--output-text);
}

.error-text {
  color: var(--error-text);
}

.section-title {
  color: var(--command-highlight);
  font-weight: bold;
}

/* =========================================================
   INPUT (STICKY)
========================================================= */
.terminal-input-row {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--terminal-border);
  background: var(--terminal-header-bg);
}

.terminal-input-inner {
  display: flex;
  align-items: center;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--command-text);
  font: inherit;
}

#terminal-input::placeholder {
  color: #4b5263;
}

#terminal-input:disabled {
  opacity: 0.5;
}

/* =========================================================
   CURSOR
========================================================= */
.cursor {
  display: inline-block;
  margin-left: 2px;
  color: var(--prompt-color);
  animation: blink 1s step-start infinite;
}

.cursor::before {
  content: "█";
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* =========================================================
   STATUS BAR
========================================================= */
.status-bar {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #9da5b4;
  text-align: center;
  padding-bottom: 0.5rem;
}

.command-highlight {
  color: var(--command-highlight);
}

/* =========================================================
   MOBILE FLOAT BUTTON
========================================================= */
.focus-input-btn {
  position: fixed;
  right: 1rem;
  bottom: 1.25rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  background: #22c55e;
  color: #0b1120;
  font-size: 1.2rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
}

/* =========================================================
   MOBILE SAFARI FIX
========================================================= */
@media (max-width: 600px) {
  body {
    justify-content: flex-start;
  }

  .terminal-container {
    width: 100%;
    min-height: 100dvh;
    height: auto;
    border-radius: 0;
    box-shadow: none;
  }

  .terminal-header {
    padding-top: env(safe-area-inset-top);
  }

  .terminal-input-row {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .focus-input-btn {
    display: flex;
  }
}

/* ===== MOBILE LAYOUT FIX (CRITICAL) ===== */
@media (max-width: 600px) {
  body {
    display: block;
    align-items: unset;
    justify-content: unset;
  }

  .terminal-container {
    margin: 0 auto;
  }

  .status-bar {
    width: 100%;
    text-align: center;
  }
}
