/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
}

a {
  color: #4a90d9;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Navbar */
.navbar {
  background: #1a1a2e;
  color: white;
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  color: white;
  font-weight: bold;
  font-size: 1.2em;
}

.nav-brand:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links a {
  color: #ccc;
}

.nav-links a:hover,
.nav-links a.active {
  color: white;
  text-decoration: none;
}

.btn-link {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
}

.btn-link:hover {
  color: white;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Auth Pages */
.auth-container {
  max-width: 400px;
  margin: 100px auto;
  padding: 30px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.auth-container h1 {
  margin: 0 0 10px;
  color: #1a1a2e;
}

.auth-container h2 {
  margin: 0 0 20px;
  color: #666;
  font-weight: normal;
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  color: #666;
}

/* Forms */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background-color: #fff;
  color: #333;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4a90d9;
}

.form-row {
  display: flex;
  gap: 15px;
}

.flex-1 {
  flex: 1;
}

.form-control {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  margin-right: 10px;
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  text-align: center;
  background: #e0e0e0;
  color: #333;
  line-height: 1;
  box-sizing: border-box;
  vertical-align: middle;
}

.btn:hover {
  background: #d0d0d0;
  text-decoration: none;
}

.btn-primary {
  background: #4a90d9;
  color: white;
}

.btn-primary:hover {
  background: #3a7fc8;
}

.btn-danger {
  background: #d9534f;
  color: white;
}

.btn-danger:hover {
  background: #c9433f;
}

.btn-warning {
  background: #f39c12;
  color: white;
}

.btn-warning:hover {
  background: #e08e0b;
}

.btn-success {
  background: #27ae60;
  color: white;
}

.btn-success:hover {
  background: #219a52;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Messages */
.error {
  background: #fce4e4;
  color: #c0392b;
  padding: 10px 15px;
  border-radius: 4px;
  margin-bottom: 15px;
}

.info {
  background: #e8f4f8;
  color: #2980b9;
  padding: 10px 15px;
  border-radius: 4px;
  margin-bottom: 15px;
}

.warning {
  background: #fcf8e3;
  color: #8a6d3b;
  padding: 10px 15px;
  border-radius: 4px;
  margin-bottom: 15px;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.table th,
.table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.table th {
  background: #f9f9f9;
  font-weight: 600;
}

.table tr:last-child td {
  border-bottom: none;
}

.table .actions {
  white-space: nowrap;
}

.table .actions form {
  display: inline;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
}

.badge-text-python {
  background: #3498db;
  color: white;
}

.badge-turtle {
  background: #27ae60;
  color: white;
}

.badge-pygame {
  background: #e67e22;
  color: white;
}

.badge-admin {
  background: #9b59b6;
  color: white;
}

.badge-success {
  background: #27ae60;
  color: white;
}

.badge-warning {
  background: #f39c12;
  color: white;
}

/* Headers */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header-row h1 {
  margin: 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px;
  background: white;
  border-radius: 4px;
  color: #666;
}

/* Admin Section */
.admin-section {
  background: white;
  padding: 20px;
  border-radius: 4px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-section h2 {
  margin-top: 0;
}

.admin-section h3 {
  margin-top: 20px;
  font-size: 1em;
  color: #666;
}

.invite-link {
  width: 100%;
  padding: 8px;
  font-family: monospace;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f9f9f9;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
}

.modal-content h3 {
  margin-top: 0;
}

.modal-content textarea {
  width: 100%;
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  resize: none;
}

.modal-actions {
  margin-top: 15px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Editor Page */
.editor-container {
  display: flex;
  gap: 15px;
  min-height: 500px;
}

.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.editor-pane label {
  margin-bottom: 5px;
  font-weight: 500;
}

.editor-pane .CodeMirror {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 4px;
  height: 100% !important;
}

.preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  border-radius: 4px;
  overflow: hidden;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #2d2d2d;
}

.preview-header label {
  color: #ccc;
  font-weight: 500;
}

#turtle-canvas {
  background: white;
  margin: 10px;
  border-radius: 4px;
  display: none;
  min-height: 200px;
  overflow: auto;  /* Enable scrolling when canvas is larger than container */
}

#turtle-canvas canvas {
  display: block;  /* Prevent inline spacing issues */
}

#pygame-canvas {
  background: white;
  margin: 10px;
  border-radius: 4px;
  display: none;
  min-height: 200px;
  overflow: auto;  /* Enable scrolling when canvas is larger than container */
}

#pygame-canvas canvas {
  display: block;  /* Prevent inline spacing issues */
}

#output {
  flex: 1;
  margin: 0;
  padding: 10px;
  color: #0f0;
  font-family: monospace;
  font-size: 14px;
  overflow: auto;
  white-space: pre-wrap;
  min-height: 100px;
}

/* Version History */
.version-history {
  margin-top: 2rem;
  border-top: 1px solid #333;
  padding-top: 1rem;
}

.version-history h3 {
  margin-bottom: 1rem;
  color: #888;
  font-size: 1rem;
  user-select: none;
}

.version-history h3:hover {
  color: #aaa;
}

#version-toggle-icon {
  display: inline-block;
  width: 1em;
  transition: transform 0.2s;
}

.version-code-row td {
  padding: 0 !important;
}

.version-code-preview {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 1rem;
  margin: 0.5rem 0;
  max-height: 300px;
  overflow: auto;
  font-family: monospace;
  font-size: 13px;
  white-space: pre-wrap;
  color: #d4d4d4;
}

/* Input Container for Preview */
#input-container {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background: #1a1a2e;
  border-top: 1px solid #333;
}

#input-prompt {
  color: #4ade80;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 14px;
  margin-right: 5px;
  white-space: pre;
}

#input-field {
  flex: 1;
  background: #0f0f1a;
  border: 1px solid #333;
  color: #e0e0e0;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 14px;
  padding: 5px 8px;
  border-radius: 3px;
  outline: none;
}

#input-field:focus {
  border-color: #4361ee;
}

/* Search Form */
.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.search-input {
  flex: 1;
  max-width: 400px;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: #4a90d9;
}

.search-results {
  color: #666;
  margin-bottom: 15px;
  font-size: 14px;
}

/* Dropzone for file uploads */
.dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  background: #fafafa;
}

.dropzone:hover {
  border-color: #4a90d9;
  background: #f5f9ff;
}

.dropzone.dragover {
  border-color: #4a90d9;
  background: #e8f2ff;
  border-style: solid;
}

.dropzone p {
  margin: 5px 0;
  color: #666;
}

.dropzone p:first-child {
  color: #333;
}
