/* Playground styles */

.playground-section {
  padding: 2rem 0 4rem;
}

.playground-section .container {
  max-width: 1600px;
  width: min(100% - 2rem, 1600px);
}

.playground-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

.playground-editor,
.playground-output {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.playground-editor-header,
.playground-output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}

.playground-editor-title,
.playground-output-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.playground-editor-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

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

#code-input {
  flex: 1;
  width: 100%;
  min-height: 560px;
  padding: 1.25rem;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  tab-size: 2;
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  z-index: 2;
}

#code-input::selection {
  background: rgba(59, 130, 246, 0.3);
  color: #e2e8f0;
}

#code-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Syntax highlight overlay */
.playground-editor-wrap {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
}

#code-highlight {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  tab-size: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  pointer-events: none;
  z-index: 1;
  color: #e2e8f0;
}

#code-highlight code {
  font-family: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.playground-output-area {
  flex: 1;
  min-height: 560px;
  max-height: 800px;
  overflow: auto;
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

.playground-output-area code {
  font-family: inherit;
}

.playground-status {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  display: none;
}

.playground-status.running {
  display: inline;
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent);
}

.playground-status.ok {
  display: inline;
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-2);
}

.playground-status.error {
  display: inline;
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-3);
}

.playground-output-area .output-error {
  color: var(--accent-3);
}

.playground-output-area .output-placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Examples */

.playground-examples {
  margin-bottom: 2rem;
}

.playground-examples h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.example-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text);
}

.example-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.example-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.example-label {
  font-weight: 500;
}

/* Note */

.playground-note {
  padding: 1rem 1.25rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.playground-note strong {
  color: var(--text);
}

.playground-note code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  color: var(--accent);
}

/* Loading indicator */

.playground-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.playground-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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