/* Playground Specific Styles */
.playground-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-top: 70px;
  background: var(--color-background);
}

/* Toolbar */
.playground-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.toolbar-left h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.syntax-toggle {
  display: flex;
  gap: 4px;
  background: var(--color-background);
  padding: 4px;
  border-radius: 8px;
}

.syntax-toggle .toggle-btn {
  padding: 6px 12px;
  font-size: 14px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.syntax-toggle .toggle-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.example-select {
  padding: 8px 12px;
  font-size: 14px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  cursor: pointer;
}

/* Main Layout */
.playground-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 140px); /* Account for navbar and toolbar */
}

.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 200px;
  overflow: hidden;
}

.output-panel {
  width: 400px;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  min-height: 200px;
  overflow: hidden;
}

/* Resizable Splitter */
.splitter {
  width: 6px;
  background: var(--color-border);
  cursor: ew-resize;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  user-select: none;
}

.splitter:hover {
  background: var(--color-primary);
}

.splitter.dragging {
  background: var(--color-primary);
}

.splitter-handle {
  width: 2px;
  height: 40px;
  background: var(--color-text-muted);
  border-radius: 1px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.splitter:hover .splitter-handle,
.splitter.dragging .splitter-handle {
  opacity: 1;
  background: white;
}

/* Disable text selection during drag */
body.dragging-splitter {
  user-select: none;
  cursor: ew-resize !important;
}

body.dragging-splitter * {
  cursor: ew-resize !important;
}

/* Panel Headers */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  font-weight: 500;
}

.file-name {
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Monaco Editor Container */
.monaco-editor-container {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 400px;
  position: relative;
}

/* Output Panel Tabs */
.panel-tabs {
  display: flex;
  gap: 1px;
  background: var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  background: var(--color-background);
  border: none;
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
}

.tab-btn:hover {
  color: var(--color-text);
}

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  overflow: auto;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Problems Tab */
.problems-list {
  padding: 1rem;
}

.no-problems {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-success);
}

.no-problems svg {
  width: 20px;
  height: 20px;
}

.problem-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.problem-item:last-child {
  border-bottom: none;
}

.problem-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.problem-icon.error {
  color: var(--color-error);
}

.problem-icon.warning {
  color: var(--color-warning);
}

.problem-content {
  flex: 1;
}

.problem-message {
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 4px;
}

