* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #667eea;
  --primary-dark: #5568d3;
  --secondary: #764ba2;
  --success: #10b981;
  --danger: #ef4444;
  --bg: #0f172a;
  --bg-light: #1e293b;
  --bg-lighter: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #475569;
  --shadow: rgba(0, 0, 0, 0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 10px var(--shadow);
}

.header h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--bg-light);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.project-section,
.history-section {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.project-section h2,
.history-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.status-message {
  text-align: center;
  padding: 1rem 0;
}

.status-message p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.project-info {
  margin-top: 1rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.info-item label {
  font-weight: 600;
  color: var(--text-muted);
}

.info-item span,
.info-item a {
  color: var(--text);
  text-decoration: none;
  word-break: break-all;
}

.info-item a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-lighter);
  color: var(--text);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
}

.btn-secondary {
  background: var(--bg-lighter);
}

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

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* History List */
.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  background: var(--bg-lighter);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  border-left: 3px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  background: var(--bg-lighter);
  border-left-color: var(--primary);
  transform: translateX(2px);
}

.history-item.active {
  border-left-color: var(--success);
  background: var(--bg-lighter);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.history-item-id {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-item-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.history-item-status.success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.history-item-status.active {
  background: rgba(102, 126, 234, 0.2);
  color: var(--primary);
}

.history-item-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-item-url {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
  margin-top: 0.25rem;
  display: block;
}

.history-item-url:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Editor Area */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.editor-header {
  background: var(--bg-light);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.file-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.file-selector label {
  color: var(--text-muted);
  font-weight: 600;
}

.file-selector select {
  flex: 1;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.file-selector select:focus {
  outline: none;
  border-color: var(--primary);
}

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

.editor-container {
  flex: 1;
  position: relative;
}

#editor {
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  background: var(--bg);
  color: var(--text);
  border: none;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  tab-size: 2;
}

.status-bar {
  background: var(--bg-light);
  padding: 0.5rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

#loading-message {
  margin-top: 1rem;
  color: var(--text);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.5rem;
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow);
  min-width: 300px;
  animation: slideIn 0.3s ease-out;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

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

.toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

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

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

::-webkit-scrollbar-track {
  background: var(--bg);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-lighter);
}

