/* Variables CSS */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --bg-card: #15151f;
  --bg-hover: #1e1e2a;
  
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  
  --accent-primary: #6366f1;
  --accent-secondary: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  --border-color: #2a2a3a;
  --border-focus: #6366f1;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);
  
  --font-sans: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --transition: 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(129, 140, 248, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* App Container */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem 0;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.logo-icon {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 300;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  background: var(--bg-secondary);
  padding: 0.4rem;
  border-radius: var(--radius-lg);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.mode-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.mode-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.mode-tab.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.tab-icon {
  font-size: 1.1rem;
}

/* Main Layout */
.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

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

/* Sections */
.builder-section,
.preview-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

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

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Tool Info Section */
.tool-info-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.tool-info-section .form-group {
  margin-bottom: 0;
}

.tool-info-section .form-row {
  gap: 1rem;
}

.tool-info-section input {
  background: var(--bg-secondary);
}

@media (max-width: 768px) {
  .tool-info-section .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .tool-info-section .form-group {
    margin-bottom: 1rem;
  }
  
  .tool-info-section .form-group:last-child {
    margin-bottom: 0;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon {
  font-size: 1rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  box-shadow: var(--shadow-sm), 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 30px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background: var(--bg-tertiary);
  color: var(--accent-secondary);
  border: 1px dashed var(--border-color);
}

.btn-small:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
}

/* Properties Container */
.properties-container {
  flex: 1;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1.5rem;
}

.properties-container::-webkit-scrollbar {
  width: 6px;
}

.properties-container::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.properties-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
}

.empty-state span {
  font-size: 0.85rem;
}

/* Property Card */
.property-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: all var(--transition);
}

.property-card:hover {
  border-color: var(--accent-primary);
  transform: translateX(4px);
}

.property-info {
  flex: 1;
}

.property-name {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent-secondary);
  margin-bottom: 0.25rem;
}

.property-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.property-type {
  background: var(--bg-secondary);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.property-required {
  color: var(--success);
}

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

.property-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  transition: color var(--transition);
}

.property-actions button:hover {
  color: var(--text-primary);
}

.property-actions button.delete:hover {
  color: var(--error);
}

/* Required Section */
.required-section {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.required-section h3 {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.required-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.no-required {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.required-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

/* Code Preview */
.preview-actions {
  display: flex;
  gap: 0.5rem;
}

.code-preview {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-width: 0;
}

.code-preview pre {
  margin: 0;
  padding: 1.25rem;
  overflow: auto;
  max-height: 500px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
}

.code-preview code {
  font-family: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-small {
  max-width: 400px;
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color var(--transition);
  line-height: 1;
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

/* Form Elements */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all var(--transition);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Checkbox */
.checkbox-group {
  margin-top: 1rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}

.checkbox-label:hover .checkmark {
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  color: white;
  font-size: 0.85rem;
  font-weight: bold;
}

/* Type Options */
.type-options {
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

/* Nested Properties */
.nested-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.nested-header h4 {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.nested-props-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nested-prop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.nested-prop-item span {
  font-family: var(--font-mono);
  color: var(--accent-secondary);
}

.nested-prop-item .type-badge {
  font-family: var(--font-sans);
  background: var(--bg-tertiary);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.nested-prop-item button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
}

.nested-prop-item button:hover {
  color: var(--error);
}

/* Output Builder Specific */
.choice-input-section {
  background: var(--bg-tertiary);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.choice-input-section textarea {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.8;
}

.json-info {
  display: flex;
  gap: 1rem;
  background: var(--bg-tertiary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  align-items: flex-start;
}

.info-icon {
  font-size: 1.5rem;
}

.info-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.info-content p:last-child {
  margin-bottom: 0;
}

.info-content strong {
  color: var(--text-primary);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--success);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon {
  color: var(--success);
  font-size: 1.1rem;
}

.toast-message {
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.property-card {
  animation: fadeIn 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
  .app {
    padding: 1rem;
  }
  
  .header h1 {
    font-size: 1.75rem;
  }
  
  .section-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .preview-actions {
    justify-content: flex-end;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

