/* Scoped CSS variables - prefixed to avoid conflicts with consuming projects */
:root {
  --wcli-bg-color: #0a0e14;
  --wcli-text-color: #b3b9c5;
  --wcli-prompt-color: #39bae6;
  --wcli-input-color: #ffffff;
  --wcli-error-color: #ff3333;
  --wcli-success-color: #7fd962;
  --wcli-warning-color: #ffcc66;
  
  --wcli-ansi-red: #ff3333;
  --wcli-ansi-green: #7fd962;
  --wcli-ansi-yellow: #ffcc66;
  --wcli-ansi-blue: #59c2ff;
  --wcli-ansi-magenta: #d4bfff;
  --wcli-ansi-cyan: #5ccfe6;
}

.terminal-wrapper {
    display: flex;
    flex-direction: row;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.terminal-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.sidebar-toggle-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
    background: rgba(57, 186, 230, 0.2);
    border: 1px solid var(--wcli-prompt-color);
    border-radius: 4px;
    color: var(--wcli-prompt-color);
    padding: 4px 8px;
    padding-top: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s, transform 0.2s;
  }

.sidebar-toggle-btn:hover {
    background: rgba(57, 186, 230, 0.3);
    transform: scale(1.05);
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

/* Ensure toggle button is above backdrop on mobile */
@media (max-width: 768px) {
    .sidebar-toggle-btn {
        z-index: 1002;
    }
}

/* All styles scoped to terminal components to avoid conflicts */
.terminal-container,
.terminal-container * {
  box-sizing: border-box;
}

.terminal-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
  background-color: var(--wcli-bg-color);
  color: var(--wcli-text-color);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 10px;
  line-height: 1.5;
  font-size: 16px;
}

.terminal-output::-webkit-scrollbar {
  width: 8px;
}

.terminal-output::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

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

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

.terminal-line {
  margin: 2px 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.terminal-line-input {
  color: var(--wcli-text-color);
}

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

.terminal-line-error {
  color: var(--wcli-error-color);
}

.prompt {
  color: var(--wcli-prompt-color);
  font-weight: bold;
  user-select: none;
}

.input-text {
  color: var(--wcli-input-color);
  margin-left: 4px;
}

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

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

/* ANSI color support */
.ansi-red {
  color: var(--wcli-ansi-red);
}

.ansi-green {
  color: var(--wcli-ansi-green);
}

.ansi-yellow {
  color: var(--wcli-ansi-yellow);
}

.ansi-blue {
  color: var(--wcli-ansi-blue);
}

.ansi-magenta {
  color: var(--wcli-ansi-magenta);
}

.ansi-cyan {
  color: var(--wcli-ansi-cyan);
}

.terminal-suggestions {
  display: none;
  padding: 8px 12px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--wcli-prompt-color);
  font-size: 13px;
  color: var(--wcli-text-color);
  max-height: 100px;
  overflow-y: auto;
}

.suggestion-item {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: var(--wcli-prompt-color);
}

.suggestion-more {
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  font-size: 12px;
}

.terminal-input-container {
  display: flex;
  align-items: center;
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--wcli-input-color);
  font-family: inherit;
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  margin-left: 4px;
  caret-color: var(--wcli-prompt-color);
}

.terminal-input::selection {
  background: rgba(57, 186, 230, 0.3);
}

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

.cursor {
  animation: blink 1s infinite;
}

/* Selection - scoped to terminal container */
.terminal-container ::selection {
  background: rgba(57, 186, 230, 0.3);
}

.terminal-container ::-moz-selection {
  background: rgba(57, 186, 230, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .terminal-output,
  .terminal-input {
    font-size: 14px;
  }
  
  .terminal-input-container {
    /* Add extra padding on mobile to ensure input is visible */
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

/* Focus indicator */
.terminal-input:focus {
  outline: none;
}

/* Welcome message styling */
.terminal-line:first-child {
  color: var(--wcli-success-color);
  font-weight: bold;
}
