/* Monokai Pro Color Palette */
:root {
  --mono-bg: #2D2A2E;
  --mono-bg-light: #383539;
  --mono-bg-lighter: #423f42;
  --mono-fg: #fcfcfa;
  --mono-fg-dim: #939293;
  --mono-pink: #ff6188;
  --mono-green: #a9dc76;
  --mono-yellow: #ffd866;
  --mono-orange: #fc9867;
  --mono-purple: #ab9df2;
  --mono-teal: #78dce8;

  --border-color: #423f42;
  --radius: 8px;
  --radius-sm: 4px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--mono-bg);
  color: var(--mono-fg);
  line-height: 1.6;
}

/* App Layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--mono-bg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.logo {
  font-family: 'Fira Code', monospace;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  gap: 2px;
}

.logo-bracket {
  color: var(--mono-fg-dim);
}

.logo-text {
  color: var(--mono-fg);
}

.logo-dot {
  color: var(--mono-pink);
}

.logo-ai {
  color: var(--mono-green);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--mono-fg-dim);
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--mono-fg);
  background: var(--mono-bg-light);
}

.btn-ghost {
  background: transparent;
  color: var(--mono-fg-dim);
}

.btn-ghost:hover {
  color: var(--mono-fg);
  background: var(--mono-bg-light);
}

.btn-primary {
  background: #ffffff;
  color: var(--mono-bg);
}

.btn-primary:hover {
  background: #f0f0f0;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

/* Chat Container */
.chat-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome Message */
.welcome-message {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 300px;
}

.welcome-content {
  text-align: center;
  max-width: 500px;
}

.welcome-content h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--mono-fg);
}

.welcome-content h1 .highlight {
  color: var(--mono-green);
}

.welcome-content p {
  color: var(--mono-fg-dim);
  font-size: 1rem;
  margin-bottom: 24px;
}

.api-key-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--mono-bg-light);
  border-radius: var(--radius);
  color: var(--mono-yellow);
  font-size: 0.9rem;
}

.api-key-notice svg {
  flex-shrink: 0;
}