.problem-location {
  font-size: 12px;
  color: var(--color-text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* AST Tab */
.ast-output {
  padding: 1rem;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Visualization Tab */
.visualization-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.visualization-placeholder {
  text-align: center;
  color: var(--color-text-muted);
}

/* Share Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--color-background);
  color: var(--color-text);
}

.share-url-container {
  display: flex;
  gap: 8px;
  margin-top: 1rem;
}

.share-url {
  flex: 1;
  padding: 10px 12px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--color-text);
}

/* Responsive Design */
@media (max-width: 768px) {
  .playground-toolbar {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .toolbar-left,
  .toolbar-right {
    width: 100%;
    justify-content: center;
  }
  
  .playground-main {
    flex-direction: column;
  }
  
  .splitter {
    display: none; /* Hide splitter on mobile */
  }
  
  .output-panel {
    width: 100%;
    height: 300px;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }
}

/* Monaco Editor Theme Overrides */
.monaco-editor .margin {
  background-color: var(--color-surface) !important;
}

.monaco-editor,
.monaco-editor .inputarea.ime-input {
  background-color: var(--color-background) !important;
}

.monaco-editor .line-numbers {
  color: var(--color-text-muted) !important;
}

/* Chat Interface Styles */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* Chat Configuration */
.chat-config {
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
}

.config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}

.config-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.config-toggle {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.config-toggle:hover {
  background: var(--color-border);
}

.config-content {
  display: none;
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

.config-section {
  margin-bottom: 16px;
}

.config-section label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.config-select,
.config-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  transition: border-color 0.2s;
}

.config-select:focus,
.config-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.token-input-group {
  display: flex;
  position: relative;
}

.token-input-group .config-input {
  padding-right: 40px;
}

.token-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.token-toggle:hover {
  background: var(--color-background);
}

.config-help {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.config-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--color-background);
  scroll-behavior: smooth;
}

.chat-message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.user-avatar,
.assistant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 16px;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}

.user-avatar {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.message-content {
  flex: 1;
  max-width: calc(100% - 44px);
}

.chat-message.user .message-content {
  text-align: right;
}

.message-text {
  background: var(--color-surface);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-message.user .message-text {
  background: var(--color-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-text {
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 6px;
  padding: 0 4px;
}

.welcome-message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.welcome-message .message-content {
  background: var(--color-surface);
  padding: 16px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-border);
}

.welcome-message ul {
  margin: 12px 0;
  padding-left: 20px;
}

.welcome-message li {
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.4;
}

/* Code Blocks */
.code-block {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text);
  overflow-x: auto;
}

.inline-code {
  background: var(--color-background);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.code-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.insert-code-btn {
  font-size: 12px;
  padding: 6px 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.insert-code-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Input */
.chat-input-container {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 16px;
}

.chat-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
  gap: 8px;
}

.chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text);
  resize: none;
  min-height: 48px;
  max-height: 150px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send {
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Notifications */
.chat-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease-out;
}

.chat-notification.success {
  background: var(--color-success);
  color: white;
}

.chat-notification.error {
  background: var(--color-error);
  color: white;
}

.chat-notification.info {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Chat Responsive Design */
@media (max-width: 768px) {
  .chat-messages {
    padding: 12px;
  }
  
  .chat-input-container {
    padding: 12px;
  }
  
  .chat-message {
    margin-bottom: 12px;
  }
  
  .message-content {
    max-width: calc(100% - 36px);
  }
  
  .config-content {
    padding: 12px;
  }
  
  .config-actions {
    flex-direction: column;
  }
  
  .chat-notification {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* Checkpoint System Styles */
.checkpoint-toggle {
  position: fixed;
  top: 120px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: white;
  font-size: 18px;
  cursor: pointer;
  z-index: 1001;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.checkpoint-toggle:hover {
  background: var(--color-primary-dark);
  transform: scale(1.05);
}

.checkpoint-panel {
  position: fixed;
  top: 170px;
  right: 20px;
  width: 350px;
  max-height: 500px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.checkpoint-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.checkpoint-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.checkpoint-actions {
  display: flex;
  gap: 8px;
}

.checkpoint-stats {
  padding: 12px 16px;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 16px;
  font-size: 12px;
}

.stats-item {
  color: var(--color-text-muted);
}

.checkpoint-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: 350px;
}

.checkpoint-item {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-bottom: 8px;
  padding: 12px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.checkpoint-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.checkpoint-item.current {
  border-color: var(--color-success);
  background: rgba(34, 197, 94, 0.05);
}

.checkpoint-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.checkpoint-description {
  font-weight: 500;
  color: var(--color-text);
  flex: 1;
  margin-right: 8px;
  font-size: 14px;
  line-height: 1.3;
}

.checkpoint-actions-small {
  display: flex;
  gap: 4px;
}

.checkpoint-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.checkpoint-preview {
  margin-top: 8px;
  border-top: 1px solid var(--color-border);
  padding-top: 8px;
}

.checkpoint-preview pre {
  background: var(--color-code-background, var(--color-background));
  padding: 8px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.2;
  margin: 0;
  overflow: hidden;
}

.checkpoint-preview code {
  color: var(--color-text);
  font-family: 'JetBrains Mono', monospace;
}

.preview-more {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 4px;
}

.no-checkpoints {
  text-align: center;
  color: var(--color-text-muted);
  font-style: italic;
  padding: 20px;
}

/* Tool Results and Validation Styles */
.tool-results {
  margin: 12px 0;
  padding: 12px;
  background: var(--color-background);
  border-radius: 6px;
  border-left: 3px solid var(--color-primary);
}

.tool-success {
  color: var(--color-success);
  font-weight: 500;
  font-size: 14px;
}

.tool-success-item {
  color: var(--color-success);
  font-size: 13px;
  margin-left: 16px;
  margin-top: 4px;
}

.tool-errors {
  color: var(--color-error);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 8px;
}

.tool-error {
  color: var(--color-error);
  font-size: 13px;
  margin-left: 16px;
  margin-top: 4px;
}

.validation-results {
  margin: 12px 0;
  padding: 12px;
  background: var(--color-background);
  border-radius: 6px;
  border-left: 3px solid var(--color-info, var(--color-primary));
}

.validation-success {
  color: var(--color-success);
  font-weight: 500;
  font-size: 14px;
}

.validation-errors {
  color: var(--color-error);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 8px;
}

.validation-error {
  color: var(--color-error);
  font-size: 13px;
  margin-left: 16px;
  margin-top: 4px;
}

.validation-warnings {
  color: var(--color-warning, #f59e0b);
  font-weight: 500;
  font-size: 14px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.validation-warning {
  color: var(--color-warning, #f59e0b);
  font-size: 13px;
  margin-left: 16px;
  margin-top: 4px;
}

/* Auto-fix Badge Styles */
.auto-fix-badge {
  display: inline-block;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

/* Button size variants for checkpoint actions */
.btn.btn-tiny {
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 3px;
}

.btn.btn-small {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}

/* Tool Action Messages */
.tool-action-message {
  display: flex;
  justify-content: center;
  margin: 8px 0;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.tool-action-message.fade-out {
  opacity: 0;
}

.tool-action-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.tool-action-icon {
  font-size: 16px;
}

.tool-action-text {
  font-style: italic;
}

.tool-action-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive adjustments for checkpoint panel */
@media (max-width: 768px) {
  .checkpoint-panel {
    width: calc(100vw - 40px);
    right: 20px;
    left: 20px;
    max-height: 60vh;
  }
  
  .checkpoint-toggle {
    right: 30px;
  }
  
  .checkpoint-stats {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .checkpoint-actions {
    flex-direction: column;
    gap: 4px;
  }
}