/* Consenger Admin UI Styles */

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  background: #f5f5f5;
}

h1 {
  color: #333;
  margin-bottom: 10px;
}

.subtitle {
  color: #666;
  margin-bottom: 30px;
}

/* Configuration Section */
.config-section {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.config-section h3 {
  margin-top: 0;
  color: #444;
}

.config-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.config-row label {
  width: 120px;
  font-weight: 500;
  padding-top: 8px;
}

.config-row input,
.config-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 16px;
  background: #e0e0e0;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab:hover {
  background: #d0d0d0;
}

.tab.active {
  background: #fff;
  font-weight: 600;
}

.tab.requires-turnstile {
  border-left: 3px solid #f59e0b;
}

.tab.requires-auth {
  border-left: 3px solid #10b981;
}

/* Form Section */
.form-section {
  background: #fff;
  padding: 20px;
  border-radius: 0 8px 8px 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-section h2 {
  margin-top: 0;
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Badges */
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.badge.turnstile {
  background: #fef3c7;
  color: #92400e;
}

.badge.bot-check {
  background: #dbeafe;
  color: #1e40af;
}

.badge.auth {
  background: #d1fae5;
  color: #065f46;
}

.badge.rate {
  background: #f3e8ff;
  color: #6b21a8;
}

/* Form Groups */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #444;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.form-group textarea {
  min-height: 80px;
  font-family: monospace;
  resize: vertical;
}

.form-group small {
  color: #888;
  font-size: 12px;
}

/* Turnstile */
.turnstile-container {
  margin: 15px 0;
  min-height: 65px;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e2e8f0;
  color: #475569;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* Response Section */
.response-section {
  margin-top: 20px;
  padding: 15px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.response-section h4 {
  margin: 0 0 10px 0;
  color: #475569;
}

.response-section pre {
  margin: 0;
  padding: 12px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.response-section .status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

.status.success {
  background: #d1fae5;
  color: #065f46;
}

.status.error {
  background: #fee2e2;
  color: #991b1b;
}

.status.info {
  background: #dbeafe;
  color: #1e40af;
}

/* Token Display */
.token-display {
  background: #fff;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 1px solid #e2e8f0;
}

.token-display h4 {
  margin: 0 0 10px 0;
  color: #475569;
}

.token-display .token {
  font-family: monospace;
  font-size: 11px;
  word-break: break-all;
  background: #f1f5f9;
  padding: 8px;
  border-radius: 4px;
  max-height: 60px;
  overflow: auto;
}

.token-display .token.empty {
  color: #94a3b8;
  font-style: italic;
}

/* Legend */
.legend {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #666;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-color.turnstile {
  background: #f59e0b;
}

.legend-color.auth {
  background: #10b981;
}

/* Controls */
.controls {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 15px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 15px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group label {
  font-weight: 500;
  white-space: nowrap;
}

.control-group input,
.control-group select,
.control-group textarea {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

/* Test Section */
.test-section {
  background: #fff;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.description {
  color: #666;
  margin-bottom: 20px;
}

/* Chat Container (Streaming Chat) */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.messages {
  min-height: 400px;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
  background: #fafbfc;
}

.message {
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 8px;
  max-width: 80%;
}

.message-user {
  background: #dbeafe;
  margin-left: auto;
}

.message-assistant {
  background: #f1f5f9;
}

.message-header {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: #64748b;
}

.message-content {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Prompt Container */
.prompt-container,
.tts-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Audio Player */
.audio-player {
  margin-top: 15px;
  padding: 15px;
  background: white;
  border-radius: 6px;
}

.audio-player audio {
  width: 100%;
}

/* Response Containers */
.response-container {
  margin-top: 20px;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.response-success {
  background: #f0fdf4;
  border-color: #10b981;
}

.response-error {
  background: #fef2f2;
  border-color: #ef4444;
}

.response-content {
  padding: 15px;
  background: white;
  border-radius: 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: 15px;
  line-height: 1.6;
}

.response-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #64748b;
}

.meta-item {
  display: flex;
  gap: 5px;
}

.error-message {
  color: #ef4444;
  font-weight: 500;
  padding: 10px;
  background: white;
  border-radius: 6px;
}

.error-note {
  margin-top: 10px;
  padding: 10px;
  background: #fef3c7;
  border-radius: 6px;
  font-size: 13px;
  color: #92400e;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #64748b;
  font-style: italic;
}

.error {
  color: #ef4444;
  font-weight: 500;
}


.token-info p {
  margin: 5px 0;
  font-size: 14px;
}

.token-info .note {
  color: var(--text-secondary);
}

#token-status {
  font-family: monospace;
  font-weight: 600;
}

/* Tabs */
.tabs {
  max-width: 1200px;
  margin: 0 auto 20px;
  display: flex;
  gap: 5px;
}

.tab {
  padding: 12px 20px;
  background: #e2e8f0;
  border: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.tab:hover {
  background: #cbd5e1;
}

.tab.active {
  background: var(--card-bg);
  font-weight: 600;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

/* Main Content */
main {
  max-width: 1200px;
  margin: 0 auto;
}

.test-section {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 0 8px 8px 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.description {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Chat Container (Streaming Chat) */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.messages {
  min-height: 400px;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  background: #fafbfc;
}

.message {
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 8px;
  max-width: 80%;
}

.message-user {
  background: #dbeafe;
  align-self: flex-end;
  margin-left: auto;
}

.message-assistant {
  background: #f1f5f9;
  align-self: flex-start;
}

.message-header {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-secondary);
}

.message-content {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.input-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Prompt Container (Single Prompt) */
.prompt-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.prompt-container label {
  font-weight: 500;
  margin-bottom: 5px;
}

.prompt-container textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

/* TTS Container */
.tts-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.tts-container label {
  font-weight: 500;
  margin-bottom: 5px;
}

.tts-container textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

/* Controls */
.controls {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 15px;
  background: #f8fafc;
  border-radius: 8px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group label {
  font-weight: 500;
  white-space: nowrap;
}

.control-group input,
.control-group select,
.control-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
}

.control-group textarea {
  min-width: 300px;
  font-family: inherit;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #2563eb;
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-color);
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-group {
  display: flex;
  gap: 10px;
}

/* Response Containers */
.response-container {
  margin-top: 20px;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.response-success {
  background: #f0fdf4;
  border-color: var(--success-color);
}

.response-error {
  background: #fef2f2;
  border-color: var(--error-color);
}

.response-content {
  padding: 15px;
  background: white;
  border-radius: 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: 15px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
}

.response-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
}

.meta-item {
  display: flex;
  gap: 5px;
}

.error-message {
  color: var(--error-color);
  font-weight: 500;
  padding: 10px;
  background: white;
  border-radius: 6px;
}

.error-note {
  margin-top: 10px;
  padding: 10px;
  background: #fef3c7;
  border-radius: 6px;
  font-size: 13px;
  color: #92400e;
}

.loading {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-style: italic;
}

.error {
  color: var(--error-color);
  font-weight: 500;
}

/* Audio Player */
.audio-player {
  margin-top: 15px;
  padding: 15px;
  background: white;
  border-radius: 6px;
}

.audio-player audio {
  width: 100%;
}

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

  .control-group {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group input,
  .control-group select,
  .control-group textarea {
    width: 100%;
  }

  .response-meta {
    flex-direction: column;
    gap: 10px;
  }

  .message {
    max-width: 90%;
  }
}
