:root {
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --error: #ef4444;
  --success: #10b981;
  --info: #3b82f6;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.title {
  font-size: 1.875rem;
  font-weight: bold;
  background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary), #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradient 8s linear infinite;
  background-size: 200% 200%;
  text-align: center;
  flex-grow: 1;
  margin: 0 1rem;
}

.btn-back {
  background-color: white;
  color: black;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s, color 0.3s;
  font-weight: 500;
  font-size: 0.875rem;
}

.btn-back:hover {
  background-color: #f0f0f0;
}

.btn-back .icon {
  width: 0.875rem;
  height: 0.875rem;
  stroke: black;
  margin-right: 0.375rem;
}

.header-buttons {
  display: flex;
  gap: 0.75rem;
}

.btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background-color: #4f46e5;
  transform: scale(1.05);
}

.btn-secondary {
  background-color: var(--accent-secondary);
  color: white;
}

.btn-secondary:hover {
  background-color: #7c3aed;
  transform: scale(1.05);
}

.icon {
  width: 0.875rem;
  height: 0.875rem;
}

main {
  flex: 1;
  padding: 1rem;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  gap: 1rem;
  height: calc(100vh - 5rem);
}

.editor-grid.expanded .editor-section,
.editor-grid.expanded .console {
  display: none;
}

.editor-grid.expanded .preview-section {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  grid-row: 1;
  grid-column: 1;
}

.preview-section {
  background-color: white;
  border-radius: 0.5rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  grid-row: 1 / 3;
  grid-column: 2;
}

.console {
  grid-row: 2;
  grid-column: 1;
  height: 200px;
  background-color: var(--bg-secondary);
  border-radius: 0.5rem;
  overflow: hidden;
}

.tabs {
  display: flex;
  background-color: var(--bg-secondary);
  border-radius: 0.5rem 0.5rem 0 0;
  overflow: hidden;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.tab.active {
  background-color: var(--accent-primary);
  color: white;
}

.code-editor {
  flex: 1;
  border-radius: 0 0 0.5rem 0.5rem;
  overflow: hidden;
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.console-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.btn-clear {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.btn-clear:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.console-output {
  height: calc(100% - 2.5rem);
  padding: 1rem;
  overflow-y: auto;
  font-size: 0.875rem;
}

.console-output .error {
  color: var(--error);
}

.console-output .success {
  color: var(--success);
}

.console-output .info {
  color: var(--info);
}

.preview-header {
  background-color: var(--bg-secondary);
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.window-controls {
  display: flex;
  gap: 0.5rem;
}

.control {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
}

.control.red { background-color: #ef4444; }
.control.yellow { background-color: #f59e0b; }
.control.green { background-color: #10b981; }

iframe {
  flex: 1;
  width: 100%;
  border: none;
  background-color: white;
}

@keyframes gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4f46e5;
}

/* Mobile Styles */
@media (max-width: 768px) {
  header {
    padding: 0.5rem;
    position: relative;
  }
  
  .title {
    font-size: 1rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    z-index: 1;
    white-space: nowrap;
  }
  
  .btn-back {
    position: relative;
    z-index: 10;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
  
  .btn-back .icon {
    width: 0.75rem;
    height: 0.75rem;
    margin-right: 0.25rem;
  }
  
  .header-buttons {
    gap: 0.5rem;
    position: relative;
    z-index: 10;
  }
  
  .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    gap: 0.25rem;
  }
  
  .icon {
    width: 0.75rem;
    height: 0.75rem;
  }
  
  .desktop-only {
    display: none;
  }
  
  main {
    padding: 0.5rem;
  }
  
  .editor-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: calc(100vh - 4rem);
  }
  
  .editor-section {
    order: 1;
    grid-row: auto;
    grid-column: 1;
  }
  
  .preview-section {
    order: 2;
    min-height: 300px;
    grid-row: auto;
    grid-column: 1;
  }
  
  .console {
    order: 3;
    grid-column: 1;
    grid-row: auto;
    height: 150px;
  }
  
  .tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .code-editor {
    min-height: 250px;
  }
}

@media (max-width: 480px) {
  .title {
    font-size: 0.875rem;
  }
  
  .btn-back {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }
  
  .btn-back .icon {
    width: 0.65rem;
    height: 0.65rem;
    margin-right: 0.2rem;
  }
  
  .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }
  
  .icon {
    width: 0.65rem;
    height: 0.65rem;
  }
  
  .tab {
    padding: 0.375rem 0.75rem;
  }
  
  .tab .icon {
    display: none;
  }
}