/* css/components.css — 재사용 컴포넌트 */

/* ===== 버튼 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-sm);
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); font-weight: 600; font-size: 0.86rem;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--bg-panel-2); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f7ae8; }
.btn-danger { background: transparent; border-color: var(--loss); color: var(--loss); }
.btn-danger:hover { background: rgba(229, 72, 77, 0.12); }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 16px; font-size: 0.98rem; }
.btn-xs { padding: 4px 8px; font-size: 0.76rem; }
.btn-inline { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; color: var(--text-dim); border: 1px solid transparent;
}
.icon-btn:hover { background: var(--bg-panel-2); color: var(--text); }

/* ===== 패널 ===== */
.panel {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.panel h3 { font-size: 1rem; margin-bottom: var(--sp-3); }

/* ===== 텍스트 유틸 ===== */
.muted { color: var(--text-dim); }
.small { font-size: 0.8rem; }
.profit { color: var(--profit); }
.low { color: var(--low); }
.loss { color: var(--loss); }
.warn-text { color: var(--low); font-size: 0.85rem; }
.disclaimer {
  font-size: 0.76rem; color: var(--text-mute);
  background: var(--bg-input); border: 1px dashed var(--border);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); margin-top: var(--sp-2);
}

/* ===== 칩 ===== */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.chip-neutral { background: rgba(100, 116, 139, 0.18); color: var(--text-dim); border-color: var(--neutral); }
.chip-profit { background: rgba(63, 178, 127, 0.16); color: var(--profit); border-color: var(--profit); }
.chip-low { background: rgba(240, 165, 0, 0.16); color: var(--low); border-color: var(--low); }
.chip-loss { background: rgba(229, 72, 77, 0.16); color: var(--loss); border-color: var(--loss); }

/* ===== 폼 ===== */
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 0.82rem; color: var(--text-dim); font-weight: 600; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.input {
  width: 100%; padding: 9px 11px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.input:focus { border-color: var(--accent); outline: none; }
select.input { cursor: pointer; }
.color-input { height: 40px; padding: 3px; cursor: pointer; }
.color-swatches { display: flex; gap: 6px; margin-top: 6px; }
.color-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid transparent; transition: transform 0.1s;
}
.color-swatch.selected { border-color: var(--text); transform: scale(1.12); }

/* ===== 난이도 카드 ===== */
.difficulty-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.diff-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--sp-3); border: 1px solid var(--border);
  border-radius: var(--r-md); cursor: pointer; background: var(--bg-input);
  transition: border-color 0.15s, background 0.15s;
}
.diff-card input { position: absolute; opacity: 0; pointer-events: none; }
.diff-card.selected { border-color: var(--accent); background: var(--bg-elev); }
.diff-name { font-weight: 700; }
.diff-cash { color: var(--accent); font-weight: 700; font-size: 0.9rem; }
.diff-desc { font-size: 0.72rem; color: var(--text-mute); }

/* ===== 테이블 ===== */
.table-scroll { overflow-x: auto; }
.data-table { font-size: 0.85rem; }
.data-table th, .data-table td {
  padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.data-table th { color: var(--text-dim); font-weight: 600; font-size: 0.76rem; position: sticky; top: 0; background: var(--bg-panel-2); }
.data-table td.num, .data-table th.num { text-align: right; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: var(--bg-elev); }
.actions-cell { white-space: nowrap; display: flex; gap: 4px; }

/* ===== 상세 정보 그리드 (우측 패널) ===== */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 2px; }
.drow { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border-soft); font-size: 0.85rem; }
.dk { color: var(--text-dim); }
.dv { font-weight: 600; text-align: right; }
.mini-list li { padding: 6px 8px; border-radius: var(--r-sm); font-size: 0.85rem; cursor: pointer; }
.mini-list li:hover { background: var(--bg-elev); }

/* ===== 프리뷰 박스 (노선 개설) ===== */
.preview-box { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3); }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.kv { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 2px 0; }
.kv .k { color: var(--text-dim); }
.kv .v { font-weight: 600; }
.preview-profit {
  margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border);
  font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.preview-profit.profit { color: var(--profit); }
