/* ==========================================================================
   UnrealAgent Interactive Demo Styles - Phase A Enhancement
   ========================================================================== */

/* --- Base Layout Structure --- */
.ua-app-split {
  display: flex;
  height: 100%;
  overflow: hidden;
  height: 580px;
}

.ua-app-sidebar {
  width: 300px;
  min-width: 280px;
  background: rgba(0, 0, 0, 0.25);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
}

/* --- Chat Header with Status --- */
.ua-chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
}

.ua-chat-title {
  font-weight: 700;
  font-size: 14px;
  color: #f1f5f9;
  letter-spacing: 0.2px;
}

.ua-chat-status {
  font-size: 10px;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.ua-chat-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
  animation: statusPulse 2s infinite;
}

@keyframes statusPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* --- Chat History with Enhanced Scrolling --- */
.ua-chat-history {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  /* Thin elegant scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.ua-chat-history::-webkit-scrollbar {
  width: 5px;
}

.ua-chat-history::-webkit-scrollbar-track {
  background: transparent;
}

.ua-chat-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}

.ua-chat-history::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Message Bubbles Enhanced --- */
.ua-msg {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.7;
  max-width: 92%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  animation: msgSlideIn 0.25s ease-out;
}

@keyframes msgSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ua-msg.user {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.18);
  color: #e0e7ff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ua-msg.ai {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(226, 232, 240, 0.95);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* Thinking/Processing State */
.ua-msg.thinking {
  opacity: 0.8;
  background: rgba(34, 211, 238, 0.06);
  border: 1px dashed rgba(34, 211, 238, 0.25);
  color: rgba(165, 243, 252, 0.9);
  display: flex;
  align-items: center;
  gap: 10px;
}

.ua-msg.thinking i {
  color: #22d3ee;
}

/* Code/Command Styling */
.ua-msg b,
.ua-msg strong {
  color: #67e8f9;
  font-weight: 600;
}

.ua-msg code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a5f3fc;
}

/* --- Action Card Style (Phase B preview) --- */
.ua-action-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(34, 211, 238, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  transition: all 0.2s;
}

.ua-action-card:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(34, 211, 238, 0.08));
  border-color: rgba(99, 102, 241, 0.3);
}

.ua-action-card .ua-action-icon {
  width: 34px;
  height: 34px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  font-size: 14px;
  flex-shrink: 0;
}

.ua-action-card .ua-action-text {
  flex: 1;
  font-size: 12px;
  color: #e2e8f0;
  font-weight: 500;
}

.ua-action-card .ua-action-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-radius: 6px;
}

.ua-action-card .ua-action-status.completed {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.ua-action-card .ua-action-status.running {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  animation: statusPulse 1s infinite;
}

.ua-action-card .ua-action-status.queued {
  color: #64748b;
  background: rgba(100, 116, 139, 0.1);
}

/* --- Task Menu Styles --- */
.ua-task-menu {
  padding: 12px 16px 14px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ua-menu-header {
  font-size: 10px;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.ua-preset-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ua-preset-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.ua-preset-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.06);
}

.ua-preset-btn.active {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

.ua-preset-btn i {
  color: #64748b;
  width: 18px;
  text-align: center;
  font-size: 13px;
  transition: color 0.2s;
}

.ua-preset-btn.active i {
  color: #38bdf8;
}

/* Progress bar inside button */
.ua-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
  width: 0%;
  transition: width 0.1s linear;
  opacity: 0;
}

.ua-preset-btn.active .ua-progress-bar {
  opacity: 1;
}

/* --- Typewriter Input Styles --- */
.ua-chat-input-fake {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.15);
  min-height: 52px;
}

.ua-input-text {
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  flex: 1;
}

