/* Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-700: #166534;
  --green-600: #16a34a;
  --green-100: #dcfce7;
  --green-50: #f0fdf4;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --yellow-100: #fef3c7;
  --yellow-700: #a16207;
  --blue-100: #dbeafe;
  --blue-700: #1d4ed8;
  --red-100: #fee2e2;
  --red-700: #b91c1c;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-100);
}

/* Layout */
.app {
  min-height: 100vh;
}

.header {
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  color: white;
  padding: 24px;
}
.header h1 { font-size: 24px; font-weight: 700; }
.header .subtitle { opacity: 0.9; font-size: 14px; margin-top: 4px; }

.main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

/* Actions */
.actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--green-700);
  color: white;
}
.btn-primary:hover { background: #14532d; }
.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }
.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}
.btn-danger {
  background: var(--red-700);
  color: white;
}
.btn-danger:hover { background: #991b1b; }
.btn-warning {
  background: var(--yellow-700);
  color: white;
}
.btn-warning:hover { background: #854d0e; }

/* Newsletter Grid */
.newsletter-grid {
  display: grid;
  gap: 16px;
}

.newsletter-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.newsletter-card h3 {
  font-size: 18px;
  color: var(--gray-900);
}
.newsletter-card .meta {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}
.newsletter-card .actions {
  margin: 0;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-draft { background: var(--gray-100); color: var(--gray-700); }
.badge-review { background: var(--yellow-100); color: var(--yellow-700); }
.badge-published { background: var(--green-100); color: var(--green-700); }

/* Editor Layout */
.editor-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 24px;
  min-height: calc(100vh - 150px);
}

.sidebar {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  height: fit-content;
  position: sticky;
  top: 24px;
}
.sidebar h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 12px;
}
.sidebar-nav {
  list-style: none;
}
.sidebar-nav li {
  margin-bottom: 4px;
}
.sidebar-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--gray-700);
  text-decoration: none;
  font-size: 14px;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--green-50);
  color: var(--green-700);
}

.editor-main {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.editor-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.editor-header h2 {
  font-size: 20px;
}

.editor-content {
  padding: 24px;
}

/* Sections */
.section-block {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-100);
}
.section-block:last-child {
  border-bottom: none;
}
.section-block h3 {
  font-size: 16px;
  color: var(--green-700);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-block textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
}
.section-block textarea:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px var(--green-100);
}

/* Comments */
.comments-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--gray-300);
}
.comments-section h4 {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.comment {
  background: var(--gray-50);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
}
.comment .author {
  font-weight: 600;
  color: var(--gray-700);
}
.comment .date {
  font-size: 12px;
  color: var(--gray-500);
}
.comment .text {
  margin-top: 6px;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.comment-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
}
.comment-form input:focus {
  outline: none;
  border-color: var(--green-600);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-content {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-500);
}
#modal-body { padding: 20px; }

/* Forms */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
}

/* Share link box */
.share-link-box {
  background: var(--gray-50);
  padding: 16px;
  border-radius: var(--radius);
  margin-top: 16px;
}
.share-link-box input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-family: monospace;
  font-size: 13px;
}

/* Preview pane */
.preview-pane {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
}

/* Scan results */
.scan-results {
  max-height: 400px;
  overflow-y: auto;
}
.scan-item {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
}
.scan-item:hover {
  background: var(--green-50);
}
.scan-item h4 {
  font-size: 14px;
  margin-bottom: 4px;
}
.scan-item .from {
  font-size: 12px;
  color: var(--gray-500);
}
.scan-item.selected {
  background: var(--green-100);
  border-left: 3px solid var(--green-700);
}

/* Keyword chips for Gmail search */
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.chip input {
  display: none;
}
.chip:hover {
  background: var(--gray-200);
}
.chip.selected {
  background: var(--green-100);
  color: var(--green-700);
  border-color: var(--green-600);
}

/* Scan results list */
.scan-results-list {
  max-height: 350px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.scan-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.15s;
}
.scan-item:last-child { border-bottom: none; }
.scan-item:hover { background: var(--gray-50); }
.scan-item.selected {
  background: var(--green-50);
}
.scan-item-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}
.scan-item.selected .scan-item-checkbox {
  background: var(--green-600);
  border-color: var(--green-600);
}
.scan-item.selected .scan-item-checkbox::after {
  content: '✓';
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}
.scan-item-content {
  flex: 1;
  min-width: 0;
}
.scan-item-content strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}
.scan-item-content .from {
  font-size: 12px;
  color: var(--gray-500);
}
.scan-item-content .snippet {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Comments panel in editor */
.comments-panel {
  background: var(--yellow-100);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.comments-panel h4 {
  font-size: 14px;
  color: var(--yellow-700);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.comment-card {
  background: white;
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.comment-card:last-child { margin-bottom: 0; }
.comment-card .meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.comment-card .meta strong {
  color: var(--gray-700);
}
.comment-card .section-tag {
  display: inline-block;
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-left: 8px;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 2000;
  animation: slideIn 0.3s ease;
}
.toast.success { background: var(--green-700); }
.toast.error { background: var(--red-700); }

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

/* Responsive */
@media (max-width: 768px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .newsletter-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
