/* ============================================
   Router Web UI — CSS
   Reuses design tokens from style.css
   ============================================ */

/* --- Main layout --- */
.router-main {
  max-width: 1024px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 40px) 24px 60px;
}

.router-header {
  margin-bottom: 36px;
}

.router-sub {
  font-size: 17px;
  color: var(--gray);
  line-height: 1.6;
}

/* --- Version Toggle --- */
.version-toggle {
  display: flex;
  gap: 0;
  background: #f0f0f0;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 28px;
}

.version-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--gray);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s var(--ease-spring);
}

.version-btn:hover {
  color: var(--black);
}

.version-btn.active {
  background: var(--white);
  color: var(--black);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.version-btn.active[data-mode="v5"] {
  background: var(--black);
  color: var(--white);
}

.version-btn.active[data-mode="blueprint"] {
  background: linear-gradient(135deg, #1a1a1a 0%, #444 100%);
  color: var(--white);
}

.version-btn-icon {
  display: flex;
  align-items: center;
}

/* --- v5 Options Bar --- */
.v5-options-bar {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 28px;
}

.v5-options-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.v5-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  user-select: none;
}

.v5-opt input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #fff;
  cursor: pointer;
}

.v5-opt select {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}

@media (max-width: 734px) {
  .version-toggle {
    margin-bottom: 20px;
  }

  .version-btn {
    padding: 10px 12px;
    font-size: 13px;
    gap: 6px;
  }

  .v5-options-bar {
    padding: 12px 16px;
  }

  .v5-options-inner {
    gap: 12px 20px;
  }
}

/* --- How It Works Section --- */
.how-it-works {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 40px;
}

.how-it-works h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
  color: var(--black);
}

.steps {
  display: flex;
  gap: 24px;
  justify-content: space-between;
}

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.step-num {
  width: 48px;
  height: 48px;
  background: var(--black);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.step p {
  font-size: 14px;
  color: var(--gray);
  line-height: 1.5;
}

@media (max-width: 734px) {
  .steps {
    flex-direction: column;
    gap: 20px;
  }

  .how-it-works {
    padding: 24px 20px;
  }
}

/* --- Advanced Settings (details element) --- */
.advanced-settings {
  background: var(--light-bg);
  border-radius: 16px;
  margin-top: 32px;
  margin-bottom: 40px;
  padding: 0;
  border: none;
  scroll-margin-top: calc(var(--nav-height) + 16px);
}

.advanced-settings summary {
  padding: 16px 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray);
  list-style: none;
  user-select: none;
}

.advanced-settings summary::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--gray);
  border-bottom: 2px solid var(--gray);
  transform: rotate(-45deg);
  margin-left: 8px;
  transition: transform 0.4s var(--ease-in-out-quart);
  vertical-align: middle;
}

.advanced-settings[open] summary::after {
  transform: rotate(45deg);
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-settings[open] summary {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.advanced-settings .config-body {
  overflow: hidden;
  transition: height 0.45s var(--ease-in-out-quart), opacity 0.45s var(--ease-in-out-quart);
  opacity: 1;
}

.advanced-settings .config-body.collapsing {
  opacity: 0;
}

/* --- Config Panel --- */
.config-panel {
  background: var(--light-bg);
  border-radius: 16px;
  margin-bottom: 32px;
  overflow: hidden;
}

.config-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 24px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--black);
}

.config-arrow {
  font-size: 12px;
  transition: transform 0.4s var(--ease-spring);
  color: var(--gray);
}

.config-arrow.open {
  transform: rotate(180deg);
}

.config-body {
  padding: 0 24px 24px;
  display: none;
}

.config-body.open,
.advanced-settings[open] .config-body {
  display: block;
}

.config-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-field-wide {
  flex: 1;
  min-width: 200px;
}

.config-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Form elements --- */
select,
input[type="text"] {
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: var(--white);
  color: var(--black);
  outline: none;
  transition: border-color 0.4s var(--ease-spring);
}

select:focus,
input[type="text"]:focus {
  border-color: var(--black);
}

select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2386868b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

input[type="text"] {
  width: 80px;
}

/* --- Checkboxes grid --- */
.options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 16px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--black);
  cursor: pointer;
  user-select: none;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--black);
  cursor: pointer;
}

/* --- Preflight badge --- */
.preflight-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 100px;
  background: rgba(0, 0, 0, 0.06);
}

.preflight-badge.clean {
  color: #333333;
}

.preflight-badge.dirty {
  color: #666666;
}

/* --- Buttons --- */
.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  transition: background 0.4s var(--ease-spring), border-color 0.4s var(--ease-spring);
  white-space: nowrap;
}

.btn:hover {
  background: var(--light-bg);
  border-color: rgba(0, 0, 0, 0.2);
}

.btn:active {
  transform: scale(0.96);
  transition-duration: 0.1s;
}

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

.btn-primary:hover {
  background: #333333;
  border-color: #333333;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-large {
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 700;
}

