/* ==========================================================================
   Writing Test Styles
   ========================================================================== */

.writing-section {
  margin-bottom: var(--space-10);
}

.section-intro {
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* Grade Filter */
.grade-filter {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.grade-filter label {
  font-weight: 500;
}

.grade-filter select {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text);
  font-size: var(--text-base);
  cursor: pointer;
}

/* Prompt Grid */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
}

.prompt-card {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: all 0.2s ease;
}

.prompt-card:hover {
  border-color: var(--amber-400);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.prompt-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-3);
}

.prompt-type {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.prompt-type.argumentative {
  background: var(--indigo-100);
  color: var(--indigo-700);
}

.prompt-type.analytical {
  background: var(--sage-100);
  color: var(--sage-700);
}

.prompt-type.narrative {
  background: var(--amber-100);
  color: var(--amber-700);
}

.prompt-type.synthesis {
  background: var(--sky-100);
  color: var(--sky-600);
}

.prompt-difficulty {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.prompt-card h3 {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-2);
  color: var(--color-heading);
}

.prompt-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

.prompt-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.prompt-time {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.start-btn {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--amber-600);
}

/* Writing Interface */
.writing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.prompt-badge {
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  background: var(--amber-100);
  color: var(--amber-700);
  border-radius: var(--radius-full);
}

.prompt-display {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.prompt-display h2 {
  font-size: var(--text-xl);
  margin: 0 0 var(--space-4);
}

.prompt-text {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.prompt-instructions {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-3);
  background: var(--amber-50);
  border-radius: var(--radius-md);
}

/* Essay Editor */
.essay-editor {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

#essay-input {
  width: 100%;
  min-height: 400px;
  padding: var(--space-5);
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  resize: vertical;
}

#essay-input:focus {
  outline: none;
}

#essay-input::placeholder {
  color: var(--color-text-subtle);
}

/* Submit Section */
.submit-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.pricing-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.price-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.price {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-heading);
}

.price-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.price-note {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 300px;
}

#submit-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 450px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: none;
  border: none;
  font-size: var(--text-2xl);
  color: var(--color-text-muted);
  cursor: pointer;
}

.modal-content h2 {
  margin: 0 0 var(--space-2);
}

.modal-content > p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.payment-summary {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
}

.summary-row.total {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  font-weight: 600;
}

.form-group {
  margin-bottom: var(--space-5);
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-2);
}

#card-element {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.error-message {
  color: #dc2626;
  font-size: var(--text-sm);
  margin-top: var(--space-2);
}

.secure-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-4);
}

/* Loading State */
.loading-container {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--color-border);
  border-top-color: var(--amber-500);
  border-radius: 50%;
  margin: 0 auto var(--space-6);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-container h2 {
  margin: 0 0 var(--space-2);
}

.loading-container > p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 300px;
  margin: 0 auto;
  text-align: left;
}

.step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
}

.step.active {
  color: var(--sage-600);
}

.step.active .step-icon {
  color: var(--sage-500);
}

.step-icon {
  width: 20px;
  text-align: center;
}

/* Results */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
}

.score-overview {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-8);
  padding: var(--space-6);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.overall-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-right: var(--space-8);
  border-right: 1px solid var(--color-border);
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber-400) 0%, var(--amber-500) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
}

.score-value {
  font-size: var(--text-4xl);
  font-weight: 700;
  color: white;
}

.score-max {
  font-size: var(--text-lg);
  color: rgba(255, 255, 255, 0.8);
}

.score-label {
  font-weight: 500;
  color: var(--color-text-muted);
}

.score-breakdown {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
}

.score-category {
  display: grid;
  grid-template-columns: 180px 1fr 60px;
  align-items: center;
  gap: var(--space-3);
}

.category-name {
  font-size: var(--text-sm);
  font-weight: 500;
}

.score-bar {
  height: 8px;
  background: var(--color-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-400), var(--amber-500));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.category-score {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: right;
}

/* Feedback Cards */
.feedback-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.feedback-card {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.feedback-card h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  font-size: var(--text-lg);
}

.feedback-card.strengths h3 {
  color: var(--sage-600);
}

.feedback-card.improvements h3 {
  color: var(--amber-600);
}

.feedback-card ul {
  margin: 0;
  padding-left: var(--space-5);
}

.feedback-card li {
  margin-bottom: var(--space-2);
  line-height: 1.5;
}

/* Detailed Feedback */
.detailed-feedback {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}

.detailed-feedback h3 {
  margin: 0 0 var(--space-4);
}

#detailed-feedback-content {
  line-height: 1.7;
}

#detailed-feedback-content p {
  margin-bottom: var(--space-4);
}

/* Essay Review */
.essay-review {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.essay-review h3 {
  margin: 0 0 var(--space-4);
}

.essay-text {
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  line-height: 1.7;
  font-family: var(--font-body);
}

/* Error State */
.error-container {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}

.error-container svg {
  color: #dc2626;
  margin-bottom: var(--space-4);
}

.error-container h2 {
  margin: 0 0 var(--space-2);
}

.error-container p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* Dark Mode */
[data-theme="dark"] .prompt-card {
  background: var(--color-bg-elevated);
}

[data-theme="dark"] .prompt-type.argumentative {
  background: rgba(99, 102, 241, 0.2);
  color: var(--indigo-400);
}

[data-theme="dark"] .prompt-type.analytical {
  background: rgba(34, 197, 94, 0.2);
  color: var(--sage-400);
}

[data-theme="dark"] .prompt-type.narrative {
  background: rgba(251, 191, 36, 0.2);
  color: var(--amber-400);
}

[data-theme="dark"] .prompt-type.synthesis {
  background: rgba(14, 165, 233, 0.2);
  color: var(--sky-400);
}

[data-theme="dark"] .prompt-instructions {
  background: rgba(251, 191, 36, 0.1);
}

[data-theme="dark"] #essay-input {
  background: var(--color-bg-elevated);
  color: var(--color-text);
}

[data-theme="dark"] .modal-content {
  background: var(--color-bg-elevated);
}

[data-theme="dark"] #card-element {
  background: var(--color-bg);
}

[data-theme="dark"] .score-overview,
[data-theme="dark"] .feedback-card,
[data-theme="dark"] .detailed-feedback,
[data-theme="dark"] .essay-review,
[data-theme="dark"] .submit-section,
[data-theme="dark"] .prompt-display,
[data-theme="dark"] .essay-editor {
  background: var(--color-bg-elevated);
}

/* Responsive */
@media (max-width: 768px) {
  .submit-section {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }

  .pricing-info {
    flex-direction: column;
  }

  .score-overview {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .overall-score {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding-right: 0;
    padding-bottom: var(--space-6);
    margin-bottom: var(--space-6);
  }

  .score-category {
    grid-template-columns: 1fr 60px;
  }

  .category-name {
    grid-column: 1 / -1;
    margin-bottom: var(--space-1);
  }

  .feedback-sections {
    grid-template-columns: 1fr;
  }
}
