/* ==========================================================================
   Retro CRT Computer Terminal - Lightweight & High Performance
   Zero blur overhead, crisp phosphor green/cyan mono aesthetic, hardware accelerated.
   ========================================================================== */

#terminal-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100%;
  height: 100dvh;
  background: rgba(4, 7, 12, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 300;
  padding: 14px;
  overscroll-behavior: contain;
}

#terminal-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Outer CRT Monitor Shell */
.crt-bezel {
  width: min(720px, 100%);
  height: min(540px, calc(100vh - 32px));
  height: min(540px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  min-height: 0;
  background: #141822;
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  padding: 12px;
  display: flex;
  flex-direction: column;
  transform: scale(0.96);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

#terminal-modal.visible .crt-bezel {
  transform: scale(1);
}

/* CRT Header Status Bar */
.crt-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 8px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.crt-brand {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  font-size: 11.5px;
  color: #00e5ff;
  letter-spacing: 1.5px;
}

.crt-power-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #8b9bb4;
  font-family: var(--font-mono, monospace);
}

.crt-led {
  width: 7px;
  height: 7px;
  background-color: #2ecc71;
  border-radius: 50%;
  box-shadow: 0 0 6px #2ecc71;
}

.crt-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #d1d8e0;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.crt-close-btn:hover {
  background: rgba(235, 77, 75, 0.2);
  color: #ff7675;
  border-color: rgba(235, 77, 75, 0.4);
}

/* Phosphor CRT Screen */
.crt-screen {
  flex: 1;
  min-height: 0;
  background: #06090e;
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Subtle lightweight scanlines (pure CSS background pattern, no JS/DOM cost) */
.crt-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  opacity: 0.6;
}

.crt-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  z-index: 2;
  overflow: hidden;
}

.term-top-status {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: #557088;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(0, 229, 255, 0.15);
  margin-bottom: 8px;
}

/* Quick Action Toolbar inside Terminal */
.term-quick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.term-btn {
  background: #0f1520;
  border: 1px solid rgba(0, 229, 255, 0.2);
  color: #8bb0c9;
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.term-btn:hover {
  background: rgba(0, 229, 255, 0.12);
  color: #00e5ff;
  border-color: rgba(0, 229, 255, 0.4);
}

.term-btn.active {
  background: rgba(0, 229, 255, 0.2);
  color: #00e5ff;
  border-color: #00e5ff;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.3);
}

/* Terminal Command History Stream */
#term-output {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  line-height: 1.5;
  color: #00ffcc;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 4px;
}

.term-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.term-line.user-cmd {
  color: #ffffff;
  font-weight: 700;
}

.term-line.success {
  color: #2ecc71;
}

.term-line.warn {
  color: #f1c40f;
}

.term-line.err {
  color: #e74c3c;
}

/* Command Prompt Input Row */
.term-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 229, 255, 0.15);
}

.term-prompt {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: #00e5ff;
  font-weight: 700;
  white-space: nowrap;
}

#term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: #ffffff;
  caret-color: #00ffcc;
  user-select: text;
  -webkit-user-select: text;
}

#term-input::placeholder {
  color: #3b5066;
  font-size: 11px;
}

@media (max-width: 600px) {
  .crt-bezel {
    height: calc(100vh - 20px);
    padding: 8px;
  }
  
  .crt-brand {
    font-size: 10px;
  }

  .term-top-status {
    display: none;
  }
}
