/* /interface/Feature/chat/chat.css
   Chat Feature Styles, exact copy from WebApp css global css, modified to host terminal inside chat main
   Sorted alphabetically by selector for easier editing
 */

/* =========================
   Animations
   ========================= */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================
   Utilities
   ========================= */

.hidden {
  display: none !important;
}

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* =========================
   Selectors, A to Z
   ========================= */

.chat-agent-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: contain;
  border: 2px solid #f97316;
}

.chat-agent-details {
  display: flex;
  flex-direction: column;
}

.chat-agent-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chat-agent-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.chat-agent-status {
  font-size: 13px;
  color: #94a3b8;
}

.chat-feature {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-width: 0;
  min-height: 0;
  background: #0a0a0f;
  overflow: hidden;
  position: relative;
}

.chat-footer {
  flex-shrink: 0;
  background: #12121a;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #12121a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

/* Multi-agent container */
.chat-agents-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Agent card in header */
.chat-agent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  border: 2px solid transparent;
}

.chat-agent-card:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-agent-card.active {
  background: rgba(249, 115, 22, 0.15);
  border-color: #f97316;
}

/* Agent card avatar */
.chat-agent-card .chat-agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: contain;
  border: 2px solid #f97316;
}

.chat-agent-card .chat-agent-details {
  display: flex;
  flex-direction: column;
}

.chat-agent-card .chat-agent-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.chat-agent-card .chat-agent-status {
  font-size: 11px;
  color: #94a3b8;
}

/* Remove agent button */
.chat-agent-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chat-agent-card:hover .chat-agent-remove {
  opacity: 1;
}

.chat-agent-remove:hover {
  background: #dc2626;
}

/* Agent message sections */
.agent-messages {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.agent-messages.hidden {
  display: none;
}

.agent-messages-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  scroll-behavior: smooth;
}

.chat-input {
  flex: 1;
  background: #1a1a25;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px 16px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: #f97316;
}

.chat-input::placeholder {
  color: #64748b;
}

/* Chat main hosts messages and terminal side by side */
.chat-main {
  display: flex;
  flex-direction: row;
  flex: 1;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Chat columns layout - side by side message columns */
.chat-columns {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 1px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  min-width: 0;
}

/* Individual column */
.chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0a0a0f;
  min-width: 200px;
  min-height: 0;
}

.chat-column.hidden {
  display: none;
}

/* Column header */
.chat-column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #12121a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.chat-column-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: contain;
}

.chat-column-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

/* Column messages area */
.chat-column-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  scroll-behavior: smooth;
}

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

.context-divider {
  height: 1px;
  background: #2d2d3d;
  margin: 0.5rem 0;
}

.context-item {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
}

.context-item.danger {
  color: #ef4444;
}

.context-item.danger:hover {
  background: #ef444420;
}

.context-item:hover {
  background: #2d2d3d;
}

.context-menu {
  position: absolute;
  background: #1e1e2e;
  border: 1px solid #2d2d3d;
  border-radius: 8px;
  padding: 0.5rem 0;
  min-width: 180px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
}

.input-container {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  align-items: center;
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
}

.chat-input-wrapper .chat-input {
  flex: 1;
}

.chat-input-wrapper .send-btn {
  margin-left: 8px;
  flex-shrink: 0;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
  align-items: flex-start;
}

.message .avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #f97316;
  background-size: cover;
  background-position: top;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: white;
  flex-shrink: 0;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message .avatar {
  display: flex;
}

.message-content {
  background: #1a1a25;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.message-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.agent {
  justify-content: flex-end;
}

.message.agent .avatar {
  order: 1;
}

.message.agent .message-content {
  order: 0;
}

.message.system {
  align-self: center;
  max-width: 90%;
}

.message.system .avatar {
  display: none;
}

.message.system .message-content {
  background: transparent;
  border: none;
  text-align: center;
}

.message.system .message-info {
  display: none;
}

.message.system .message-text {
  color: #94a3b8;
  font-style: italic;
}

.message.user {
  justify-content: flex-start;
}

.message.user .avatar {
  order: 0;
}

.message.user .message-content {
  order: 1;
}

.message.user .message-content {
  background: #f97316;
  border-color: #f97316;
  color: white;
}

.message.user .message-text {
  color: white;
}

.message.user .sender-name {
  color: white;
}

.message.user .timestamp {
  color: rgba(255,255,255,0.7);
}

.messages-container {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.send-btn {
  padding: 12px 20px;
  background: #f97316;
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #ea580c;
}

.sender-name {
  font-weight: 600;
  font-size: 13px;
  color: #f97316;
}

/* =========================================
   TERMINAL SIDE PANEL - Clean Architecture
   ========================================= */

/* Side Panel Container */
.terminal-side-panel {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  width: 40px; /* Collapsed width */
  min-width: 40px;
  max-width: 40px;
  height: auto;
  flex: 0 0 40px; /* No grow, no shrink, 40px basis */
  transition: width 0.3s ease, max-width 0.3s ease;
  overflow: hidden;
  z-index: 100;
  background: #0a0a0f;
}

/* Side Panel Open State */
.terminal-side-panel.open {
  width: 60%;
  max-width: 60%;
  flex: 0 0 60%; /* No grow, no shrink, 60% basis */
}

/* Toggle Button - always visible */
.terminal-side-panel-toggle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 60px;
  background: #1e1e2e;
  border: none;
  border-radius: 0 8px 8px 0;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 101;
  transition: all 0.2s;
}

