/* =====================================================
   PHASE 1: PARALLEL LAYOUT STYLES
   ===================================================== */

/* Phase 1 Loading Screen */
.phase-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 40px 20px;
}

.loading-content {
  text-align: center;
  max-width: 400px;
}

.loading-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.loading-content h2 {
  margin: 0 0 10px 0;
  font-size: 1.8rem;
}

.loading-content > p {
  color: var(--text-secondary);
  margin: 0 0 30px 0;
}

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

.loading-hint {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  opacity: 0.8;
}

/* Two-column layout */
.phase1-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  align-items: start;
}

@media (max-width: 1024px) {
  .phase1-layout {
    grid-template-columns: 1fr;
  }
}

/* Feedback Panel (Left Sidebar) */
.feedback-panel {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

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

.feedback-header h3 {
  margin: 0;
  font-size: 1rem;
}

.revisions-counter {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.revisions-counter strong {
  color: var(--accent);
}

.feedback-content {
  padding: 20px;
}

.feedback-empty {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 40px 20px;
}

.feedback-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.feedback-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.feedback-element-tag {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.feedback-item p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.feedback-timestamp {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* Elements Grid */
.elements-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Element Card */
.element-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.element-card:hover {
  border-color: var(--accent);
}

.element-card.completed {
  border-color: var(--success);
}

.element-card.active {
  box-shadow: 0 0 0 2px var(--accent);
}

/* Element Header */
.element-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.element-header h3 {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
}

.info-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  opacity: 0.6;
  transition: opacity 0.2s, background 0.2s;
}

.info-btn:hover {
  opacity: 1;
  background: var(--hover);
}

.element-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.element-status.pending {
  background: var(--warning-bg);
  color: var(--warning);
}

.element-status.complete {
  background: var(--success-bg);
  color: var(--success);
}

/* Element Body */
.element-body {
  padding: 20px;
}

/* Element Field */
.element-field {
  padding: 4px 0;
}

.element-field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.edit-hint {
  font-weight: 400;
  font-style: italic;
  opacity: 0.7;
}

.field-textarea {
  width: 100%;
  min-height: 100px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s;
}

.field-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field-display {
  padding: 16px;
  background: var(--background);
  border: 2px solid var(--border);
  border-radius: 10px;
  line-height: 1.6;
}

/* Editable fields within displays */
.editable-field, .editable-content, .list-item {
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.editable-field:hover, .editable-content:hover, .list-item:hover {
  background: rgba(99, 102, 241, 0.1);
}

.editable-field:focus, .editable-content:focus, .list-item:focus {
  outline: none;
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 0 2px var(--accent);
}

/* Buttons */
.ai-btn {
  padding: 10px 18px;
  margin-top: 12px;
  margin-right: 10px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ai-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.save-btn {
  padding: 10px 18px;
  margin-top: 12px;
}

/* Generating spinner */
.generating {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  color: var(--text-secondary);
}

.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Explanation box */
.explanation-box {
  margin-top: 12px;
  padding: 12px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 8px;
  font-size: 0.9rem;
  border-left: 3px solid var(--accent);
}

.explanation-box strong {
  color: var(--accent);
}

/* Confirm button */
.confirm-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  font-size: 1rem;
}

/* Error message */
.error-msg {
  padding: 16px;
  color: var(--error, #ef4444);
  text-align: center;
}

.error-msg button {
  margin-left: 10px;
  padding: 6px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* Suggest Button */
.suggest-btn {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark, #4a6cf7));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.suggest-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.suggest-btn.loading {
  background: var(--text-secondary);
  pointer-events: none;
}

.suggest-btn.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

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

/* Suggestion Area */
.suggestion-area {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.suggestion-area label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.edit-hint {
  font-weight: 400;
  font-style: italic;
  opacity: 0.7;
}

.suggested-value {
  width: 100%;
  padding: 16px;
  background: var(--background);
  border: 2px solid var(--accent);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 80px;
}

.suggested-value.small {
  min-height: 60px;
}

.suggested-value:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Explanation Box */
.explanation {
  margin-top: 16px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(99, 102, 241, 0.1));
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.explanation label {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}

.explanation p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Element Actions */
.element-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.element-actions button {
  flex: 1;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.keep-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.keep-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.accept-btn {
  background: var(--accent);
  border: none;
  color: white;
}

.accept-btn:hover {
  background: var(--accent-dark, #4a6cf7);
}

/* Tone display styles */
.tone-statement {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.tone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 12px 0;
}

.tone-col ul {
  margin: 8px 0;
  padding-left: 20px;
}

.tone-col li {
  margin: 4px 0;
}

.tone-refs {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Theme display styles */
.theme-seed, .theme-question {
  margin-bottom: 10px;
}

.theme-opposition {
  margin-top: 12px;
  text-align: center;
  font-size: 1.1rem;
}

.theme-opposition .vs {
  color: var(--accent);
  font-weight: 700;
  margin: 0 10px;
}

/* Scope display styles */
.scope-type {
  margin-bottom: 10px;
}

.scope-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--accent);
  color: white;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.scope-statement {
  margin: 12px 0;
}

.scope-details {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Feedback panel item styles */
.feedback-item {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.feedback-item:last-child {
  border-bottom: none;
}

.feedback-label {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.feedback-item p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Tone-specific styles */
.tone-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}

.tone-column {
  background: var(--background);
  padding: 16px;
  border-radius: 8px;
}

.tone-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.tone-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.tone-list li:last-child {
  border-bottom: none;
}

.tone-list li .remove-item {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.tone-list li:hover .remove-item {
  opacity: 1;
}

.add-item {
  width: 100%;
  padding: 8px 12px;
  margin-top: 8px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.add-item:focus {
  border-style: solid;
  border-color: var(--accent);
  outline: none;
}

.reference-films {
  margin-top: 16px;
}

#suggested-tone-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ref-film {
  background: var(--background);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme-specific styles */
.theme-fields {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.theme-field label {
  margin-bottom: 4px;
}

.opposition-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  background: var(--background);
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 500;
}

.opposition-display .vs {
  color: var(--accent);
  font-weight: 700;
}

/* Scope-specific styles */
.scope-badges {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.scope-badge {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

.scope-badge.selectable {
  cursor: pointer;
  background: var(--background);
  border: 2px solid var(--border);
  transition: all 0.2s;
}

.scope-badge.selectable:hover {
  border-color: var(--accent);
}

.scope-badge.selectable.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.scope-constraints {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 16px 0;
}

@media (max-width: 768px) {
  .scope-constraints {
    grid-template-columns: 1fr;
  }
}

.constraint {
  display: flex;
  flex-direction: column;
}

.constraint label {
  margin-bottom: 6px;
}

.constraint input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  font-size: 0.95rem;
}

.constraint input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Phase Completion Card */
.phase-completion-card {
  background: linear-gradient(135deg, var(--surface), rgba(99, 102, 241, 0.05));
  border-radius: 12px;
  border: 2px solid var(--border);
  padding: 24px;
  margin-top: 20px;
}

.phase-completion-card h3 {
  margin: 0 0 20px 0;
}

.completion-checklist {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .completion-checklist {
    grid-template-columns: 1fr;
  }
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--background);
  border-radius: 8px;
  cursor: default;
}

.checklist-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
}

.checklist-item input:checked + span {
  color: var(--success);
}

.completion-actions {
  display: flex;
  gap: 16px;
}

.completion-actions button {
  flex: 1;
  padding: 14px 24px;
  font-size: 1rem;
}

/* Info Modal */
.info-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.info-modal-content {
  background: var(--surface, #1a1a2e);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  position: relative;
  animation: scaleIn 0.2s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border, #333);
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.info-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.info-close:hover {
  color: var(--text);
}

.info-modal-content h3 {
  margin: 0 0 16px 0;
}

.info-modal-content > p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.info-example {
  background: var(--background);
  padding: 16px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.info-example label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.info-example p {
  margin: 0;
  font-style: italic;
  line-height: 1.6;
}

/* Mobile adjustments */
@media (max-width: 1024px) {
  .feedback-panel {
    position: static;
    max-height: none;
    order: -1;
  }
  
  .tone-lists {
    grid-template-columns: 1fr;
  }
}