.link-btn {
  background: none;
  border: none;
  color: var(--mono-teal);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.link-btn:hover {
  color: var(--mono-fg);
}

/* Messages */
.message {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.user-message .message-content {
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.message-prompt {
  color: var(--mono-teal);
  margin-right: 8px;
}

.message-text {
  color: var(--mono-fg);
}

.assistant-message .message-content {
  padding: 16px 0;
}

.assistant-message p {
  margin-bottom: 16px;
  color: var(--mono-fg);
}

.assistant-message ul,
.assistant-message ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.assistant-message li {
  color: var(--mono-fg-dim);
  margin-bottom: 6px;
}

.assistant-message li::marker {
  color: var(--mono-teal);
}

.assistant-message h1,
.assistant-message h2,
.assistant-message h3 {
  color: var(--mono-fg);
  margin-bottom: 12px;
  margin-top: 16px;
}

.assistant-message h1 {
  font-size: 1.5rem;
}

.assistant-message h2 {
  font-size: 1.25rem;
}

.assistant-message h3 {
  font-size: 1.1rem;
}

.assistant-message strong {
  color: var(--mono-fg);
  font-weight: 600;
}

.assistant-message em {
  font-style: italic;
}

/* Code Blocks */
.code-block,
.diff-block {
  background: #221f22;
  border-radius: var(--radius);
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--mono-bg-light);
  border-bottom: 1px solid var(--border-color);
}

.code-filename {
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  color: var(--mono-fg-dim);
}

.code-copy-btn {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 4px 10px;
  background: var(--mono-bg-lighter);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--mono-fg-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.code-copy-btn:hover {
  color: var(--mono-fg);
  border-color: var(--mono-fg-dim);
}

.code-content {
  margin: 0;
  padding: 16px;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  overflow-x: auto;
  color: var(--mono-fg);
  white-space: pre !important;
}

.code-content code {
  white-space: pre !important;
  word-wrap: normal;
}

/* Inline Code */
.inline-code {
  font-family: 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--mono-bg-light);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--mono-pink);
}

/* Syntax Highlighting */
.keyword {
  color: var(--mono-pink);
}

.function {
  color: var(--mono-green);
}

.string {
  color: var(--mono-yellow);
}

.number {
  color: var(--mono-purple);
}

.comment {
  color: var(--mono-fg-dim);
  font-style: italic;
}

.operator {
  color: var(--mono-pink);
}

.parameter {
  color: var(--mono-orange);
  font-style: italic;
}

/* Diff Styling */
.diff-content {
  margin: 0;
  padding: 16px;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  overflow-x: auto;
}

.diff-line {
  line-height: 1.6;
  padding: 1px 8px;
  margin: 0 -8px;
  white-space: pre;
}

.diff-add {
  color: var(--mono-green);
  background: rgba(169, 220, 118, 0.15);
}

.diff-del {
  color: var(--mono-pink);
  background: rgba(255, 97, 136, 0.15);
}

.diff-info {
  color: var(--mono-teal);
  background: rgba(120, 220, 232, 0.1);
}

.diff-context {
  color: var(--mono-fg-dim);
}

/* Highlight.js overrides for Monokai theme */
.hljs {
  background: transparent !important;
  padding: 0 !important;
  white-space: pre !important;
}

pre.code-content {
  background: #221f22;
}

pre.code-content code {
  background: transparent;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre !important;
  display: block;
}

/* Success and Error Text */
.success-text {
  color: var(--mono-green);
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  margin-bottom: 8px !important;
}

.success-text::before {
  content: "✓ ";
}

.error-text {
  color: var(--mono-pink);
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--mono-fg-dim);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Prompt Bar */
.prompt-bar {
  padding: 16px 24px 24px;
  background: var(--mono-bg);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.prompt-container {
  max-width: 900px;
  margin: 0 auto;
}

.prompt-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--mono-bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: all 0.2s;
}

.prompt-input-wrapper:focus-within {
  border-color: var(--mono-fg-dim);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.prompt-prefix {
  font-family: 'Fira Code', monospace;
  color: #ffffff;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.prompt-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--mono-fg);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  min-height: 20px;
  max-height: 200px;
  line-height: 1.4;
  padding: 4px 0;
}

.prompt-input::placeholder {
  color: var(--mono-fg-dim);
}

.send-btn {
  background: #ffffff;
  border: none;
  color: var(--mono-bg);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #f0f0f0;
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

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

.send-btn.loading {
  animation: pulse 1.5s infinite;
}

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

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

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

.modal {
  background: var(--mono-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  margin: 24px;
  transform: scale(0.95);
  transition: transform 0.2s;
}

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

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--mono-fg);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--mono-fg-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--mono-fg);
  background: var(--mono-bg-light);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--mono-fg);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--mono-fg-dim);
  margin-bottom: 12px;
}

.api-key-input-wrapper {
  display: flex;
  gap: 8px;
}

.form-input {
  flex: 1;
  background: var(--mono-bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  color: var(--mono-fg);
  outline: none;
  transition: all 0.2s;
}

.form-input:focus {
  border-color: var(--mono-fg-dim);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.form-input::placeholder {
  color: var(--mono-fg-dim);
}

.toggle-visibility {
  flex-shrink: 0;
}

.hidden {
  display: none;
}

.get-api-key-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--mono-teal);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.2s;
}

.get-api-key-link:hover {
  color: var(--mono-fg);
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--mono-fg-dim);
}

/* Selection */
::selection {
  background: rgba(120, 220, 232, 0.3);
  color: var(--mono-fg);
}

/* Responsive */
@media (max-width: 768px) {
  .header-actions .btn-ghost {
    display: none;
  }

  .chat-messages {
    padding: 16px;
  }

  .message {
    max-width: 100%;
  }

  .modal {
    margin: 16px;
  }
}
