/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  color: #0a0a0a;
  background: #fafafa;
  letter-spacing: -0.01em;
}

/* Header */
header {
  background: #0a0a0a;
  border-bottom: 3px solid #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  text-transform: lowercase;
  font-family: 'JetBrains Mono', monospace;
}

.subtitle {
  font-size: 0.875rem;
  color: #a0a0a0;
  font-weight: 400;
}

.badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #ffffff;
  color: #0a0a0a;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 2px solid #0a0a0a;
  font-family: 'JetBrains Mono', monospace;
}

/* Tabs */
.tabs {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 0;
  background: #0a0a0a;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: #1a1a1a;
  color: #a0a0a0;
  border: none;
  border-right: 1px solid #2a2a2a;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
}

.tab:hover {
  background: #2a2a2a;
  color: #ffffff;
}

.tab.active {
  background: #fafafa;
  color: #0a0a0a;
  border-bottom: 3px solid #0a0a0a;
}

.tab svg {
  width: 1rem;
  height: 1rem;
}

/* Main Content */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.editor-container {
  display: none;
}

.editor-container.active {
  display: block;
}

.space-y {
  margin-bottom: 2rem;
}

.editor-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.03em;
  text-transform: lowercase;
}

.editor-description {
  color: #666666;
  font-size: 0.95rem;
  font-weight: 400;
}

/* Error Message */
.error-message {
  background: #0a0a0a;
  border: 3px solid #ff0000;
  padding: 1.25rem;
  margin-bottom: 2rem;
  color: #ffffff;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

.error-message.hidden {
  display: none;
}

/* Prompt Section */
.prompt-section {
  margin-bottom: 2rem;
}

.prompt-input-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.prompt-input {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 2px solid #0a0a0a;
  background: #ffffff;
  font-size: 0.9rem;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.15s;
  font-weight: 500;
}

.prompt-input:focus {
  outline: none;
  border-color: #0a0a0a;
  box-shadow: 4px 4px 0 0 #0a0a0a;
  transform: translate(-2px, -2px);
}

.prompt-input:disabled {
  background: #e0e0e0;
  cursor: not-allowed;
}

.streaming-status {
  font-size: 0.85rem;
  color: #0a0a0a;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.streaming-status.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  border: 2px solid #0a0a0a;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
  position: relative;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #0a0a0a;
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 4px 4px 0 0 #0a0a0a;
  transform: translate(-2px, -2px);
}

.btn-danger {
  background: #ff0000;
  color: #ffffff;
  border-color: #ff0000;
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 4px 4px 0 0 #ff0000;
  transform: translate(-2px, -2px);
}

.btn-outline {
  background: #ffffff;
  color: #0a0a0a;
  border: 2px solid #0a0a0a;
}

.btn-outline:hover:not(:disabled) {
  background: #0a0a0a;
  color: #ffffff;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}

.btn.hidden {
  display: none;
}

/* Split View */
.split-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .split-view {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: #ffffff;
  border: 3px solid #0a0a0a;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #0a0a0a;
  color: #ffffff;
}

.panel-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
}

/* Textarea */
.code-textarea {
  width: 100%;
  height: 450px;
  padding: 1.25rem;
  border: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  resize: none;
  background: #fafafa;
  color: #0a0a0a;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.code-textarea:focus {
  outline: none;
  background: #ffffff;
}

.code-textarea:disabled {
  background: #e0e0e0;
  cursor: not-allowed;
}

/* Editing animations */
.code-textarea.highlight-editing {
  background: #fff9e6;
  box-shadow: inset 0 0 0 2px #ffd700;
  animation: pulse-editing 1.5s ease-in-out infinite;
}

.code-textarea.highlight-success {
  background: #e6ffe6;
  box-shadow: inset 0 0 0 2px #00cc00;
  animation: flash-success 0.5s ease-out;
}

/* Deleting animation - red pulse to show what's being removed */
.code-textarea.highlight-deleting {
  background: #ffe6e6;
  box-shadow: inset 0 0 0 2px #ff4444;
  animation: pulse-deleting 0.8s ease-in-out;
}

/* Inserting animation - blue pulse to show new content being typed */
.code-textarea.highlight-inserting {
  background: #e6f3ff;
  box-shadow: inset 0 0 0 2px #4488ff;
  animation: pulse-inserting 1.5s ease-in-out infinite;
}

/* Selection highlight styling */
.code-textarea::selection {
  background: #ff4444;
  color: white;
}

@keyframes pulse-editing {
  0%, 100% {
    box-shadow: inset 0 0 0 2px #ffd700;
  }
  50% {
    box-shadow: inset 0 0 0 3px #ffa500;
  }
}

@keyframes flash-success {
  0% {
    background: #e6ffe6;
    box-shadow: inset 0 0 0 3px #00cc00;
  }
  100% {
    background: #fafafa;
    box-shadow: inset 0 0 0 0px #00cc00;
  }
}

@keyframes pulse-deleting {
  0%, 100% {
    box-shadow: inset 0 0 0 2px #ff4444;
  }
  50% {
    box-shadow: inset 0 0 0 4px #ff0000;
  }
}

@keyframes pulse-inserting {
  0%, 100% {
    box-shadow: inset 0 0 0 2px #4488ff;
  }
  50% {
    box-shadow: inset 0 0 0 3px #0066ff;
  }
}

/* Table Container */
.table-container {
  height: 450px;
  overflow: auto;
  background: #ffffff;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #a0a0a0;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  position: sticky;
  top: 0;
  background: #0a0a0a;
  color: #ffffff;
  z-index: 1;
}

th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  border: 2px solid #0a0a0a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
}

