/* Add Pitch System Wizard - 3-screen wizard for defining new pitch systems */

.add-system-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  animation: addSystemFadeIn 0.2s ease-out forwards;
}

@keyframes addSystemFadeIn {
  to { opacity: 1; }
}

.add-system-dialog {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 520px;
  max-width: 92vw;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9);
  animation: addSystemSlideUp 0.2s ease-out forwards;
  display: flex;
  flex-direction: column;
}

@keyframes addSystemSlideUp {
  to { transform: scale(1); }
}

/* Header */
.add-system-header {
  position: relative;
  padding: 24px 24px 16px;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}

.add-system-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #1f2937;
}

.add-system-header-with-back {
  text-align: center;
}

.add-system-step {
  margin-top: 4px;
  font-size: 12px;
  color: #9ca3af;
}

.add-system-back-btn {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  color: #6b7280;
  font-size: 18px;
}

.add-system-back-btn:hover {
  background: #f3f4f6;
  color: #1f2937;
}

/* Body */
.add-system-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Fields */
.add-system-field {
  margin-bottom: 16px;
}

.add-system-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.add-system-hint {
  font-weight: 400;
  color: #9ca3af;
}

.add-system-field input[type="text"],
.add-system-field input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #1f2937;
  background: #f9fafb;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.add-system-field input:focus {
  outline: none;
  border-color: #6366f1;
  background: white;
}

.add-system-input-error {
  border-color: #ef4444 !important;
  animation: addSystemShake 0.3s ease;
}

@keyframes addSystemShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.add-system-field-note {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
  min-height: 16px;
}

.add-system-field-note.error {
  color: #ef4444;
}

.add-system-row {
  display: flex;
  gap: 12px;
}

.add-system-field-half {
  flex: 1;
}

/* Option group (role, profile, spellings) */
.add-system-option-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.add-system-option {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s;
}

.add-system-option:hover {
  border-color: #6366f1;
  color: #4f46e5;
}

.add-system-option.active {
  background: #eef2ff;
  border-color: #6366f1;
  color: #4f46e5;
  font-weight: 500;
}

/* Slider */
.add-system-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.add-system-slider-row input[type="range"] {
  flex: 1;
  accent-color: #6366f1;
}

.add-system-slider-value {
  font-size: 18px;
  font-weight: 600;
  color: #4f46e5;
  min-width: 28px;
  text-align: center;
}

/* Character grid */
.add-system-char-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.add-system-char-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-system-char-degree {
  font-size: 12px;
  color: #9ca3af;
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}

.add-system-char-input {
  width: 60px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: monospace;
  text-align: center;
  flex-shrink: 0;
}

.add-system-char-label {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  color: #6b7280;
}

/* Toggles */
.add-system-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.add-system-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
}

.add-system-toggle input[type="checkbox"] {
  accent-color: #6366f1;
}

/* Preview grid */
.add-system-preview-grid {
  overflow-x: auto;
}

.add-system-preview-table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}

.add-system-preview-table th,
.add-system-preview-table td {
  border: 1px solid #e5e7eb;
  padding: 4px 8px;
  text-align: center;
}

.add-system-preview-table th {
  background: #f9fafb;
  font-weight: 500;
  color: #6b7280;
  font-size: 11px;
}

.add-system-preview-char {
  font-weight: 600;
  font-family: monospace;
  background: #f0f0ff;
}

.add-system-preview-empty {
  color: #9ca3af;
  font-style: italic;
  padding: 12px;
  text-align: center;
}

/* Screen 3: patterns & collisions */
.add-system-pattern-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.add-system-pattern {
  font-family: monospace;
  font-size: 12px;
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: 4px;
  color: #374151;
}

