/* ── fitting.css ─────────────────────────────────── */

.fitting-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
  min-height: calc(100vh - 72px);
}

/* ── Header ── */
.fitting-header {
  margin-bottom: 24px;
}

.fitting-header h1 {
  font-family: "Rajdhani", "Noto Sans KR", sans-serif;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--amber);
}

#fitting-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Config section ── */
.fitting-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

/* ── Ship selector ── */
.ship-selector {
  position: relative;
}

.ship-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.875rem;
}

.ship-info strong {
  color: var(--text);
}

.ship-manufacturer {
  color: var(--muted);
}

.ship-size {
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--panel-light);
  color: var(--cyan);
}

/* ── Ship dropdown ── */
.ship-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 10;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  margin-top: 4px;
  padding: 4px 0;
  box-shadow: var(--shadow);
}

.ship-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.8125rem;
  transition: background 0.12s;
}

.ship-option:hover,
.ship-option.highlighted {
  background: var(--panel-light);
}

.ship-option-name {
  color: var(--text);
  font-weight: 500;
}

.ship-option-maker {
  color: var(--muted);
  font-size: 0.75rem;
}

/* ── Purpose chips ── */
.purpose-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.purpose-chip {
  padding: 6px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.purpose-chip:hover {
  border-color: var(--amber);
  color: var(--text);
}

.purpose-chip.active {
  background: var(--amber);
  border-color: var(--amber);
  color: #071017;
  font-weight: 600;
}

/* ── Config row (shop-only + budget) ── */
.config-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.budget-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.budget-label input {
  width: 160px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 0.2s;
}

.budget-label input:focus {
  border-color: var(--amber);
}

/* ── Buttons ── */
.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  padding: 8px 24px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--amber);
  border: 1px solid var(--amber);
  color: #071017;
}

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

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}

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

/* ── States ── */
.fitting-state {
  text-align: center;
  padding: 64px 16px;
  color: var(--muted);
}

.fitting-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 1.0625rem;
}

.fitting-state p {
  margin: 0;
  font-size: 0.875rem;
}

/* ── Slot section ── */
.slot-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slot-section h2 {
  font-family: "Rajdhani", "Noto Sans KR", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

/* ── Slot table ── */
.slot-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.slot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.slot-table thead {
  background: var(--panel-light);
}

.slot-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.slot-table td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.slot-table tbody tr:last-child td {
  border-bottom: none;
}

/* Fixed slot row */
.slot-table tr.fixed td {
  background: rgba(143, 169, 179, 0.06);
  color: var(--muted);
}

/* Size badge */
.size-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--panel-light);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--cyan);
  white-space: nowrap;
}

/* Item cells */
.item-name {
  font-weight: 500;
  white-space: nowrap;
}

.item-name.default-item {
  color: var(--muted);
}

/* Recommended item — clickable */
.recommend-link {
  color: var(--amber);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.12s;
}

.recommend-link:hover {
  color: var(--amber-bright);
  text-decoration: underline;
}

/* Reason cell */
.reason-text {
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 220px;
  line-height: 1.4;
}

/* Price / source badges */
.price-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.price-value {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--amber-bright);
}

.price-zero {
  color: var(--muted);
  font-weight: 400;
}

.shop-links {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.shop-link {
  font-size: 0.625rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-light);
  color: var(--cyan);
  cursor: pointer;
  transition: background 0.12s;
}

.shop-link:hover {
  background: var(--line-strong);
}

.source-badge {
  display: inline-block;
  font-size: 0.625rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.source-wikelo {
  background: rgba(240, 163, 26, 0.12);
  color: var(--amber);
}

.source-mission {
  background: rgba(115, 213, 162, 0.12);
  color: var(--green);
}

.source-craft {
  background: rgba(97, 210, 242, 0.12);
  color: var(--cyan);
}

/* ── Summary bar ── */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  align-items: center;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 0.6875rem;
  color: var(--muted);
  font-weight: 500;
}