td {
  padding: 0.875rem 1rem;
  border: 1px solid #d0d0d0;
}

tbody tr:hover {
  background: #f5f5f5;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

tbody tr:nth-child(even):hover {
  background: #f0f0f0;
}

/* Table row highlight when edited */
tbody tr.row-highlight-edit {
  background: #ffffcc !important;
  animation: row-flash 2s ease-out;
  box-shadow: inset 0 0 0 3px #ffcc00;
}

@keyframes row-flash {
  0% {
    background: #ffff00 !important;
    box-shadow: inset 0 0 0 3px #ffaa00;
  }
  100% {
    background: #ffffcc !important;
    box-shadow: inset 0 0 0 3px #ffcc00;
  }
}

.cell-editable {
  cursor: pointer;
  padding: 0.5rem;
  min-height: 1.5rem;
  transition: background 0.15s;
}

.cell-editable:hover {
  background: #e0e0e0;
  outline: 2px solid #0a0a0a;
}

.cell-empty {
  color: #c0c0c0;
}

.cell-input {
  width: 100%;
  padding: 0.5rem;
  border: 2px solid #0a0a0a;
  font-size: 0.85rem;
  font-family: 'Space Grotesk', sans-serif;
}

.cell-input:focus {
  outline: none;
  box-shadow: 2px 2px 0 0 #0a0a0a;
}

/* Markdown Preview */
.markdown-preview {
  height: 450px;
  overflow: auto;
  padding: 1.5rem;
  background: #ffffff;
}

.markdown-preview h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-top: 1.75rem;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.markdown-preview h1:first-child {
  margin-top: 0;
}

.markdown-preview h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.markdown-preview h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.markdown-preview p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

.markdown-preview ul, .markdown-preview ol {
  margin-bottom: 1rem;
  margin-left: 1.75rem;
}

.markdown-preview li {
  margin-bottom: 0.35rem;
}

.markdown-preview code {
  background: #0a0a0a;
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
}

.markdown-preview pre {
  background: #0a0a0a;
  color: #ffffff;
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  border: 3px solid #0a0a0a;
}

.markdown-preview pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.markdown-preview blockquote {
  border-left: 4px solid #0a0a0a;
  padding-left: 1.25rem;
  margin: 1.25rem 0;
  color: #4a4a4a;
  font-style: italic;
}

.markdown-preview a {
  color: #0a0a0a;
  text-decoration: underline;
  font-weight: 600;
}

.markdown-preview a:hover {
  text-decoration: none;
}

.markdown-preview table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

.markdown-preview table th,
.markdown-preview table td {
  border: 2px solid #0a0a0a;
  padding: 0.75rem 1rem;
}

.markdown-preview table th {
  background: #0a0a0a;
  color: #ffffff;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.markdown-preview hr {
  border: none;
  border-top: 3px solid #0a0a0a;
  margin: 2rem 0;
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
  border: 3px solid #0a0a0a;
}

/* Info Box */
.info-box {
  background: #0a0a0a;
  color: #ffffff;
  border: 3px solid #0a0a0a;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.info-box h4 {
  font-weight: 700;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
}

.info-box ul {
  list-style: none;
  margin-left: 0;
}

.info-box li {
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
}

.info-box li:before {
  content: "→";
  position: absolute;
  left: 0;
  font-weight: 700;
}

/* Examples Section */
.examples-section h4 {
  font-weight: 700;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
}

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

/* Footer */
footer {
  background: #0a0a0a;
  color: #ffffff;
  border-top: 3px solid #ffffff;
  padding: 2rem 2rem;
  margin-top: 4rem;
  text-align: center;
}

footer p {
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
}

footer p:first-child {
  margin-bottom: 0.5rem;
  text-transform: lowercase;
  font-weight: 700;
}

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

::-webkit-scrollbar-track {
  background: #e0e0e0;
}

::-webkit-scrollbar-thumb {
  background: #0a0a0a;
  border: 2px solid #e0e0e0;
}

::-webkit-scrollbar-thumb:hover {
  background: #2a2a2a;
}

/* Clarification Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #fafafa;
  border: 3px solid #0a0a0a;
  box-shadow: 8px 8px 0 0 #0a0a0a;
  max-width: 550px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  background: #0a0a0a;
  color: #fafafa;
  padding: 1.5rem 1.75rem;
  border-bottom: 3px solid #0a0a0a;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.05em;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.modal-body {
  padding: 2rem 1.75rem;
}

.clarification-question {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #0a0a0a;
  line-height: 1.5;
}

.clarification-context {
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 1.5rem;
  font-style: italic;
  line-height: 1.5;
}

.clarification-context:empty {
  display: none;
}

.clarification-input {
  width: 100%;
  min-height: 100px;
  padding: 1rem;
  border: 3px solid #0a0a0a;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  resize: vertical;
  background: #ffffff;
  color: #0a0a0a;
  line-height: 1.5;
}

.clarification-input:focus {
  outline: none;
  box-shadow: 4px 4px 0 0 #0a0a0a;
}

.clarification-input::placeholder {
  color: #999;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  padding: 0 1.75rem 1.75rem 1.75rem;
}

.modal-footer button {
  flex: 1;
  padding: 1rem 1.5rem;
  border: 3px solid #0a0a0a;
  background: #fafafa;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-submit {
  background: #0a0a0a !important;
  color: #fafafa !important;
}

.btn-submit:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 0 #0a0a0a;
}

.btn-cancel:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 0 #0a0a0a;
}

.modal-footer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
