/* Model Playground - Tool Styles */

.playground-tool {
  max-width: 820px;
  margin: 0 auto;
  padding: 0.5rem 0 2rem;
}

.playground-tool h1 {
  font-size: 1.75rem;
  margin-top: 0;
  color: #111827;
}

.playground-tool .subtitle {
  color: #6b7280;
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

/* Top bar */
.playground-tool .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.playground-tool .toolbar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.playground-tool .toolbar select {
  padding: 0.45rem 0.65rem;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #111827;
  cursor: pointer;
}

.playground-tool .toolbar select:focus {
  outline: none;
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.25);
}

.playground-tool .toolbar .spacer {
  flex: 1;
}

/* Model status badge */
.playground-tool .model-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.playground-tool .model-badge.idle {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

.playground-tool .model-badge.loading {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.playground-tool .model-badge.ready {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #86efac;
}

.playground-tool .model-badge.generating {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.playground-tool .model-badge.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.playground-tool .model-badge .spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  opacity: 0.5;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Buttons */
.playground-tool .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.playground-tool .btn:active {
  transform: scale(0.98);
}

.playground-tool .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.playground-tool .btn-primary {
  background: #15803d;
  color: #fff;
}

.playground-tool .btn-primary:hover:not(:disabled) {
  background: #166534;
}

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

.playground-tool .btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.playground-tool .btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1.5px solid #d1d5db;
}

.playground-tool .btn-secondary:hover:not(:disabled) {
  background: #e5e7eb;
}

.playground-tool .btn-small {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

/* Chat area */
.playground-tool .chat-container {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: #fff;
}

.playground-tool .chat-messages {
  min-height: 300px;
  max-height: 480px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.playground-tool .chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 1rem;
  min-height: 240px;
}

.playground-tool .chat-empty .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.playground-tool .message {
  max-width: 88%;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.9rem;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.playground-tool .message.user {
  align-self: flex-end;
  background: #15803d;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.playground-tool .message.assistant {
  align-self: flex-start;
  background: #1e1e2e;
  color: #cdd6f4;
  border-bottom-left-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
}

.playground-tool .message.assistant .cursor-blink {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: #89b4fa;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 1px;
}

@keyframes blink {
  50% { opacity: 0; }
}

.playground-tool .message .msg-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.6;
  margin-bottom: 0.3rem;
  display: block;
}

/* Chat input area */
.playground-tool .chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.playground-tool .chat-input-area textarea {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  font-family: inherit;
  background: #fff;
  color: #111827;
  box-sizing: border-box;
}

.playground-tool .chat-input-area textarea:focus {
  outline: none;
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.25);
}

.playground-tool .chat-input-area .btn-send {
  align-self: flex-end;
  padding: 0.55rem 1rem;
}

/* Stats panel */
.playground-tool .stats-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.playground-tool .stat-card {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.playground-tool .stat-card .stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 0.2rem;
}

.playground-tool .stat-card .stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
}

.playground-tool .stat-card .stat-value.highlight {
  color: #15803d;
}

.playground-tool .stat-card .stat-value.muted {
  color: #6b7280;
  font-size: 0.9rem;
  font-weight: 400;
}

/* Load model section */
.playground-tool .load-section {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.playground-tool .model-info {
  font-size: 0.75rem;
  color: #9ca3af;
  white-space: nowrap;
}

/* Status banner */
.playground-tool .status-banner {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
  display: none;
}

.playground-tool .status-banner.visible {
  display: flex;
}

.playground-tool .status-banner.info {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.playground-tool .status-banner.success {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.playground-tool .status-banner.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

/* Per-response stats */
.playground-tool .response-stats {
  display: flex;
  gap: 1rem;
  padding: 0.4rem 0.75rem;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 6px;
  align-self: flex-start;
  max-width: 88%;
}

.playground-tool .response-stats span {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Scrollbar styling for chat */
.playground-tool .chat-messages::-webkit-scrollbar {
  width: 6px;
}

.playground-tool .chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.playground-tool .chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

/* Responsive */
/* Benchmark button */
.playground-tool .btn-benchmark {
  background: #7c3aed;
  color: #fff;
}
.playground-tool .btn-benchmark:hover:not(:disabled) {
  background: #6d28d9;
}
.playground-tool .btn-benchmark:disabled {
  background: #a78bfa;
}

/* Benchmark progress area */
.playground-tool .benchmark-progress {
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  background: #f5f3ff;
}
.playground-tool .benchmark-header {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.75rem;
}
.playground-tool .benchmark-progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.playground-tool .benchmark-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.playground-tool .benchmark-status {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}
.playground-tool .benchmark-current {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 0.25rem;
}

/* Benchmark results area */
.playground-tool .benchmark-results {
  padding: 1.25rem;
  border: 2px solid #86efac;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  background: #f0fdf4;
}
.playground-tool .benchmark-summary {
  font-size: 0.85rem;
  color: #374151;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}
.playground-tool .benchmark-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
}
.playground-tool .benchmark-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}
.playground-tool .benchmark-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
.playground-tool .benchmark-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #f3f4f6;
  font-variant-numeric: tabular-nums;
}
.playground-tool .benchmark-table tr:last-child td {
  border-bottom: none;
}
.playground-tool .benchmark-table .bench-pass {
  color: #15803d;
  font-weight: 600;
}
.playground-tool .benchmark-table .bench-fail {
  color: #dc2626;
  font-weight: 600;
}
.playground-tool .benchmark-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .playground-tool .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .playground-tool .toolbar .spacer {
    display: none;
  }

  .playground-tool .load-section {
    flex-wrap: wrap;
  }

  .playground-tool .stats-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .playground-tool .chat-messages {
    max-height: 360px;
    min-height: 240px;
  }

  .playground-tool .message {
    max-width: 95%;
  }
}
