/**
 * AGON Playground Styles
 *
 * Responsive styling for the interactive playground.
 * Supports both light and dark modes via Material theme.
 */

/* Container */
#agon-playground {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}

/* Header with example selector */
.playground-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.playground-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.playground-header select {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--md-default-fg-color--lighter);
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-size: 0.9rem;
  cursor: pointer;
}

.playground-header select:hover {
  border-color: var(--md-accent-fg-color);
}

/* Main layout: two columns */
.playground-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  min-height: 400px;
}

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

/* Input panel */
.playground-input {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  overflow: hidden;
}

.playground-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--md-code-bg-color);
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
}

.playground-input-header span {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--md-default-fg-color--light);
}

#json-editor {
  flex: 1;
  min-height: 350px;
}

/* Output panel */
.playground-output {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  overflow: hidden;
}

/* Tab bar */
.playground-tabs {
  display: flex;
  gap: 0;
  background: var(--md-code-bg-color);
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  overflow-x: auto;
}

.playground-tab {
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--md-default-fg-color--light);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  position: relative;
}

.playground-tab:hover {
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
}

.playground-tab.active {
  color: var(--md-accent-fg-color);
  background: var(--md-default-bg-color);
}

.playground-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--md-accent-fg-color);
}

.playground-tab.best::before {
  content: '\2713';
  margin-right: 0.3rem;
  color: var(--md-accent-fg-color);
}

/* Copy button in tab bar */
.playground-tabs-actions {
  margin-left: auto;
  padding: 0.3rem;
}

#copy-btn {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 4px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color--light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

#copy-btn:hover {
  border-color: var(--md-accent-fg-color);
  color: var(--md-accent-fg-color);
}

/* Output content */
.playground-output-content {
  flex: 1;
  position: relative;
  min-height: 300px;
}

#encoded-output {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1rem;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  background: var(--md-code-bg-color);
  color: var(--md-code-fg-color);
}

/* Error message */
#playground-error {
  display: none;
  padding: 0.75rem 1rem;
  background: rgba(255, 0, 0, 0.1);
  border: 1px solid rgba(255, 0, 0, 0.3);
  border-radius: 4px;
  color: #d32f2f;
  font-size: 0.9rem;
}

[data-md-color-scheme="slate"] #playground-error {
  background: rgba(255, 0, 0, 0.15);
  color: #ff5252;
}

/* Token comparison section */
.playground-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  background: var(--md-code-bg-color);
}

.playground-stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.playground-stats-header h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--md-default-fg-color);
}

/* Best format indicator */
#best-format {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.best-format-label {
  color: var(--md-default-fg-color--light);
}

.best-format-name {
  font-weight: 600;
  color: var(--md-accent-fg-color);
}

.best-format-savings {
  color: #00C853;
  font-weight: 500;
}

/* Chart container */
.chart-container {
  height: 200px;
  width: 100%;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .playground-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .playground-header select {
    width: 100%;
  }

  .playground-tabs {
    flex-wrap: nowrap;
  }

  .playground-tab {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .chart-container {
    height: 180px;
  }
}

/* Syntax highlighting for output (basic) */
.output-keyword {
  color: #0066CC;
}

.output-string {
  color: #00C853;
}

.output-number {
  color: #FF9500;
}

/* Loading state */
.playground-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 350px;
  color: var(--md-default-fg-color--light);
  font-size: 0.9rem;
}

.playground-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--md-default-fg-color--lightest);
  border-top-color: var(--md-accent-fg-color);
  border-radius: 50%;
  margin-right: 0.5rem;
  animation: spin 1s linear infinite;
}

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