/* ============================================================
   한국 게임 가격 추적 - 기본 스타일
   public/static/style.css
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
    'Malgun Gothic', '맑은 고딕', sans-serif;
  background: #0f1117;
  color: #e6e8ec;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* ---------- 페이지 래퍼 (헤더 + 본문) ---------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* ---------- 헤더: 제목 가운데, 검색창 우측, 관리링크 좌측 ---------- */
.site-header {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.site-header .header-text {
  grid-column: 1 / -1;
  text-align: center;
}
.site-header h1 { font-size: 1.7rem; }
.site-header .subtitle { color: #9aa0aa; font-size: .9rem; margin-top: 2px; }

/* 검색창 (헤더 우측, 제목 줄 위) */
.search-box {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  gap: 8px;
  justify-self: end;
}
.search-input {
  background: #1a1d27;
  border: 1px solid #2a2e3a;
  border-radius: 8px;
  color: #e6e8ec;
  padding: 9px 14px;
  font-size: .9rem;
  width: 200px;
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: #4f7cff; }
.search-input::placeholder { color: #6b7280; }
.search-btn {
  background: #4f7cff;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.search-btn:hover { background: #3d6af0; }

/* 관리자 링크 (헤더 좌상단, 절대배치라 제목 중앙정렬 안 깨짐) */
.header-admin {
  position: absolute;
  left: 0;
  top: 2px;
  grid-row: 1;
  grid-column: 1;
  justify-self: start;
}
.admin-link {
  font-size: .8rem; color: #9aa0aa;
  background: #1a1d27; border: 1px solid #2a2e3a;
  padding: 7px 12px; border-radius: 8px; white-space: nowrap;
}
.admin-link:hover { color: #e6e8ec; border-color: #4f7cff; }

/* 검색 결과 안내 */
.search-meta {
  font-size: .88rem; color: #9aa0aa;
  margin: -6px 0 14px;
}
.search-meta strong { color: #e6e8ec; }
.search-clear { color: #ff8585; margin-left: 8px; }
.search-clear:hover { text-decoration: underline; }

/* ---------- 2단 레이아웃 (탭+게임 | 특가순위) ---------- */
/* 헤더 아래에서 시작 → 특가 순위 박스가 콘솔 탭 라인과 같은 높이에서 시작 */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.main-col {
  max-width: none;
  width: 100%;
  min-width: 0;
  padding: 0;
  margin: 0;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
  .site-header { grid-template-columns: 1fr; }
  .search-box { grid-row: auto; grid-column: 1; justify-self: stretch; }
  .search-input { width: 100%; }
  .header-admin { position: static; margin-bottom: 4px; }
}

/* ---------- 콘솔 탭 ---------- */
.console-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  background: #1a1d27;
  padding: 8px;
  border-radius: 12px;
}
.console-tab {
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: .92rem;
  color: #9aa0aa;
  transition: all .15s;
}
.console-tab:hover { background: #232733; color: #e6e8ec; }
.console-tab.active { background: #4f7cff; color: #fff; }
.tab-icon { margin-right: 2px; }

/* ---------- 사이드바 (할인율) ---------- */
.sidebar {
  background: #1a1d27;
  border-radius: 12px;
  padding: 18px;
  position: sticky;
  top: 16px;
}
.sidebar-title { font-size: 1.1rem; margin-bottom: 2px; }
.sidebar-sub { font-size: .8rem; color: #9aa0aa; margin-bottom: 14px; }
.discount-list { list-style: none; counter-reset: rank; }
.discount-item { counter-increment: rank; border-bottom: 1px solid #2a2e3a; }
.discount-item:last-child { border-bottom: none; }
.discount-item a { display: block; padding: 10px 0 10px 28px; position: relative; }
.discount-item a:hover { background: #232733; border-radius: 6px; }
.discount-item a::before {
  content: counter(rank);
  position: absolute; left: 4px; top: 10px;
  font-size: .8rem; font-weight: 700; color: #ff6b6b;
  width: 18px; text-align: center;
}
.discount-platform {
  display: inline-block; font-size: .68rem; font-weight: 700;
  background: #2a2e3a; color: #9aa0aa; padding: 1px 6px; border-radius: 4px;
  margin-bottom: 3px;
}
.discount-name { display: block; font-size: .85rem; }
.discount-price { font-size: .85rem; font-weight: 700; }
.discount-rate { color: #ff6b6b; margin-left: 4px; font-size: .78rem; }

/* ---------- 카드 내 배지/가격 ---------- */
.platform-badge {
  display: inline-block; font-size: .68rem; font-weight: 700;
  background: #4f7cff; color: #fff; padding: 1px 7px; border-radius: 4px;
  margin-bottom: 5px;
}
.card-discount { color: #ff6b6b; font-weight: 700; }
.no-price { color: #6b7280; font-size: .82rem; }

/* ---------- 플랫폼 전환 (상세 내부) ---------- */
.platform-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.platform-pill {
  padding: 8px 14px; border-radius: 20px; font-size: .88rem; font-weight: 600;
  background: #1a1d27; color: #9aa0aa; border: 1px solid #2a2e3a;
}
.platform-pill:hover { color: #e6e8ec; }
.platform-pill.active { background: #4f7cff; color: #fff; border-color: #4f7cff; }
.current-platform { font-weight: 600; margin-bottom: 6px; }
.edition-name { color: #9aa0aa; font-weight: 400; }

h1 { font-size: 1.8rem; margin-bottom: 8px; }
.subtitle { color: #9aa0aa; margin-bottom: 24px; }

/* CTA 버튼 */
.cta-button {
  display: inline-block;
  background: #4f7cff;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  margin-top: 12px;
}
.cta-button:hover { background: #3d68e8; }

.back-link { color: #9aa0aa; font-size: .9rem; display: inline-block; margin-bottom: 16px; }
.back-link:hover { color: #e6e8ec; }

/* ---------- 게임 목록 그리드 ---------- */
.game-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.game-card {
  background: #1a1d27;
  border-radius: 12px;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.4); }

/* 카드 클릭 트리거 (버튼이지만 카드처럼 보이게) — 펼쳐져도 모양 안 바뀜 */
.game-card-trigger {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  font: inherit;
}
/* 썸네일: 비율 통일 + 어두운 배경으로 흰 여백/이미지 비율 차이 자연스럽게 */
.game-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #0c0e14;
  overflow: hidden;
}
/* 흐릿한 배경 채움 (작은 이미지나 비율 다른 이미지의 여백을 메움) */
.game-thumb-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--thumb-bg, none);
  background-size: cover;
  background-position: center;
  filter: blur(18px) brightness(.5);
  transform: scale(1.15);
  z-index: 0;
}
.game-thumb {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .25s;
}
.game-card:hover .game-thumb { transform: scale(1.04); }
/* 하단 살짝 어둡게 → 본문과 자연스럽게 이어짐 */
.game-thumb-wrap::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 38%;
  background: linear-gradient(to top, rgba(26,29,39,.85), transparent);
  z-index: 2;
  pointer-events: none;
}
.game-thumb-placeholder {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  opacity: .4;
}
.game-card-body { padding: 12px 14px; }
.game-card-body h3 { font-size: 1rem; margin-bottom: 4px; }
.game-price { color: #9aa0aa; font-size: .85rem; }

/* 펼침 화살표 */
.accordion-chevron {
  position: absolute;
  right: 12px;
  bottom: 12px;
  font-size: .75rem;
  color: #6b7280;
  transition: transform .2s;
}
/* 열린 카드: 모양 그대로, 강조 테두리 + 화살표 회전만 */
.game-card.open {
  box-shadow: 0 0 0 2px #4f7cff inset;
}
.game-card.open .accordion-chevron { transform: rotate(180deg); color: #4f7cff; }

/* ---------- 행 삽입 펼침 패널 (방식 B) ---------- */
/* 클릭한 카드가 속한 행 바로 아래에 삽입됨. 그리드 전체 폭 차지. */
.row-panel {
  grid-column: 1 / -1;
  background: #161922;
  border: 1px solid #4f7cff;
  border-radius: 12px;
  overflow: hidden;
  max-height: 0;
  transition: max-height .28s ease;
}
.row-panel-inner { padding: 18px 20px 22px; }
.accordion-loading { color: #9aa0aa; padding: 8px 0; }
.no-data { color: #6b7280; font-size: .9rem; padding: 8px 0; }

/* 패널 헤더: 썸네일 + 제목 + 액션(전체보기/닫기) */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-title { display: flex; gap: 16px; align-items: center; }
.panel-thumb {
  width: 130px;
  aspect-ratio: 460/215;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.panel-title-text h3 { font-size: 1.25rem; margin-bottom: 8px; }
.panel-platforms { display: flex; gap: 6px; margin-bottom: 8px; font-size: 1rem; }
.header-plat {
  background: #232735;
  border-radius: 6px;
  padding: 2px 7px;
  line-height: 1.4;
}
.panel-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.meta-chip {
  background: #232735;
  color: #c3c8d2;
  font-size: .78rem;
  padding: 4px 10px;
  border-radius: 999px;
}
.meta-chip.genre { background: #2a2150; color: #b9a9ff; }
.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-full-link {
  font-size: .82rem;
  color: #4f7cff;
  text-decoration: none;
  white-space: nowrap;
}
.detail-full-link:hover { text-decoration: underline; }

/* 위시리스트(알림받기) 버튼 */
.wishlist-btn {
  background: #232735;
  border: 1px solid #3a3050;
  color: #e6e8ec;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.wishlist-btn:hover { background: #2c3142; }
.wishlist-btn .wl-icon { color: #ff6b9d; }
.wishlist-btn.wished { background: #3a1f2e; border-color: #ff6b9d; }
.wishlist-btn.wished .wl-icon { color: #ff4d85; }

/* 인사이트 배너 */
.insight-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: .92rem;
  font-weight: 500;
  line-height: 1.4;
}
.insight-banner .insight-icon { font-size: 1.1rem; flex-shrink: 0; }
.insight-buy  { background: linear-gradient(90deg,#13351f,#16251d); border: 1px solid #2e7d4f; color: #6ee7a0; }
.insight-wait { background: linear-gradient(90deg,#33270f,#252016); border: 1px solid #7d652e; color: #e7c96e; }
.insight-info { background: #1d2233; border: 1px solid #34406a; color: #a9bcff; }

/* 역대최저 날짜 맥락 */
.lowest-date { color: #9aa0aa; font-size: .82rem; }
.lowest-date.fresh { color: #6ee7a0; font-weight: 600; }
.lowest-date.stale { color: #e7c96e; }

/* 토스트 */
.gpt-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #232735;
  border: 1px solid #4f7cff;
  color: #e6e8ec;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 1000;
  max-width: 90vw;
}
.gpt-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.panel-close {
  background: #232735;
  border: 1px solid #2a2e3a;
  color: #9aa0aa;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
}
.panel-close:hover { background: #2c3142; color: #e6e8ec; }
.edition-body { margin-top: 4px; }

/* 펼친 영역 내부 가격 섹션: 디지털/패키지 2열 */
.row-panel .price-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* ---------- 게임 상세 헤더 ---------- */
.game-header {
  display: flex;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.game-hero {
  width: 280px;
  max-width: 100%;
  border-radius: 12px;
  aspect-ratio: 460/215;
  object-fit: cover;
}
.game-meta { flex: 1; min-width: 220px; }
.game-meta h1 { margin-bottom: 10px; }
.release, .original { color: #9aa0aa; font-size: .9rem; }
.original { color: #e6e8ec; font-weight: 600; }
.steam-link {
  display: inline-block;
  margin-top: 10px;
  color: #66c0f4;
  font-size: .9rem;
}

/* ---------- 가격 섹션 (디지털/패키지) ---------- */
.price-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 640px) { .price-sections { grid-template-columns: 1fr; } }

.price-section {
  background: #1a1d27;
  border-radius: 12px;
  padding: 18px;
}
.price-section h2 { font-size: 1.15rem; margin-bottom: 12px; }
.section-icon { margin-right: 4px; }

.lowest-info {
  background: #232733;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .85rem;
  color: #9aa0aa;
  margin-bottom: 12px;
}
.lowest-info strong { color: #4ade80; }
.lowest-date { font-size: .8rem; }

.price-list { list-style: none; }
.price-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #2a2e3a;
}
.price-row:last-child { border-bottom: none; }
.source-name { font-weight: 600; min-width: 64px; }
.price-value { font-size: 1.05rem; font-weight: 700; flex: 1; }
.discount {
  color: #ff6b6b;
  font-size: .8rem;
  margin-left: 6px;
  font-weight: 600;
}
.lowest-badge {
  background: #4ade80;
  color: #0f1117;
  font-size: .7rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 700;
}
.buy-link {
  color: #4f7cff;
  font-size: .85rem;
  font-weight: 600;
}
.buy-link:hover { text-decoration: underline; }

.no-data { color: #6b7280; font-size: .9rem; padding: 8px 0; }
.notice {
  margin-top: 24px;
  font-size: .8rem;
  color: #6b7280;
  padding: 12px;
  background: #1a1d27;
  border-radius: 8px;
}

/* ---------- 가격 추이 그래프 ---------- */
.trend-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #2a2e3a;
}
.trend-section h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.trend-chart-wrap {
  position: relative;
  height: 240px;
  background: #14171f;
  border: 1px solid #22262f;
  border-radius: 10px;
  padding: 12px;
}
.trend-empty {
  color: #9aa0aa;
  font-size: .88rem;
  background: #14171f;
  border: 1px dashed #2a2e3a;
  border-radius: 10px;
  padding: 16px;
}
