:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #1f2937;
  --bg-color: #f3f4f6;
  --panel-bg: #ffffff;
  --border-color: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --highlight-bg: rgba(254, 226, 226, 0.5); /* Light red for error highlights */
  --highlight-active: rgba(254, 202, 202, 0.8);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.header-actions {
  display: flex;
  gap: 1rem;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #10b981; /* Emerald green */
  color: white;
  border: 1px solid #059669;
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  background-color: #059669;
  box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.btn-secondary:disabled {
  background-color: #a7f3d0;
  border-color: #d1fae5;
  color: #064e3b;
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
}

.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 1rem;
  gap: 1rem;
}

.editor-panel, .review-panel {
  background-color: var(--panel-bg);
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel {
  flex: 3;
}

.review-panel {
  flex: 2;
  border-left: 1px solid var(--border-color);
}

/* Settings Panel */
.settings-panel {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background-color: #fafafa;
}

.settings-header {
  margin-bottom: 0.5rem;
}

.settings-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--secondary-color);
  margin: 0;
}

.model-selector {
  display: flex;
  background-color: #e5e7eb;
  padding: 0.25rem;
  border-radius: 0.5rem;
  gap: 0.25rem;
}

.model-option {
  position: relative;
  cursor: pointer;
  margin: 0;
}

.model-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.model-option span {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  border-radius: 0.375rem;
  transition: all 0.2s;
  user-select: none;
}

.model-option input[type="radio"]:checked + span {
  background-color: white;
  color: var(--primary-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.model-option input[type="radio"]:focus-visible + span {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.prompt-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
}

.prompt-textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* Document Reading Surface */
.document-wrapper {
  flex: 1;
  overflow-y: auto;
  background-color: #e5e7eb; /* Gray background to simulate desk */
  padding: 2rem;
}

.document-page {
  margin: 0 auto;
  background-color: white;
  width: 100%;
  max-width: 800px; /* A4-ish width */
  min-height: 1056px; /* A4 aspect ratio height minimum */
  padding: 4rem 3rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
  border-radius: 2px;
  font-family: "SimSun", "Songti SC", serif; /* Formal document font */
  font-size: 1.1rem;
  line-height: 1.8;
  color: #000;
  outline: none; /* Remove outline when editing */
}

/* Base mammoth styles for the document */
.document-page h1 { font-size: 2em; text-align: center; margin-bottom: 1.5em; }
.document-page h2 { font-size: 1.5em; margin-top: 1em; margin-bottom: 0.5em; }
.document-page p { margin-bottom: 1em; text-indent: 2em; } /* Standard Chinese indent */

/* Table styles for parsed Word documents */
.document-page table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.95em;
}

.document-page th, .document-page td {
  border: 1px solid #374151;
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

.document-page th {
  background-color: #f3f4f6;
  font-weight: 600;
}

/* AI Highlight span */
.highlight-error {
  background-color: var(--highlight-bg);
  cursor: pointer;
  border-radius: 2px;
  border-bottom: 2px dashed #dc2626;
  transition: background-color 0.2s;
}

.highlight-error:hover, .highlight-error.active {
  background-color: var(--highlight-active);
}

/* UI Suggestion Highlight Spans */
.highlight-del {
  color: #dc2626; /* Red 600 */
  text-decoration: line-through;
  background-color: #fef2f2; /* Red 50 */
  padding: 0 4px;
  border-radius: 2px;
  margin: 0 2px;
}

.highlight-ins {
  color: #16a34a; /* Green 600 */
  text-decoration: underline;
  text-decoration-thickness: 2px;
  background-color: #f0fdf4; /* Green 50 */
  padding: 0 4px;
  border-radius: 2px;
  margin: 0 2px;
}

/* Review WorkBench */
.panel-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.badge {
  background-color: #fee2e2;
  color: #dc2626;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.cards-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 2rem;
}

/* Issue Card */
.issue-card {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1rem;
  background-color: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.issue-card:hover, .issue-card.active {
  border-color: var(--primary-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.issue-card.resolved {
  opacity: 0.6;
  pointer-events: none;
}

.issue-card .reason {
  font-size: 0.75rem;
  color: #dc2626;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.issue-card .original-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-bottom: 0.5rem;
}

.issue-card .suggestion {
  font-size: 1rem;
  color: var(--text-main);
  font-weight: 500;
  margin-bottom: 1rem;
  background-color: #f0fdf4;
  padding: 0.5rem;
  border-radius: 0.25rem;
  border-left: 3px solid #16a34a;
}

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

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-delete {
  background-color: #fef2f2;
  color: #ef4444;
  border: 1px solid #fecaca;
}
.btn-delete:hover {
  background-color: #fee2e2;
  border-color: #fca5a5;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

.btn-edit {
  background-color: #f0f9ff;
  color: #0ea5e9;
  border: 1px solid #bae6fd;
}
.btn-edit:hover {
  background-color: #e0f2fe;
  border-color: #7dd3fc;
  box-shadow: 0 2px 4px rgba(14, 165, 233, 0.1);
}
.btn-edit.btn-saving {
  background-color: #0ea5e9;
  color: white;
  border: 1px solid #0284c7;
  box-shadow: 0 2px 4px rgba(14, 165, 233, 0.2);
}

.btn-copy {
  background-color: #ffffff;
  color: #4b5563;
  border: 1px solid #d1d5db;
}
.btn-copy:hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
  color: #111827;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Loading Spinner */
.loader-spinner {
  border: 4px solid rgba(79, 70, 229, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
