/* Purple-Orange Modern Design */
:root {
  --purple-50: #faf5ff;
  --purple-100: #f3e8ff;
  --purple-200: #e9d5ff;
  --purple-300: #d8b4fe;
  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --purple-700: #7e22ce;
  --purple-800: #6b21a8;
  --purple-900: #581c87;
  --purple-950: #320e48;

  --orange-50: #fff7ed;
  --orange-100: #ffedd5;
  --orange-200: #fed7aa;
  --orange-300: #fdba74;
  --orange-400: #fb923c;
  --orange-500: #f97316;
  --orange-600: #ea580c;
  --orange-700: #c2410c;
  --orange-800: #9a3412;
  --orange-900: #7c2d12;

  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-950: #172554;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--purple-50) 0%, var(--orange-50) 100%);
  min-height: 100vh;
  color: var(--gray-800);
  line-height: 1.5;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--purple-600), var(--orange-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
}

.logo-emoji {
  font-size: 1.5rem;
}

header .subtitle {
  color: var(--gray-600);
  font-size: 1.1rem;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Card Styles */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.card.hidden {
  display: none;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
  padding: 1.25rem 1.5rem 0.5rem;
  margin: 0;
}

.card-icon {
  margin-right: 0.5rem;
}

.card-description {
  color: var(--gray-600);
  font-size: 0.875rem;
  padding: 0 1.5rem 1rem;
  margin: 0;
}

.card-content {
  padding: 1rem 1.5rem 1.5rem;
}

/* Tabs */
.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding: 0 1.5rem 1.5rem;
}

@media (min-width: 640px) {
  .tabs {
    grid-template-columns: repeat(5, 1fr);
  }
}

.tab-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--gray-200);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-700);
}

@media (min-width: 640px) {
  .tab-button {
    font-size: 0.875rem;
    flex-direction: row;
    padding: 0.75rem 1rem;
  }
}

.tab-button:hover {
  background: var(--purple-50);
  border-color: var(--purple-200);
}

.tab-button.active {
  background: linear-gradient(90deg, var(--purple-100), var(--orange-100));
  border-color: var(--purple-300);
  color: var(--purple-800);
}

.tab-icon {
  font-size: 1.25rem;
}

/* Form Groups */
.form-group {
  margin-bottom: 1rem;
  padding: 0 1.5rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

/* Add bottom padding to cards with form groups */
.card .form-group:first-child {
  padding-top: 0.25rem;
}

.card .form-group:last-child {
  padding-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--gray-900);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px var(--purple-100);
}

input::placeholder, textarea::placeholder {
  color: var(--gray-400);
}

.hint {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

.textarea {
  min-height: 140px;
  resize: vertical;
  font-family: inherit;
}

.input-row {
  display: flex;
  gap: 0.75rem;
}

.input-row input {
  flex: 1;
}

.input-row select {
  width: 100px;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.button-primary {
  background: linear-gradient(90deg, var(--purple-600), var(--orange-500));
  color: white;
}

.button-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.button-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.button-secondary:hover {
  background: var(--gray-200);
}

.button-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.button-outline:hover {
  background: var(--gray-50);
}

.button-ghost {
  background: transparent;
  color: var(--gray-600);
}

.button-ghost:hover {
  background: var(--gray-100);
}

.button-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.button-dashed {
  border-style: dashed;
}

.actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.actions .button {
  flex: 1;
}

/* Info Boxes */
.info-box {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin: 0 1.5rem 1rem;
}

.info-box:last-child {
  margin-bottom: 1.5rem;
}

.info-box.blue {
  background: var(--blue-50);
  color: var(--blue-950);
}

.info-box.purple {
  background: var(--purple-50);
  color: var(--purple-950);
}

.info-box.amber {
  background: var(--orange-100);
  color: var(--orange-900);
}

.info-box ul {
  margin-top: 0.5rem;
  padding-left: 1.25rem;
}

.info-box li {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
}

/* Toggle */
.toggle-group {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 1rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.toggle-switch {
  width: 40px;
  height: 20px;
  appearance: none;
  background: var(--gray-300);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-switch:checked {
  background: var(--purple-500);
}

.toggle-switch::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 1px;
  left: 1px;
  transition: transform 0.2s;
}

.toggle-switch:checked::before {
  transform: translateX(20px);
}

.toggle-text {
  font-weight: 500;
  color: var(--gray-700);
}

/* Image Upload */
.image-upload-container {
  margin-top: 0.5rem;
  padding: 0 1.5rem 1.5rem;
}

.image-upload-container:first-child {
  padding-top: 0.25rem;
}

.image-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--gray-50);
}

.image-upload-label:hover {
  border-color: var(--purple-400);
  background: var(--purple-50);
}

.upload-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

.image-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.image-preview {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--purple-600);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  cursor: pointer;
}

/* Thread Children */
.thread-children {
  padding: 0 1rem 1rem;
}

.thread-child {
  border-left: 3px solid var(--purple-300);
  margin-left: 1rem;
  margin-top: 1rem;
  padding-left: 1rem;
}

.thread-child-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.thread-child-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-800);
}

.thread-child-actions {
  display: flex;
  gap: 0.25rem;
}

.thread-child-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.add-thread-button {
  margin: 1rem 1.5rem 1rem;
}

/* Thread Overview */
.thread-overview-content {
  padding: 1rem 1.5rem 1.5rem;
}

.overview-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.overview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.overview-label {
  font-size: 0.875rem;
  font-weight: 500;
}

.overview-subtext {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* Selected Account */
.selected-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--purple-50);
  border: 1px solid var(--purple-200);
  border-radius: 8px;
  margin: 0.5rem 1.5rem 1rem;
}

.account-label {
  font-weight: 500;
  color: var(--purple-800);
}

/* Output Section */
.output-container {
  margin-bottom: 1rem;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 0.875rem;
  font-weight: 500;
}

.output-html, .output-json {
  width: 100%;
  min-height: 200px;
  padding: 1rem;
  border: 1px solid var(--gray-200);
  border-radius: 0 0 8px 8px;
  background: var(--gray-50);
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  resize: vertical;
}

.output-html {
  min-height: 250px;
}

.output-json {
  min-height: 150px;
}

/* Attachments */
.attachments-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

.attachments-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding: 0 1.5rem;
}

.attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1.5rem 1rem;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: var(--purple-50);
  border: 1px solid var(--purple-200);
  border-radius: 9999px;
  font-size: 0.875rem;
}

.attachment-image-thumb {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* Markdown Editor (EasyMDE) */
.markdown-editor-container {
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.markdown-editor-container .EasyMDEContainer {
  border: none;
}

.markdown-editor-container .CodeMirror {
  min-height: 140px !important;
  font-family: ui-monospace, 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--gray-900);
}

.markdown-editor-container .CodeMirror-placeholder {
  color: var(--gray-400);
}

.markdown-editor-container .CodeMirror-focused {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px var(--purple-100);
}

.markdown-editor-container .editor-toolbar {
  background: var(--purple-50);
  border: none;
  border-bottom: 1px solid var(--gray-200);
  opacity: 1;
  padding: 0.25rem 0.5rem;
}

.markdown-editor-container .editor-toolbar button {
  color: var(--gray-700);
  opacity: 1;
}

.markdown-editor-container .editor-toolbar button.active {
  background: var(--purple-200);
  color: var(--purple-800);
}

.markdown-editor-container .editor-toolbar button:hover {
  background: var(--purple-300);
  color: var(--purple-900);
}

.markdown-editor-container .CodeMirror-cursor {
  border-left: 1px solid var(--purple-600);
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .actions {
    flex-direction: column;
  }
}