.ua-cursor {
  display: inline-block;
  width: 2px;
  height: 16px;
  background: #38bdf8;
  border-radius: 1px;
  animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* --- Main View Area --- */
.ua-app-main {
  flex: 1;
  position: relative;
  background: #1a1a1a;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ua-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.ua-view.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

.ua-empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  gap: 12px;
}

.ua-empty-state p {
  font-size: 13px;
  opacity: 0.8;
}

/* --- Editor Toolbar --- */
.ua-editor-toolbar {
  height: 38px;
  background: linear-gradient(to bottom, #2d2d2d, #252525);
  border-bottom: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  font-size: 12px;
  color: #999;
  flex-shrink: 0;
}

.ua-compile-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}

.ua-compile-badge.is-ok {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.ua-toolbar-chip {
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  color: #aaa;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ua-toolbar-spacer {
  flex: 1;
}

.ua-search-bar-mock {
  background: rgba(0, 0, 0, 0.4);
  padding: 5px 12px;
  border-radius: 12px;
  color: #888;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ua-search-bar-mock i {
  font-size: 10px;
  opacity: 0.6;
}

/* --- Blueprint Canvas Mock --- */
.ua-blueprint-canvas {
  flex: 1;
  position: relative;
  background: #1a1a1a;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: hidden;
}

.ua-wire-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ua-bp-wire {
  fill: none;
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 2;
}

.ua-bp-node {
  position: absolute;
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  min-width: 140px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  border-top: 3px solid var(--brand-primary, #6366f1);
}

.ua-bp-header {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 11px;
  font-weight: 600;
  color: #e5e7eb;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.ua-bp-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ua-bp-pin {
  font-size: 10px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ua-bp-pin.input::before {
  content: '';
  width: 7px;
  height: 7px;
  border: 1.5px solid #d1d5db;
  border-radius: 50%;
}

.ua-bp-pin.output {
  justify-content: flex-end;
}

.ua-bp-pin.output::after {
  content: '';
  width: 7px;
  height: 7px;
  border: 1.5px solid #d1d5db;
  border-radius: 50%;
}

/* --- File Grid --- */
.ua-file-grid {
  flex: 1;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  align-content: start;
  overflow-y: auto;
}

.ua-file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border-radius: 8px;
  transition: all 0.2s;
  cursor: pointer;
}

.ua-file-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ua-file-icon {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.ua-file-icon.bp {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

.ua-file-icon.mat {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.ua-file-icon.sk {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: white;
}

.ua-file-icon.tex {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.ua-file-name {
  font-size: 10px;
  color: #b0b0b0;
  text-align: center;
  word-break: break-word;
  line-height: 1.4;
  max-width: 90px;
}

/* --- Viewport Canvas --- */
.ua-viewport-canvas {
  flex: 1;
  position: relative;
  background: #1e1e1e;
  overflow: hidden;
}

/* --- Enemy Marker Animation --- */
.ua-enemy-marker {
  position: absolute;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid white;
  transform: translate(-50%, -50%) scale(0);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

.ua-view.active .ua-enemy-marker {
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.ua-view.active .ua-enemy-marker:nth-child(2) {
  animation-delay: 0.08s;
}

.ua-view.active .ua-enemy-marker:nth-child(3) {
  animation-delay: 0.16s;
}

.ua-view.active .ua-enemy-marker:nth-child(4) {
  animation-delay: 0.12s;
}

.ua-view.active .ua-enemy-marker:nth-child(5) {
  animation-delay: 0.24s;
}

.ua-view.active .ua-enemy-marker:nth-child(6) {
  animation-delay: 0.20s;
}

.ua-view.active .ua-enemy-marker:nth-child(7) {
  animation-delay: 0.32s;
}

.ua-view.active .ua-enemy-marker:nth-child(8) {
  animation-delay: 0.28s;
}

.ua-view.active .ua-enemy-marker:nth-child(9) {
  animation-delay: 0.40s;
}

.ua-view.active .ua-enemy-marker:nth-child(10) {
  animation-delay: 0.36s;
}

.ua-view.active .ua-enemy-marker:nth-child(11) {
  animation-delay: 0.44s;
}

@keyframes popIn {
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* --- Browser Tabs (Editor Chrome) --- */
.ua-browser-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.ua-browser-tab {
  padding: 6px 14px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.ua-browser-tab:hover {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.03);
}

.ua-browser-tab.active {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.05);
}

.ua-browser-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: #38bdf8;
  border-radius: 2px 2px 0 0;
}

/* --- Window Action Buttons --- */
.ua-window-actions {
  display: flex;
  gap: 6px;
}

.ua-win-action {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 11px;
}

.ua-win-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

/* --- Status Bar --- */
.ua-status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 10px;
  color: #64748b;
}

.ua-status-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ua-status-item i {
  font-size: 9px;
}

.ua-status-item.connected i {
  color: #10b981;
}

.ua-status-spacer {
  flex: 1;
}

/* --- Responsive Design --- */
@media (max-width: 1100px) {
  .ua-app-split {
    min-height: 480px;
  }

  .ua-app-sidebar {
    width: 260px;
    min-width: 240px;
  }
}

@media (max-width: 900px) {
  .ua-app-split {
    flex-direction: column;
    min-height: auto;
  }

  .ua-app-sidebar {
    width: 100%;
    min-width: auto;
    max-height: 380px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .ua-app-main {
    min-height: 280px;
  }

  .ua-browser-tabs {
    display: none;
  }

  .ua-blueprint-canvas {
    min-height: 300px;
  }
}

@media (max-width: 600px) {
  .ua-chat-history {
    padding: 14px 12px;
    gap: 10px;
  }

  .ua-msg {
    padding: 10px 12px;
    font-size: 12px;
    max-width: 95%;
  }

  .ua-preset-btn {
    padding: 8px 10px;
  }

  .ua-task-menu {
    padding: 10px 12px;
  }
}

/* --- Reduced Motion Support --- */
@media (prefers-reduced-motion: reduce) {

  .ua-msg,
  .ua-enemy-marker,
  .ua-preset-btn,
  .ua-action-card {
    animation: none;
    transition: none;
  }

  .ua-chat-status::before,
  .ua-cursor {
    animation: none;
  }

  .ua-enemy-marker {
    transform: translate(-50%, -50%) scale(1);
  }
}