/* ─── Onto WebRTC — Styles ─── */

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

:root {
  --bg: #0f1117;
  --surface: #1a1c25;
  --surface2: #242733;
  --border: #2d3040;
  --text: #e1e4ed;
  --text-muted: #8b8fa3;
  --primary: #6c5ce7;
  --primary-hover: #7c6ff0;
  --danger: #e74c3c;
  --success: #27ae60;
  --radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Header */
header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-size: 0.95rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

/* Fields */
.field-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.field-row label {
  min-width: 130px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field-row input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.field-row input:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary:hover:not(:disabled) {
  background: var(--border);
}

.danger {
  background: var(--danger);
  color: #fff;
}

.danger:hover:not(:disabled) {
  opacity: 0.9;
}

/* Status text */
.status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-family: var(--mono);
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

/* Toggle switches */
.toggle-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.slider {
  width: 40px;
  height: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 11px;
  position: relative;
  transition: all 0.2s;
}

.slider::after {
  content: '';
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.2s;
}

.toggle input:checked + .slider {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle input:checked + .slider::after {
  background: #fff;
  transform: translateX(18px);
}

.label-text {
  font-size: 0.9rem;
}

/* Video grid */
#video-section {
  margin: 1rem 0;
}

#video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

.video-container {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-container.local video {
  transform: scaleX(-1); /* mirror local video */
}

.video-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* Peer list */
#peerList {
  list-style: none;
}

#peerList li {
  padding: 0.4rem 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#peerList li::before {
  content: '●';
  color: var(--success);
  font-size: 0.6rem;
}

/* Help text */
.help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

/* Text display areas */
.text-display {
  margin-top: 0.75rem;
}

.text-display label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.text-content {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0.3rem 0 0.7rem 0;
  min-height: 1.5rem;
  word-wrap: break-word;
}

/* ─── Call Indicator / VAD ────────────── */

.call-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  min-height: 1.8rem;
}

.vad-dot {
  font-size: 1.3rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  transition: all 0.2s;
}

.vad-dot.idle {
  border-color: var(--text-muted);
}

.vad-dot.speaking {
  border-color: var(--success);
  background: rgba(39, 174, 96, 0.15);
  animation: pulse 0.8s ease-in-out infinite;
}

.vad-dot.thinking {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.15);
  animation: spin 1.2s linear infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Large button for call toggle */
.btn-large {
  padding: 0.8rem 2rem;
  font-size: 1.1rem;
  border-radius: 12px;
  min-width: 180px;
}

/* Call-active state (green pulsing when active) */
button.call-active {
  background: #27ae60;
  color: #fff;
  box-shadow: 0 0 12px rgba(39, 174, 96, 0.4);
  animation: callPulse 2s ease-in-out infinite;
}

button.call-active:hover {
  background: #2ecc71;
}

@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(39, 174, 96, 0.3); }
  50% { box-shadow: 0 0 20px rgba(39, 174, 96, 0.6); }
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  .field-row {
    flex-direction: column;
    align-items: stretch;
  }

  .field-row label {
    min-width: auto;
  }

  .btn-row {
    flex-wrap: wrap;
  }

  #video-grid {
    grid-template-columns: 1fr;
  }
}
