/* Modern Premium Web App Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-color: #0d0f14;
  --panel-bg: rgba(22, 28, 41, 0.65);
  --panel-border: rgba(255, 255, 255, 0.08);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --primary-glow: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --primary-color: #8b5cf6;
  --primary-hover: #7c3aed;
  --success-color: #10b981;
  --error-color: #ef4444;
  --accent-color: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.1) 0%, transparent 40%);
}

.container {
  width: 100%;
  max-width: 1600px;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.3fr;
  gap: 2rem;
  transition: all 0.3s ease;
}

@media (max-width: 1200px) {
  .container {
    grid-template-columns: 1fr 1.2fr;
    max-width: 1100px;
  }
}

@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
  }
}

/* Glassmorphism Panel card styling */
.card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  background: var(--primary-glow);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

p.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* Forms styling */
.form-group {
  margin-bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input, textarea {
  background: rgba(13, 15, 20, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Buttons */
.btn {
  background: var(--primary-glow);
  border: none;
  color: #fff;
  padding: 1rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 10px 20px rgba(139, 92, 246, 0.15);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 25px rgba(139, 92, 246, 0.25);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--error-color);
  color: var(--error-color);
  box-shadow: none;
  margin-top: 0.5rem;
}

.btn-secondary:hover {
  background: rgba(239, 68, 68, 0.1);
  box-shadow: 0 10px 20px rgba(239, 68, 68, 0.1);
  transform: translateY(-2px);
}

/* Call Monitor Area (Right Panel) */
.monitor-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Circle pulse animation for voice state */
.visualizer-container {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pulse-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
  transition: all 0.3s ease;
}

.pulse-circle::before, .pulse-circle::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--primary-color);
  border-radius: 50%;
  z-index: -1;
  opacity: 0.6;
}

/* Animation states based on class */
.pulse-circle.speaking::before {
  animation: pulse-ring 1.5s cubic-bezier(0.215, 0.610, 0.355, 1) infinite;
}
.pulse-circle.speaking::after {
  animation: pulse-ring 1.5s cubic-bezier(0.215, 0.610, 0.355, 1) infinite;
  animation-delay: 0.5s;
}

.pulse-circle.thinking {
  animation: pulse-grow 1s ease-in-out infinite alternate;
}

.pulse-circle svg {
  width: 36px;
  height: 36px;
  fill: #fff;
  transition: transform 0.2s ease;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes pulse-grow {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
  100% { transform: scale(1.15); box-shadow: 0 0 40px rgba(168, 85, 247, 0.6); }
}

/* Dashboard / Metrics stats */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-top: 1rem;
}

.metric-card {
  background: rgba(13, 15, 20, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.8rem;
  text-align: center;
}

.metric-card span.value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  color: var(--text-primary);
}

.metric-card span.label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Transcripts lists styles */
.transcript-box {
  flex: 1;
  min-height: 250px;
  max-height: 350px;
  background: rgba(13, 15, 20, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dialog-bubble {
  max-width: 85%;
  padding: 0.8rem 1.2rem;
  border-radius: 18px;
  line-height: 1.4;
  font-size: 0.95rem;
  position: relative;
  animation: bubble-fade 0.3s ease;
}

.dialog-bubble.user {
  align-self: flex-end;
  background: var(--primary-glow);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.dialog-bubble.agent {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

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

/* Command Downchannel Panel */
.commands-panel {
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: 16px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.commands-panel h3 {
  color: var(--accent-color);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.command-logs {
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-family: monospace;
  font-size: 0.85rem;
}

.command-item {
  background: rgba(13, 15, 20, 0.4);
  border-left: 3px solid var(--accent-color);
  padding: 0.5rem;
  border-radius: 4px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
}

.command-item span.time {
  color: var(--text-muted);
}

/* Debug Console Panel */
.debug-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-color: rgba(99, 102, 241, 0.2);
}

.debug-panel h2 {
  color: #a855f7;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.debug-logs-container {
  flex: 1;
  min-height: 400px;
  max-height: 620px;
  background: rgba(8, 10, 15, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
  scroll-behavior: smooth;
}

.debug-log-line {
  line-height: 1.4;
  word-break: break-all;
  white-space: pre-wrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  padding-bottom: 0.3rem;
  text-align: left;
}

.debug-log-line .timestamp {
  color: var(--text-muted);
  margin-right: 0.5rem;
  user-select: none;
}

.debug-log-line.info .message {
  color: #a7f3d0; /* emerald 200 */
}

.debug-log-line.warn .message {
  color: #fde047; /* yellow 300 */
}

.debug-log-line.error .message {
  color: #fca5a5; /* red 300 */
}

.debug-log-line.debug .message {
  color: #93c5fd; /* blue 300 */
}

.debug-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 1;
  text-align: center;
}

.btn-small:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Dynamic Intents Table Styles */
.intents-group {
  margin-top: 1rem;
}

.form-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.intents-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.intent-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.intent-row input {
  padding: 0.6rem;
  font-size: 0.85rem;
}

.intent-row input.intent-code {
  flex: 0.4;
  font-family: monospace;
}

.intent-row input.intent-desc {
  flex: 1;
}

.btn-remove-row {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error-color);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.btn-remove-row:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error-color);
}

.btn-add-row {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed var(--panel-border);
  color: var(--text-secondary);
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: center;
}

.btn-add-row:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--primary-color);
}

/* API Docs Panel Styles */
.api-docs-panel {
  border-color: rgba(99, 102, 241, 0.15);
  background: rgba(22, 28, 41, 0.4);
}

.api-docs-panel h2 {
  color: #6366f1;
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.8rem;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

@media (max-width: 1200px) {
  .docs-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.doc-section h3 {
  color: var(--text-primary);
  font-size: 1.05rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-section p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.8rem;
}

.doc-section pre {
  background: rgba(8, 10, 15, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.78rem;
  color: #c9d1d9;
  overflow-x: auto;
  margin-bottom: 0.8rem;
  max-height: 250px;
}

.doc-section code {
  font-family: 'Courier New', Courier, monospace;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--accent-color);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.post {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.header {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}
