/* Mission Control Design System */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Rajdhani:wght@500;600;700&display=swap');

:root {
  /* Backgrounds */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2332;
  --bg-elevated: #1e293b;

  /* Text */
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Accents */
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.3);
  --accent-green: #10b981;
  --accent-purple: #a855f7;
  --accent-orange: #f97316;
  --accent-blue: #3b82f6;

  /* Providers */
  --provider-openai: #10b981;
  --provider-anthropic: #a855f7;
  --provider-google: #f97316;
  --provider-xai: #3b82f6;

  /* Borders */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(6, 182, 212, 0.2);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px var(--accent-cyan-glow);

  /* Typography */
  --font-mono: 'IBM Plex Mono', monospace;
  --font-display: 'Rajdhani', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

body {
  font-family: var(--font-mono);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
  position: relative;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.01) 0px,
    transparent 1px,
    transparent 2px,
    rgba(255, 255, 255, 0.01) 3px
  );
  pointer-events: none;
  z-index: 999;
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  animation: fadeInUp 0.6s ease-out;
}

/* Header */
header {
  margin-bottom: 24px;
  animation: fadeInUp 0.6s ease-out;
}

h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-family: var(--font-display);
  font-size: 0.875rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

/* Config Sections */
.config-section {
  margin: 20px 0;
  animation: fadeInUp 0.5s ease-out 0.1s both;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.config-section:nth-of-type(2) {
  animation-delay: 0.15s;
}

.config-toggle {
  width: 100%;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 20px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-primary);
  transition: all 0.3s ease;
  position: relative;
  padding-right: 50px;
  cursor: pointer;
}

.config-toggle::after {
  content: '▼';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%) rotate(var(--arrow-rotation, 0deg));
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.config-toggle:hover {
  background: rgba(255, 255, 255, 0.03);
}

.config-toggle:hover::after {
  color: var(--accent-cyan);
}

.config-section:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.config-panel {
  padding: 0 20px 20px 20px;
  animation: fadeInUp 0.3s ease-out;
  border-top: 1px solid var(--border-color);
}

.config-panel.is-hidden {
  display: none;
}

.control-panel,
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  margin: 16px 0;
}

.control-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* Labels and Inputs */
label {
  font-family: var(--font-display);
  font-size: 0.813rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

input[type="text"],
input[type="number"],
select,
textarea {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px 14px;
  color: var(--text-primary);
  transition: all 0.2s ease;
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Buttons */
button {
  font-family: var(--font-display);
  font-size: 0.813rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px 20px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

button:hover::before {
  left: 100%;
}

button:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-tertiary);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

button:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
  border: none;
  color: var(--bg-primary);
  font-weight: 700;
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

/* Model Rows */
.models-list {
  margin: 20px 0;
}

.model-row {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
  transition: all 0.3s ease;
  animation: fadeInUp 0.4s ease-out;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.model-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--provider-openai);
  border-radius: 6px 0 0 6px;
  transition: all 0.3s ease;
}

.model-row[data-provider="anthropic"]::before {
  background: var(--provider-anthropic);
  box-shadow: 0 0 10px var(--provider-anthropic);
}

.model-row[data-provider="google"]::before {
  background: var(--provider-google);
  box-shadow: 0 0 10px var(--provider-google);
}

.model-row[data-provider="xai"]::before {
  background: var(--provider-xai);
  box-shadow: 0 0 10px var(--provider-xai);
}

.model-row[data-provider="openai"]::before {
  background: var(--provider-openai);
  box-shadow: 0 0 10px var(--provider-openai);
}

.model-row:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-md);
}

.model-row select,
.model-row input[type="text"] {
  min-width: 120px;
}

.model-row .modelSelect {
  min-width: 280px;
}

.model-row .agentName {
  width: 180px;
}

.model-row .hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Chat Log */
.chat-log {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 24px;
  min-height: 50vh;
  max-height: 70vh;
  overflow-y: auto;
  margin: 20px 0;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
  animation: fadeInUp 0.5s ease-out 0.2s both;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-log:empty::before {
  content: 'Start a conversation by entering a message below...';
  color: var(--text-muted);
  font-style: italic;
  display: block;
  text-align: center;
  padding: 60px 20px;
}

.chat-log::-webkit-scrollbar {
  width: 8px;
}

.chat-log::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.chat-log::-webkit-scrollbar-thumb {
  background: var(--accent-cyan);
  border-radius: 4px;
}

.chat-log::-webkit-scrollbar-thumb:hover {
  background: var(--accent-green);
}

/* Messages */
.msg {
  animation: fadeIn 0.3s ease-out;
  max-width: 85%;
}

.msg.loading {
  align-self: flex-start;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.7;
}

.loading-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.msg.user {
  align-self: flex-end;
  margin-left: auto;
  padding: 14px 18px;
  border-radius: 12px 12px 0 12px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(6, 182, 212, 0.3);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.1);
}

.msg.agent {
  align-self: flex-start;
  padding: 14px 18px;
  border-radius: 12px 12px 12px 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.msg.agent:hover {
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
}

.msg.error {
  padding: 14px 18px;
  border-radius: 6px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid #ef4444;
}

.msg-header {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.msg.user .msg-header {
  color: var(--accent-cyan);
}

.msg.agent .msg-header {
  color: var(--accent-green);
}

.msg.error .msg-header {
  color: #ef4444;
}

.msg-content {
  font-family: var(--font-mono);
  white-space: pre-wrap;
  font-size: 0.875rem;
  line-height: 1.6;
}

.tokens {
  font-family: var(--font-display);
  font-size: 0.688rem;
  color: var(--text-muted);
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Input Area */
.input-wrapper {
  margin: 20px 0;
  animation: fadeInUp 0.5s ease-out 0.25s both;
}

.input-area {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-md);
}

.input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.input-row input[type="text"] {
  flex: 1;
}

#attachBtn {
  font-size: 1.5rem;
  font-weight: 400;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

#attachBtn:hover {
  background: var(--accent-cyan);
  color: var(--bg-primary);
  border-color: var(--accent-cyan);
  transform: rotate(45deg);
}

.btn-primary {
  padding: 12px 32px;
  font-size: 0.875rem;
}

/* Attachments */
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.attachments:empty {
  display: none;
}

.attachment-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.813rem;
  animation: fadeInUp 0.2s ease-out;
}

.attachment-chip-name {
  color: var(--text-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  margin: 0;
  font-size: 1.2rem;
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.attachment-remove:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Utilities */
.is-hidden {
  display: none;
}

.small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Options Panel */
.opts {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  animation: fadeInUp 0.2s ease-out;
}

.optsBody .control-group {
  margin-bottom: 8px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-cyan);
}

select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

#convId {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent-green);
}

#previewOut {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.813rem;
  white-space: pre-wrap;
  max-height: 300px;
  overflow: auto;
  margin-top: 12px;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  color: var(--accent-green);
  text-decoration: underline;
}

/* Public Mode Banner */
.public-banner {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.15), rgba(251, 146, 60, 0.15));
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 0.813rem;
  color: var(--text-primary);
  line-height: 1.5;
  animation: fadeInUp 0.5s ease-out;
}

.public-models-note {
  padding: 8px 18px 0;
  margin-bottom: 16px;
  font-size: 0.75rem;
  color: var(--text-secondary, #9aa);
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
  h1 {
    font-size: 1.75rem;
  }

  .container {
    padding: 16px;
  }

  .model-row {
    flex-direction: column;
    align-items: stretch;
  }

  .model-row input,
  .model-row select,
  .model-row button {
    width: 100%;
  }

  .msg.user,
  .msg.agent {
    max-width: 95%;
  }
}