.btn-icon {
  font-size: 11px;
  margin-right: 4px;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* --- Textarea --- */
.area-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--black);
}

textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  background: var(--white);
  color: var(--black);
  resize: vertical;
  outline: none;
  transition: border-color 0.4s var(--ease-spring);
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--black);
}

/* --- Input Section --- */
.input-section {
  margin-bottom: 32px;
}

/* --- Output Section --- */
.output-section {
  margin-bottom: 32px;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ticket-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-selector label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
}

.ticket-selector select {
  min-width: 60px;
}

.output-display {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 20px;
  min-height: 320px;
  max-height: 600px;
  overflow-y: auto;
}

.output-display pre {
  font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

.output-display pre .ko-summary-line {
  color: #7eb8ff;
  font-style: italic;
  -webkit-user-select: none;
  user-select: none;
  opacity: 0.85;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--black);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease-out-quart), transform 0.4s var(--ease-out-quart), visibility 0.4s var(--ease-out-quart);
  z-index: 2000;
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* --- Loading overlay --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-overlay p {
  color: var(--white);
  font-size: 16px;
  font-weight: 500;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 734px) {
  .router-main {
    padding: calc(var(--nav-height) + 24px) 16px 40px;
  }

  .config-toggle {
    padding: 14px 16px;
  }

  .config-body {
    padding: 0 16px 16px;
  }

  .config-row {
    flex-direction: column;
    gap: 12px;
  }

  .config-field-wide {
    min-width: 100%;
  }

  select,
  input[type="text"] {
    width: 100%;
  }

  .options-grid {
    gap: 6px 16px;
  }

  .output-display {
    min-height: 200px;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn-row .btn {
    width: 100%;
    text-align: center;
  }

  .output-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ============================================
   Easy Mode
   ============================================ */

/* --- Toggle Button --- */
.output-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.easy-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 100px;
  background: var(--white);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  transition: all 0.4s var(--ease-spring);
  user-select: none;
}

.easy-toggle:hover {
  border-color: rgba(0, 0, 0, 0.25);
  color: var(--black);
}

.easy-toggle.active {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.easy-toggle-track {
  position: relative;
  width: 32px;
  height: 18px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 9px;
  transition: background 0.4s var(--ease-spring);
}

.easy-toggle.active .easy-toggle-track {
  background: rgba(255, 255, 255, 0.3);
}

.easy-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 0.4s var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.easy-toggle.active .easy-toggle-thumb {
  transform: translateX(14px);
}

/* --- Easy View Container --- */
.easy-view {
  border-radius: 16px;
  background: #f8f9fa;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 24px;
  min-height: 320px;
}

.easy-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  color: var(--gray);
  text-align: center;
  gap: 16px;
}

.easy-placeholder svg {
  opacity: 0.3;
}

.easy-placeholder p {
  font-size: 14px;
  line-height: 1.5;
  max-width: 300px;
}

/* --- Easy Cards --- */
.easy-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.easy-card {
  background: var(--white);
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: box-shadow 0.4s var(--ease-spring), transform 0.4s var(--ease-spring);
}

.easy-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.easy-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.easy-card-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.easy-card-letter {
  width: 32px;
  height: 32px;
  background: var(--black);
  color: var(--white);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.easy-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--black);
  line-height: 1.3;
}

.easy-card-model {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--gray);
  white-space: nowrap;
  flex-shrink: 0;
}

.easy-card-body {
  padding: 16px 20px;
}

.easy-card-ko {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #3355aa;
  font-weight: 500;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
  border-left: 3px solid #5577cc;
}

.easy-card-prompt-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.easy-card-prompt {
  background: #f5f5f7;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--black);
  font-family: var(--font);
  word-break: break-word;
}

.easy-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 16px;
}

.easy-card-next {
  font-size: 12px;
  color: var(--gray);
  display: flex;
  align-items: center;
  gap: 4px;
}

.easy-card-next svg {
  opacity: 0.5;
}

.easy-card-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s var(--ease-spring);
}

.easy-card-copy:hover {
  background: #333;
}

.easy-card-copy:active {
  transform: scale(0.96);
  transition-duration: 0.1s;
}

.easy-card-copy.copied {
  background: #16a34a;
}

.easy-card-copy svg {
  width: 14px;
  height: 14px;
}

/* --- Easy View Responsive --- */
@media (max-width: 734px) {
  .easy-view {
    padding: 16px;
    min-height: 200px;
  }

  .easy-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 16px 10px;
  }

  .easy-card-body {
    padding: 12px 16px;
  }

  .easy-card-footer {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    padding: 10px 16px 14px;
  }

  .easy-card-copy {
    justify-content: center;
    width: 100%;
  }

  .output-header-right {
    gap: 8px;
  }

  .output-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .output-header-right {
    width: 100%;
    justify-content: space-between;
  }
}

/* --- Scrollbar --- */
.output-display::-webkit-scrollbar {
  width: 6px;
}

.output-display::-webkit-scrollbar-track {
  background: transparent;
}

.output-display::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.output-display::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}