.preview-profit.low { color: var(--low); }
.preview-profit.loss { color: var(--loss); }
.preview-warn { color: var(--loss); font-size: 0.85rem; }
.preview-warn ul { margin-top: 4px; padding-left: 16px; list-style: disc; }
.chip-profit.chip { }

/* ===== 카드 그리드 (마켓) ===== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-3); }
.ac-card {
  background: var(--bg-panel-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3);
  display: flex; flex-direction: column; gap: 6px;
}
.ac-card h3 { font-size: 0.98rem; }
.ac-card-top { display: flex; align-items: center; justify-content: space-between; }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; margin: 6px 0; }
.spec { display: flex; justify-content: space-between; font-size: 0.8rem; }
.spec-k { color: var(--text-dim); }
.spec-v { font-weight: 600; }

/* 항공기 실루엣 (원본 CSS 도형) */
.ac-silhouette { height: 26px; width: 70px; position: relative; opacity: 0.85; }
.ac-silhouette::before {
  content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 6px;
  transform: translateY(-50%); border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #6ea0ff);
}
.ac-silhouette::after {
  content: ""; position: absolute; left: 40%; top: 2px;
  border-left: 16px solid transparent; border-right: 6px solid transparent;
  border-bottom: 11px solid var(--accent);
}
.ac-regional::before { width: 55px; }
.ac-narrow::before { width: 70px; }
.ac-wide { width: 84px; }
.ac-jumbo { width: 92px; }
.ac-wide::before, .ac-jumbo::before { height: 8px; }

/* ===== 통계 카드 ===== */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-4); }
.stat-card { background: var(--bg-panel-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3); display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 0.76rem; color: var(--text-dim); }
.stat-value { font-size: 1.1rem; font-weight: 700; }

/* 필터 바 */
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: end; }
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.filter-field label { font-size: 0.76rem; color: var(--text-dim); }

/* 빈 상태 */
.empty-state { text-align: center; padding: var(--sp-5); color: var(--text-dim); display: flex; flex-direction: column; gap: var(--sp-3); align-items: center; }

/* 현황 히어로 */
.overview-hero { display: flex; align-items: center; gap: var(--sp-3); }
.hero-badge { color: #fff; font-weight: 800; padding: 10px 14px; border-radius: var(--r-md); font-size: 1.1rem; }

/* 평판 바 */
.rep-row { display: flex; align-items: center; gap: var(--sp-3); }
.rep-bar { flex: 1; height: 12px; background: var(--bg-input); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.rep-bar span { display: block; height: 100%; border-radius: 999px; transition: width 0.4s; }
.rep-meta { white-space: nowrap; }

/* 상태 바 (기체 상태) */
.cond-bar { width: 64px; height: 7px; background: var(--bg-input); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.cond-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--loss), var(--low), var(--profit)); }

/* 허브 목록 */
.hub-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.hub-item { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); display: flex; flex-direction: column; }

/* ===== 모달 ===== */
.modal-host { position: fixed; inset: 0; z-index: 100; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 8, 18, 0.7); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.modal {
  position: relative; width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow);
}
.modal-wide { max-width: 560px; }
.modal-x { position: absolute; top: 10px; right: 12px; font-size: 1.4rem; color: var(--text-dim); width: 32px; height: 32px; }
.modal-content { display: flex; flex-direction: column; gap: var(--sp-3); }
.modal-content h3 { font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-2); }
.switch-row { display: flex; align-items: center; gap: var(--sp-2); font-size: 0.9rem; }

/* 정산 모달 */
.settle-table { width: 100%; font-size: 0.9rem; }
.settle-table td { padding: 6px 4px; border-bottom: 1px solid var(--border-soft); }
.settle-table td:last-child { text-align: right; font-weight: 600; }
.settle-total td { border-top: 1px solid var(--border); font-weight: 800; font-size: 1rem; }
.settle-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: var(--sp-3); font-size: 0.86rem; }
.settle-events { margin-top: var(--sp-2); }
.settle-event { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); margin-top: 6px; }

/* ===== 토스트 ===== */
.toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.toast {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--r-sm); padding: 10px 14px; font-size: 0.85rem;
  box-shadow: var(--shadow); animation: toast-in 0.28s ease;
}
.toast--success { border-left-color: var(--profit); }
.toast--warning { border-left-color: var(--low); }
.toast--danger { border-left-color: var(--loss); }
.toast--out { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