.summary-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  font-family: "Rajdhani", "Noto Sans KR", sans-serif;
}

.power-summary {
  width: 100%;
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 8px 0;
  color: var(--text);
}

.power-summary .power-line {
  display: inline;
  margin-right: 8px;
}

.summary-note {
  width: 100%;
  font-size: 0.6875rem;
  color: var(--muted);
  font-style: italic;
}

.summary-price-info {
  width: 100%;
  font-size: 0.6875rem;
  color: var(--muted);
}

/* ── Candidate dialog ── */
.candidate-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  max-width: 480px;
  width: calc(100vw - 32px);
  max-height: 80vh;
  overflow-y: auto;
  padding: 0;
  box-shadow: var(--shadow);
}

.candidate-dialog::backdrop {
  background: rgba(5, 11, 16, 0.7);
}

.candidate-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

.candidate-head h2 {
  font-family: "Rajdhani", "Noto Sans KR", sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: var(--amber);
}

.candidate-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.125rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.candidate-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.candidate-body {
  padding: 12px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.candidate-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.candidate-item:hover {
  border-color: var(--line-strong);
  background: var(--panel-light);
}

.candidate-item.selected {
  border-color: var(--amber);
  background: rgba(240, 163, 26, 0.06);
}

.candidate-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.candidate-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.candidate-detail {
  font-size: 0.6875rem;
  color: var(--muted);
}

.candidate-score {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--amber);
  font-family: "Rajdhani", "Noto Sans KR", sans-serif;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .fitting-main {
    padding: 16px 12px;
  }

  .fitting-header h1 {
    font-size: 1.5rem;
  }

  .purpose-chips {
    gap: 6px;
  }

  .purpose-chip {
    padding: 5px 12px;
    font-size: 0.75rem;
  }

  .summary-bar {
    gap: 10px;
    padding: 12px;
  }

  .summary-item {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
  }

  .slot-table th,
  .slot-table td {
    padding: 8px 6px;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .config-row {
    flex-direction: column;
    align-items: stretch;
  }

  .budget-label input {
    width: 100%;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons button {
    width: 100%;
  }
}

/* ── 구하는 방법 칩 (여러 개 선택) ── */
.acq-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.acq-chip {
  padding: 6px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.acq-chip:hover:not(:disabled) {
  border-color: var(--cyan);
  color: var(--text);
}

.acq-chip.active {
  border-color: var(--cyan);
  background: var(--cyan);
  color: var(--bg);
  font-weight: 700;
}

.acq-chip.active::before {
  content: "✓ ";
}

.acq-chip:disabled,
.acq-chip[aria-disabled="true"] {
  border-style: dashed;
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── 왼쪽 함선 카드 ── */
.fitting-config {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.fitting-options {
  min-width: 0;
}

.ship-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  overflow: hidden;
}

.ship-card-media {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: var(--panel-light);
}

.ship-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ship-card-empty {
  margin: 0;
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.ship-card-body {
  display: grid;
  gap: 4px;
  padding: 12px 14px 14px;
}

.ship-card-body strong {
  font-size: 1.25rem;
  color: var(--amber-bright);
}

#ship-card-meta {
  color: var(--muted);
  font-size: 0.8125rem;
}

#ship-card-link {
  color: var(--cyan);
  font-size: 0.8125rem;
  text-decoration: none;
}

@media (max-width: 760px) {
  .fitting-config {
    grid-template-columns: minmax(0, 1fr);
  }
}

.fitting-options {
  display: grid;
  gap: 14px;
  align-content: start;
}

/* ── 함선 목록: 개수·제조사 묶음 ── */
.ship-dropdown {
  max-height: min(60vh, 460px);
}

.ship-dropdown-count {
  padding: 8px 14px 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.ship-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 6px 14px;
  background: var(--panel-light);
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
