/* Terminal Widget Styles - keywordsAI */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

.terminal-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  font-family: 'JetBrains Mono', monospace;
}

.terminal-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #0d1a0d 0%, #0a150a 100%);
  border: 1px solid #27ca40;
  border-radius: 8px;
  color: #27ca40;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(39, 202, 64, 0.3);
}

.terminal-trigger:hover {
  background: linear-gradient(135deg, #0a150a 0%, #0d1a0d 100%);
  box-shadow: 0 0 30px rgba(39, 202, 64, 0.5);
  transform: translateY(-2px);
}

.terminal-panel {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  max-width: calc(100vw - 48px);
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 212, 255, 0.1);
}

.terminal-panel.open {
  display: flex;
  flex-direction: column;
  animation: terminalOpen 0.3s ease-out;
}

@keyframes terminalOpen {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.terminal-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
  gap: 8px;
}

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

.terminal-dot.red { background: #ff5f56; }
.terminal-dot.yellow { background: #ffbd2e; }
.terminal-dot.green { background: #27ca40; }

.terminal-title {
  flex: 1;
  text-align: center;
  color: #888;
  font-size: 13px;
}

.terminal-close {
  background: transparent;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.terminal-close:hover {
  background: #333;
  color: #fff;
}

.terminal-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  max-height: 350px;
  min-height: 200px;
  background: #0d0d0d;
}

.terminal-line {
  margin-bottom: 8px;
  line-height: 1.6;
  font-size: 13px;
}

.terminal-prompt {
  color: #27ca40;
  margin-right: 8px;
}

.terminal-cmd {
  color: #e0e0e0;
}

.terminal-output {
  color: #00d4ff;
  display: block;
  padding-left: 20px;
}

.terminal-thinking {
  color: #ffbd2e;
  display: block;
  padding-left: 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.terminal-error {
  color: #ff5f56;
  display: block;
  padding-left: 20px;
}

.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: #27ca40;
  animation: blink 1s step-end infinite;
  vertical-align: middle;
}

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

.terminal-chips {
  display: flex;
  gap: 8px;
  padding: 12px 0 4px;
  flex-wrap: wrap;
}

.terminal-chip {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid #444;
  border-radius: 4px;
  color: #888;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.terminal-chip:hover {
  border-color: #00d4ff;
  color: #00d4ff;
  background: rgba(0, 212, 255, 0.1);
}

.terminal-input-area {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #111;
  border-top: 1px solid #333;
  gap: 8px;
}

.prompt-symbol {
  color: #27ca40;
  font-size: 14px;
}

.terminal-input-area input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e0e0e0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  outline: none;
}

.terminal-input-area input::placeholder {
  color: #555;
}

.terminal-input-area button {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #27ca40;
  border-radius: 4px;
  color: #27ca40;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.terminal-input-area button:hover {
  background: #27ca40;
  color: #0d0d0d;
}

.terminal-input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.terminal-body::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* Action buttons rendered inline after bot responses */
.terminal-actions-bar {
  display: flex;
  gap: 8px;
  padding: 8px 0 4px 20px;
  flex-wrap: wrap;
}

.terminal-action-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid #444;
  border-radius: 4px;
  color: #888;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.terminal-action-btn:hover {
  border-color: #00d4ff;
  color: #00d4ff;
  background: rgba(0, 212, 255, 0.1);
}

.terminal-action-btn.primary {
  background: #27ca40;
  color: #0d0d0d;
  border-color: #27ca40;
  font-weight: 600;
}

.terminal-action-btn.primary:hover {
  opacity: 0.85;
}

/* Mobile responsive */

/* --- Mid-size (≤768px) --- */
@media (max-width: 768px) {
  .terminal-panel {
    width: calc(100vw - 48px);
    max-width: 700px;
  }

  .terminal-trigger {
    right: 16px;
    bottom: 16px;
  }
}

/* --- Phone (≤480px): bottom-sheet style --- */
@media (max-width: 480px) {
  .terminal-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: none;
    transform: none;
    border-radius: 12px 12px 0 0;
    max-height: calc(100vh - 60px);   /* fallback */
    max-height: calc(100dvh - 60px);
  }

  .terminal-panel.open {
    animation: terminalOpenMobile 0.3s ease-out;
  }

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

  .terminal-input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .terminal-trigger {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  /* Touch targets — 44px minimum */
  .terminal-close {
    min-width: 44px;
    min-height: 44px;
  }

  .terminal-chip {
    min-height: 44px;
    padding: 10px 14px;
  }

  .terminal-input-area button {
    min-height: 44px;
  }
}

/* --- Landscape (short viewport) --- */
@media (orientation: landscape) and (max-height: 500px) {
  .terminal-panel {
    max-height: calc(100vh - 16px);   /* fallback */
    max-height: calc(100dvh - 16px);
  }

  .terminal-body {
    max-height: 160px;
  }
}

/* --- Virtual keyboard open state --- */
.terminal-panel.clarm-keyboard-open {
  bottom: var(--widget-keyboard-offset, 0px);
  max-height: calc(100dvh - 60px - var(--widget-keyboard-offset, 0px));
}

