/*
  Bash terminal theme for AI Engine Pro
  Root class: .mwai-powershell-theme
  Designed for NG Kerk Vishoek — Digitale Metgesel
*/

/* ─── CSS Variables ─────────────────────────────────────────────── */
.mwai-powershell-theme {
  font-family: Consolas, 'Ubuntu Mono', 'Lucida Console', 'Courier New', monospace;
  --mwai-fontSize:                14px;
  --mwai-lineHeight:              1.55;
  --mwai-borderRadius:            0;
  --mwai-width:                   100%;
  --mwai-maxHeight:               60vh;
  --mwai-spacing:                 8px 16px;
  --mwai-fontColor:               #F8F8F2;
  --mwai-headerColor:             #AAAAAA;
  --mwai-backgroundPrimaryColor:  #1E1E1E;
  --mwai-backgroundSecondaryColor:#1E1E1E;
  --mwai-backgroundHeaderColor:   #2D2D2D;
  --mwai-bubbleColor:             transparent;
  --mwai-borderColor:             #333333;
  --mwai-accentColor:             #4AF626;
  --mwai-iconSize:                60px;
  --mwai-iconTextColor:           #F8F8F2;
  --mwai-iconTextBackgroundColor: #2D2D2D;
  --mwai-conversationsBackgroundColor: #1E1E1E;
  --mwai-conversationsTextColor:  #F8F8F2;
  --mwai-errorBackgroundColor:    #4A1A1A;
  --mwai-errorTextColor:          #FF8888;
}

.mwai-powershell-theme * {
  box-sizing: border-box;
}