.add-system-collision-panel {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.add-system-collision-title {
  font-weight: 600;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 6px;
}

.add-system-collision-item {
  font-size: 12px;
  color: #78350f;
  padding: 2px 0;
}

.add-system-explicit-hint {
  font-size: 13px;
  color: #6b7280;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
}

.add-system-explicit-hint code {
  background: #e5e7eb;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

/* YAML output */
.add-system-yaml {
  width: 100%;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #1f2937;
  background: #f9fafb;
  resize: vertical;
  box-sizing: border-box;
}

/* Footer */
.add-system-footer {
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
}

.add-system-footer-output {
  align-items: center;
}

.add-system-footer-right {
  display: flex;
  gap: 8px;
}

.add-system-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.add-system-btn-cancel {
  background: #f3f4f6;
  color: #4b5563;
}

.add-system-btn-cancel:hover {
  background: #e5e7eb;
}

.add-system-btn-secondary {
  background: #eef2ff;
  color: #4f46e5;
}

.add-system-btn-secondary:hover {
  background: #e0e7ff;
}

.add-system-btn-next {
  background: #4f46e5;
  color: white;
}

.add-system-btn-next:hover {
  background: #4338ca;
}

/* Instructions below footer */
.add-system-instructions {
  padding: 12px 24px;
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  border-top: 1px solid #f3f4f6;
}

.add-system-instructions code {
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}

/* ── Dark Mode ─────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  .add-system-dialog {
    background: #1f2937;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  }

  .add-system-header {
    border-bottom-color: #374151;
  }

  .add-system-header h2 {
    color: #f3f4f6;
  }

  .add-system-step {
    color: #6b7280;
  }

  .add-system-field label {
    color: #d1d5db;
  }

  .add-system-hint {
    color: #6b7280;
  }

  .add-system-field input[type="text"],
  .add-system-field input[type="number"] {
    background: #111827;
    border-color: #374151;
    color: #f3f4f6;
  }

  .add-system-field input:focus {
    border-color: #818cf8;
    background: #1f2937;
  }

  .add-system-option {
    background: #111827;
    border-color: #374151;
    color: #d1d5db;
  }

  .add-system-option:hover {
    border-color: #818cf8;
    color: #a5b4fc;
  }

  .add-system-option.active {
    background: #312e81;
    border-color: #818cf8;
    color: #a5b4fc;
  }

  .add-system-char-input {
    background: #111827;
    border-color: #374151;
    color: #f3f4f6;
  }

  .add-system-char-label {
    background: #111827;
    border-color: #374151;
    color: #9ca3af;
  }

  .add-system-toggle {
    color: #d1d5db;
  }

  .add-system-preview-table th,
  .add-system-preview-table td {
    border-color: #374151;
  }

  .add-system-preview-table th {
    background: #111827;
    color: #9ca3af;
  }

  .add-system-preview-char {
    background: #312e81;
  }

  .add-system-pattern {
    background: #374151;
    color: #d1d5db;
  }

  .add-system-collision-panel {
    background: #451a03;
    border-color: #92400e;
  }

  .add-system-collision-title {
    color: #fbbf24;
  }

  .add-system-collision-item {
    color: #fcd34d;
  }

  .add-system-yaml {
    background: #111827;
    border-color: #374151;
    color: #f3f4f6;
  }

  .add-system-footer {
    border-top-color: #374151;
  }

  .add-system-btn-cancel {
    background: #374151;
    color: #d1d5db;
  }

  .add-system-btn-cancel:hover {
    background: #4b5563;
  }

  .add-system-btn-secondary {
    background: #312e81;
    color: #a5b4fc;
  }

  .add-system-btn-secondary:hover {
    background: #3730a3;
  }

  .add-system-btn-next {
    background: #6366f1;
  }

  .add-system-btn-next:hover {
    background: #818cf8;
  }

  .add-system-instructions {
    color: #6b7280;
    border-top-color: #374151;
  }

  .add-system-instructions code {
    background: #374151;
  }

  .add-system-explicit-hint {
    background: #111827;
    color: #9ca3af;
  }

  .add-system-explicit-hint code {
    background: #374151;
  }

  .add-system-back-btn {
    color: #9ca3af;
  }

  .add-system-back-btn:hover {
    background: #374151;
    color: #f3f4f6;
  }
}

/* ── Mobile ────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
  .add-system-dialog {
    width: 100%;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .add-system-header {
    padding: 16px 16px 12px;
  }

  .add-system-body {
    padding: 16px;
  }

  .add-system-footer {
    padding: 12px 16px;
  }

  .add-system-row {
    flex-direction: column;
  }
}