.terminal-side-panel-toggle:hover {
  background: #2d2d3d;
  color: #f97316;
}

.terminal-side-panel.open .terminal-side-panel-toggle svg {
  transform: rotate(180deg);
}

/* Side Panel Content - slides with panel */
.terminal-side-panel-content {
  display: none;
  flex-direction: column;
  flex: 1;
  width: 100%;
  height: auto;
  margin-left: 40px;
  background: #0a0a0f;
  border-left: 1px solid #1e1e2e;
  min-height: 0;
  overflow: hidden;
}

.terminal-side-panel.open .terminal-side-panel-content {
  display: flex;
}

/* Terminal Header with Tabs */
.terminal-header {
  flex-shrink: 0;
  flex-basis: 44px;
  height: 44px;
  background: #12121a;
  border-bottom: 1px solid #1e1e2e;
}

.terminal-tabs {
  display: flex;
  height: 100%;
  align-items: center;
}

.terminal-tab {
  padding: 0 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.terminal-tab:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.05);
}

.terminal-tab.active {
  color: #f97316;
  border-bottom-color: #f97316;
}

/* Terminal Container - holds xterm */
.terminal-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

/* Terminal Wrapper */
.terminal-wrapper {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.terminal-wrapper.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
}

/* xterm terminal styling - uses absolute positioning */
.terminal-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.terminal-wrapper.active {
  display: flex;
  flex-direction: column;
}

.terminal-wrapper .xterm {
  position: absolute !important;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

.terminal-wrapper .xterm-viewport {
  overflow-y: auto !important;
}

.terminal-wrapper .xterm-screen {
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

.terminal-wrapper .xterm-helper-textarea {
  display: none !important;
}

.timestamp {
  font-size: 11px;
  color: #64748b;
}

.typing-indicator {
  padding: 8px 16px;
}

.typing-indicator.hidden {
  display: none;
}

.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #64748b;
  border-radius: 50%;
  margin: 0 2px;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0; }

/* Typing Agent Name */
.typing-agent {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}

/* Typing Message - Avatar Pulse & Bubble */
.typing-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
}

.typing-message .avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: #f97316;
  background-size: cover;
  background-position: top;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

/* Pulse animation for avatar */
.avatar-pulse {
  animation: avatarPulse 1.5s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(249, 115, 22, 0);
  }
}

/* Typing bubble with name and "is typing" */
.typing-bubble {
  background: #1a1a25;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: bubbleScale 0.3s ease-out;
}

@keyframes bubbleScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.typing-name {
  font-weight: 600;
  color: #f97316;
  font-size: 14px;
}

.typing-text {
  color: #94a3b8;
  font-size: 14px;
}

/* Dots animation for "is typing" */
.typing-text::after {
  content: '';
  animation: typingDots 1.5s infinite;
  display: inline-block;
  width: 20px;
  text-align: left;
}

@keyframes typingDots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Hide old typing indicator (fallback) */
#typing-indicator.hidden {
  display: none;
}

/* @Mention Styling */
.message-text .mention {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 600;
}

.message-text .mention-lauren {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.message-text .mention-ada {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.message-text .mention-ivy {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.message-text .mention-isabella {
  background: rgba(236, 72, 153, 0.2);
  color: #ec4899;
}

/* Inline images in chat (ChatGPT style) */
.message-image {
  max-width: 300px;
  max-height: 300px;
  border-radius: 12px;
  margin: 8px 0;
  cursor: pointer;
  object-fit: contain;
  background: #1a1a25;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.message.user .message-image {
  margin-left: auto;
}

.message.assistant .message-image {
  margin-right: auto;
}

/* @Mention in Input Hint */
.input-hint {
  font-size: 12px;
  color: #64748b;
  padding: 4px 0;
}

.input-hint .mention {
  color: #f97316;
}

/* Drag and drop styles */
.chat-feature.drag-over,
.chat-main.drag-over {
  outline: 3px dashed #f97316 !important;
  outline-offset: -3px;
}

/* Drop zone overlay */
#drop-zone {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 10000 !important;
}

/* Upload button */
.upload-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: #1a1a25;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.upload-btn:hover {
  background: #2a2a35;
  color: #f97316;
  border-color: #f97316;
}

.upload-btn svg {
  width: 20px;
  height: 20px;
}

/* ttyd iframe styling */
.ttyd-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #1e1e1e;
  display: block;
}

.terminal-wrapper .ttyd-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Simple Terminal container sizing */
#simple-term-container-lauren,
#simple-term-container-ada,
#simple-term-container-ivy,
#simple-term-container-isabella {
  width: 100%;
  height: 100%;
  overflow: hidden;
}