/* ─── Main body container ───────────────────────────────────────── */
.mwai-powershell-theme .mwai-body {
  background: #1E1E1E;
  color: #F8F8F2;
  font-size: 14px;
  font-family: Consolas, 'Ubuntu Mono', 'Lucida Console', 'Courier New', monospace;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── Hide plugin header (our custom dm-chat-header replaces it) ── */
.mwai-powershell-theme .mwai-header {
  display: none;
}

/* ─── Conversation / message area ──────────────────────────────── */
.mwai-powershell-theme .mwai-conversation {
  background: #1E1E1E;
  overflow-y: auto;
  flex: 1 1 auto;
  max-height: var(--mwai-maxHeight);
  min-height: 0;
  padding: 12px 0 4px;
  scrollbar-width: thin;
  scrollbar-color: #444444 #1E1E1E;
  cursor: text; /* hint that clicking here will let you type */
}
.mwai-powershell-theme .mwai-conversation::-webkit-scrollbar {
  width: 6px;
}
.mwai-powershell-theme .mwai-conversation::-webkit-scrollbar-track {
  background: #1E1E1E;
}
.mwai-powershell-theme .mwai-conversation::-webkit-scrollbar-thumb {
  background: #444444;
  border-radius: 3px;
}
.mwai-powershell-theme .mwai-conversation::-webkit-scrollbar-thumb:hover {
  background: #555555;
}

/* ─── Hide plugin's terminal-mode prompt (stray ">" after messages) */
.mwai-powershell-theme .mwai-terminal-prompt,
.mwai-powershell-theme .mwai-terminal-line .mwai-terminal-prompt,
.mwai-powershell-theme .mwai-conversation .mwai-terminal-line:last-child {
  display: none;
}

/* ─── Individual replies — no bubbles ──────────────────────────── */
.mwai-powershell-theme .mwai-reply {
  display: flex;
  padding: 2px 16px;
  position: relative;
  line-height: 1.55;
  background: transparent;
  border: none;
  border-radius: 0;
}

/* Hide avatar and name label */
.mwai-powershell-theme .mwai-reply .mwai-name {
  display: none;
}

/* All reply text base */
.mwai-powershell-theme .mwai-reply .mwai-text {
  flex: auto;
  font-size: 14px;
  font-family: Consolas, 'Ubuntu Mono', 'Lucida Console', 'Courier New', monospace;
  line-height: 1.55;
  color: #D2D2D2;
  background: transparent;
}

/* ─── User message: "$ " prompt in green ───────────────────────── */
.mwai-powershell-theme .mwai-reply.mwai-user {
  background: transparent;
  margin-top: 10px;
}
.mwai-powershell-theme .mwai-reply.mwai-user .mwai-text {
  color: #FF9500;
}
.mwai-powershell-theme .mwai-reply.mwai-user .mwai-text::before {
  content: '$ ';
  color: #4AF626;
  font-weight: 700;
  white-space: pre;
}

/* ─── AI / system message ───────────────────────────────────────── */
.mwai-powershell-theme .mwai-reply.mwai-ai,
.mwai-powershell-theme .mwai-reply.mwai-system {
  background: transparent;
  padding-left: 20px;
}

/* Force white on every element inside the conversation except user messages.
   This catches compliance text, paragraphs, spans, and any other elements
   the plugin injects regardless of where they sit in the DOM tree. */
.mwai-powershell-theme .mwai-conversation * {
  color: #D2D2D2 !important;
  -webkit-text-fill-color: #D2D2D2 !important;
  opacity: 1 !important;
}

/* User messages override: orange text, green prompt */
.mwai-powershell-theme .mwai-conversation .mwai-reply.mwai-user .mwai-text,
.mwai-powershell-theme .mwai-conversation .mwai-reply.mwai-user .mwai-text * {
  color: #FF9500 !important;
  -webkit-text-fill-color: #FF9500 !important;
}
.mwai-powershell-theme .mwai-conversation .mwai-reply.mwai-user .mwai-text::before {
  color: #4AF626 !important;
}

/* Terminal mode uses dedicated line/text classes for submitted user prompts. */
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user,
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user *,
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user .mwai-terminal-text,
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user .mwai-terminal-text *,
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user .mwai-terminal-typed,
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user .mwai-terminal-typed * {
  color: #FF9500 !important;
  -webkit-text-fill-color: #FF9500 !important;
}
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user {
  margin-top: 10px;
}
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user .mwai-terminal-prompt,
.mwai-powershell-theme .mwai-conversation.mwai-terminal .mwai-terminal-line.mwai-terminal-user .mwai-terminal-prompt * {
  color: #4AF626 !important;
  -webkit-text-fill-color: #4AF626 !important;
}

/* Error state */
.mwai-powershell-theme .mwai-reply.mwai-error {
  background: transparent;
}
.mwai-powershell-theme .mwai-reply.mwai-error .mwai-text {
  color: #FF8888;
}

/* ─── Links & code ──────────────────────────────────────────────── */
.mwai-powershell-theme .mwai-reply .mwai-text a {
  color: #40E0D0 !important;
  -webkit-text-fill-color: #40E0D0 !important;
  text-decoration: underline;
}
.mwai-powershell-theme .mwai-reply .mwai-text a:hover {
  color: #66EADF !important;
  -webkit-text-fill-color: #66EADF !important;
}
.mwai-powershell-theme .mwai-reply .mwai-text code {
  background: #0D0D0D;
  border: 1px solid #333333;
  color: #F8F8F2;
  font-family: Consolas, 'Ubuntu Mono', 'Lucida Console', 'Courier New', monospace;
  padding: 1px 4px;
  border-radius: 3px;
}
.mwai-powershell-theme .mwai-reply .mwai-text pre {
  background: #0D0D0D;
  border: 1px solid #333333;
  color: #CCCCCC;
  font-family: Consolas, 'Ubuntu Mono', 'Lucida Console', 'Courier New', monospace;
  padding: 10px 14px;
  overflow-x: auto;
  border-radius: 3px;
  margin: 6px 0;
}
.mwai-powershell-theme .mwai-reply .mwai-text pre code {
  background: transparent;
  border: none;
  padding: 0;
}

/* ─── Input row — no border, fully seamless ─────────────────────── */
.mwai-powershell-theme .mwai-input {
  background: #1E1E1E;
  border-top: none;      /* remove the separator line */
  display: flex;
  align-items: center;
  padding: 4px 0;
  min-height: 50px;
  gap: 0;
}

/* "$ " prompt before the textarea */
.mwai-powershell-theme .mwai-input::before {
  content: '$ ';
  color: #4AF626;
  font-family: Consolas, 'Ubuntu Mono', 'Lucida Console', 'Courier New', monospace;
  font-weight: 700;
  font-size: 14px;
  white-space: pre;
  padding: 0 0 0 16px;
  flex-shrink: 0;
  line-height: 1;
  pointer-events: none;
  align-self: center;
}

.mwai-powershell-theme .mwai-input .mwai-input-text {
  background: transparent;
  border: none;
  box-shadow: none;
  flex: 1;
  padding: 0;
  min-height: 50px;
  display: flex;
  align-items: center;
}

.mwai-powershell-theme .mwai-input .mwai-input-text textarea {
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  color: #E6E6E6;
  font-family: Consolas, 'Ubuntu Mono', 'Lucida Console', 'Courier New', monospace;
  font-size: 16px; /* must be >= 16px to prevent iOS auto-zoom */
  line-height: 1.55;
  caret-color: #4AF626;
  padding: 12px 8px;
  resize: none;
  width: 100%;
  -webkit-appearance: none;
}

.mwai-powershell-theme .mwai-input .mwai-input-text textarea::placeholder {
  color: #555555;
  opacity: 1;
}

.mwai-powershell-theme .mwai-input .mwai-input-text textarea:focus {
  outline: none;
  box-shadow: none;
}

/* ─── Submit / send button ──────────────────────────────────────── */
.mwai-powershell-theme .mwai-input button.mwai-input-submit {
  background: transparent;
  border: none;
  border-radius: 0;
  color: transparent;
  font-size: 0;
  padding: 0 14px;
  min-width: 50px;
  min-height: 50px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit::after {
  content: '↵';
  font-size: 18px;
  font-weight: 400;
  color: #444444;
  pointer-events: none;
  display: block;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit:hover::after,
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-has-content:hover::after {
  color: #4AF626;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-busy::after {
  content: '…';
  color: #444444;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit svg {
  display: none;
}

/* ─── Typing / busy cursor ──────────────────────────────────────── */
.mwai-powershell-theme .mwai-reply .mwai-text .mwai-cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: #F8F8F2;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: bash-cursor-blink 1s step-start infinite;
}
@keyframes bash-cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ─── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .mwai-powershell-theme .mwai-reply {
    padding: 2px 10px;
  }
  .mwai-powershell-theme .mwai-input::before {
    padding-left: 10px;
  }
  .mwai-powershell-theme .mwai-input .mwai-input-text textarea {
    font-size: 16px;
  }
}

/* Final UI overrides for Digitale Metgesel */
.mwai-powershell-theme .mwai-input button.mwai-input-submit {
  color: transparent;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit::after {
  content: "clear" !important;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(74, 246, 38, 0.45) !important;
  line-height: 1;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit svg {
  display: none !important;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-has-content {
  color: transparent;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-has-content::after {
  content: "\2192" !important;
  font-size: 20px;
  font-weight: 700;
  color: #4AF626 !important;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-has-content:hover::after {
  color: #7CFF5E !important;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-busy {
  color: transparent;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-busy::after {
  content: "" !important;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(74, 246, 38, 0.25);
  border-top-color: #4AF626;
  border-radius: 50%;
  display: inline-block;
  animation: dm-submit-spinner 0.75s linear infinite;
  box-sizing: border-box;
}
.mwai-powershell-theme .mwai-input button.mwai-input-submit.mwai-busy .mwai-timer {
  display: none;
}

@keyframes dm-submit-spinner {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
