/* =============================================
   history.css - 기간내 승률 변화 그래프 v2
   ============================================= */

.history-page { gap: 18px; padding-top: 24px !important; }

/* 히어로 - 코랄/민트 계열 */
.history-hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: 30px;
  border: 1px solid rgba(255,140,105,.14);
  background:
    radial-gradient(circle at 84% 14%, rgba(255,140,105,.16), transparent 24%),
    radial-gradient(circle at 10% 88%, rgba(110,231,183,.10), transparent 26%),
    linear-gradient(180deg, rgba(20,16,18,.98), rgba(12,10,14,.98));
  box-shadow: 0 22px 56px rgba(0,0,0,.42);
}
.history-hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,.025) 34%, transparent 72%); }
.history-hero::after { content: ""; position: absolute; top: 0; left: 34px; right: 34px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,140,105,.34) 20%, rgba(255,255,255,.12) 50%, rgba(110,231,183,.28) 80%, transparent); pointer-events: none; }
.history-hero-inner { position: relative; z-index: 1; display: flex; gap: 22px; align-items: stretch; }
.history-hero-left { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.history-hero-kicker { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; font-weight: 900; color: #ff8c69; text-shadow: 0 0 10px rgba(255,140,105,.14); }
.history-hero-title { margin: 0; font-size: 31px; line-height: 1.12; font-weight: 900; letter-spacing: -.3px; background: linear-gradient(135deg, #fff 0%, #ffd6c8 24%, #ff8c69 50%, #fff 76%, #8ff6d1 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.history-hero-desc { font-size: 13px; line-height: 1.9; color: #b5a8af; max-width: 720px; }
.history-hero-desc strong.op { color: #ffa88a; font-weight: 900; }
.history-hero-desc strong.favor { color: #8ff6d1; font-weight: 900; }
.history-hero-desc strong.point { color: #fff; font-weight: 900; }
.history-hero-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.history-hero-pill { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #f6eef0; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.08); }
.history-hero-pill.compare { color: #ffa88a; border-color: rgba(255,140,105,.20); background: rgba(255,140,105,.07); }
.history-hero-pill.range { color: #8ff6d1; border-color: rgba(110,231,183,.18); background: rgba(110,231,183,.07); }
.history-hero-pill.public { color: #f6f2ff; border-color: rgba(255,255,255,.10); background: rgba(255,255,255,.04); }
.history-hero-right { width: 220px; flex: 0 0 220px; display: flex; flex-direction: column; gap: 12px; justify-content: center; }
.history-hero-stat-card { border-radius: 18px; padding: 16px 14px; text-align: center; background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02)), rgba(20,16,18,.90); border: 1px solid rgba(255,255,255,.08); }
.history-hero-stat-label { font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; font-weight: 900; color: #7a6f74; margin-bottom: 6px; }
.history-hero-stat-value { font-size: 19px; font-weight: 900; color: #fdfcff; line-height: 1.1; margin-bottom: 4px; }
.history-hero-stat-sub { font-size: 10px; color: #b5a8af; line-height: 1.5; }
.history-divider { width: 100%; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,140,105,.18) 20%, rgba(110,231,183,.14) 50%, rgba(255,140,105,.18) 80%, transparent); }

/* 컨트롤 */
.history-controls,
.history-selected-section,
.history-engraving-section,
.history-chart-section,
.history-summary-section {
  border-radius: 22px; padding: 20px;
  background: linear-gradient(180deg, rgba(20,17,22,.86), rgba(11,9,13,.96));
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 18px 44px rgba(0,0,0,.28);
}

.history-control-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.history-control-row:last-child { margin-bottom: 0; }

.history-control-item {
  flex: 1;
  min-width: 140px;
}

.history-label {
  display: block;
  font-size: 11px;
  font-weight: 900;
  color: #b5a8af;
  margin-bottom: 6px;
  letter-spacing: .3px;
}

.history-select,
.history-date-input {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  outline: none;
  transition: .16s ease;
  color-scheme: dark;
}

.history-select option {
  background: #1a161e;
  color: #fff;
}

.history-select:focus,
.history-date-input:focus {
  border-color: rgba(255,140,105,.28);
  box-shadow: 0 0 0 3px rgba(255,140,105,.08);
}

.history-unit-tabs {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.history-unit-btn {
  min-height: 42px;
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: #b5a8af;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: .16s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.history-unit-btn:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
}

.history-unit-btn.active {
  color: #fff;
  border-color: rgba(255,140,105,.24);
  background: linear-gradient(135deg, rgba(255,140,105,.16), rgba(110,231,183,.08));
}

.unit-sub {
  font-size: 9px;
  font-weight: 700;
  color: #7a6f74;
  letter-spacing: .2px;
}

.history-unit-btn.active .unit-sub {
  color: #ffa88a;
}

.history-reset-btn {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: .16s ease;
}

.history-reset-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.06); }

/* 선택 상태 */
.history-selected-head,
.history-section-head { margin-bottom: 12px; }
.history-selected-title,
.history-section-title { font-size: 17px; font-weight: 900; color: #fff; line-height: 1.2; }
.history-selected-sub,
.history-section-sub { font-size: 12px; color: #b5a8af; margin-top: 4px; }
.history-selected-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.history-selected-tag { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 10px; font-size: 12px; font-weight: 800; color: #fff; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }

/* 직각 목록 - 접기/펼치기 */
.history-engraving-section {
  transition: max-height .35s ease, opacity .25s ease, padding .25s ease;
  overflow: hidden;
}

.history-engraving-section.collapsed {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-color: transparent !important;
  opacity: 0;
  margin-bottom: -10px;
}

.history-engraving-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.history-engraving-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  cursor: pointer;
  transition: .14s ease;
}

.history-engraving-item:hover {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,140,105,.14);
}

.history-engraving-item.checked {
  border-color: rgba(255,140,105,.24);
  background: linear-gradient(135deg, rgba(255,140,105,.10), rgba(110,231,183,.04));
}

.history-engraving-item input { flex-shrink: 0; }
.history-engraving-short { font-size: 12px; font-weight: 900; color: #fff; }
.history-engraving-class { font-size: 10px; color: #8f869b; margin-left: auto; }
.history-empty-state { grid-column: 1 / -1; text-align: center; padding: 20px; color: #b5a8af; }



/* 액션 바 */
.history-action-bar {
  display: flex;
  gap: 10px;
}

.history-toggle-btn {
  flex: 0 0 auto;
  min-height: 56px;
  padding: 0 22px;
  border: 2px solid rgba(255,255,255,.10);
  border-radius: 18px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: .18s ease;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)),
    rgba(20,16,18,.88);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    inset 0 -2px 0 rgba(0,0,0,.20),
    0 4px 14px rgba(0,0,0,.18);
}

.history-toggle-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.18);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    0 10px 24px rgba(0,0,0,.22);
}

.history-big-apply-btn {
  flex: 1;
  min-height: 56px;
  border: 2px solid rgba(255,140,105,.22);
  border-radius: 18px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: .18s ease;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255,140,105,.18), rgba(110,231,183,.10)),
    rgba(20,16,18,.96);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    inset 0 -2px 0 rgba(0,0,0,.22),
    0 6px 18px rgba(0,0,0,.22);
}

.history-big-apply-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255,140,105,.34);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    0 14px 30px rgba(0,0,0,.24),
    0 0 18px rgba(255,140,105,.10);
}

.history-big-apply-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 768px) {
  .history-action-bar {
    flex-direction: column;
  }

  .history-toggle-btn {
    min-height: 48px;
    font-size: 13px;
    border-radius: 16px;
  }

  .history-big-apply-btn {
    min-height: 50px;
    font-size: 15px;
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  .history-toggle-btn {
    min-height: 44px;
    font-size: 12px;
  }

  .history-big-apply-btn {
    min-height: 46px;
    font-size: 14px;
  }
}



/* 그래프 */
.history-chart-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #0f1520;
  border: 1px solid rgba(255,255,255,.06);
  min-height: 380px;
}

#historyChartSvg { width: 100%; height: 380px; display: block; }

.history-loading-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(7,10,18,.76);
  color: #fff; font-size: 14px; font-weight: 900; z-index: 5;
}

.history-tooltip {
  position: absolute; z-index: 6;
  min-width: 160px; max-width: 220px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(12,16,24,.95); border: 1px solid rgba(255,255,255,.08);
  color: #fff; font-size: 12px; line-height: 1.6;
  pointer-events: none; box-shadow: 0 10px 24px rgba(0,0,0,.24);
}

.history-legend-box { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.history-legend-item {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 11px; font-weight: 800; color: #e6dfff;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
}
.history-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* 요약 테이블 */
.history-summary-table-wrap { overflow-x: auto; }
.history-summary-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.history-summary-table th,
.history-summary-table td { padding: 12px 10px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 12px; }
.history-summary-table th { color: #fff; font-weight: 900; background: rgba(255,255,255,.04); }
.history-summary-table td { color: #cfd6e3; }
.color-chip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* 이용 안내 */
.history-guide-section { margin-top: 4px; }
.history-guide-box { border-radius: 20px; padding: 22px; background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)); border: 1px solid rgba(255,255,255,.06); }
.history-guide-title { font-size: 16px; font-weight: 900; color: #fff; margin-bottom: 14px; }
.history-guide-box ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.history-guide-box li { position: relative; padding-left: 18px; font-size: 13px; color: #c8d0e0; line-height: 1.7; }
.history-guide-box li::before { content: ""; position: absolute; left: 0; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,140,105,.50); box-shadow: 0 0 6px rgba(255,140,105,.30); }

/* 반응형 */
@media (max-width: 1100px) {
  .history-control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .history-control-item {
    min-width: 0;
    width: 100%;
  }

  .history-engraving-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .history-page {
    padding-top: 14px !important;
    gap: 12px;
  }

  .history-hero {
    padding: 18px;
    border-radius: 22px;
  }

  .history-hero-title {
    font-size: 22px;
  }

  .history-hero-desc {
    font-size: 12px;
  }

  .history-hero-pill {
    min-height: 26px;
    padding: 0 10px;
    font-size: 10px;
  }

  .history-hero-right {
    display: none !important;
  }

  .history-controls,
  .history-selected-section,
  .history-engraving-section,
  .history-chart-section,
  .history-summary-section,
  .history-guide-box {
    padding: 16px;
    border-radius: 18px;
  }

  .history-control-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .history-control-item {
    width: 100%;
  }

  .history-select,
  .history-date-input {
    min-height: 40px;
    font-size: 12px;
  }

  .history-unit-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .history-unit-btn {
    min-height: 44px;
    width: 100%;
    padding: 6px 6px;
    font-size: 11px;
  }

  .unit-sub {
    font-size: 8px;
  }

  .history-reset-btn {
    width: 100%;
    min-height: 40px;
    font-size: 12px;
  }

  .history-action-bar {
    flex-direction: column;
    gap: 8px;
  }

  .history-toggle-btn,
  .history-big-apply-btn {
    width: 100%;
  }

  .history-engraving-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #historyChartSvg {
    height: 320px;
  }

  .history-selected-title,
  .history-section-title {
    font-size: 15px;
  }

  .history-guide-title {
    font-size: 15px;
  }

  .history-guide-box li {
    font-size: 12px;
    padding-left: 16px;
  }

  .history-guide-box li::before {
    top: 7px;
    width: 5px;
    height: 5px;
  }

  .history-big-apply-btn {
    min-height: 50px;
    font-size: 15px;
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  .history-hero {
    padding: 16px;
  }

  .history-hero-title {
    font-size: 20px;
  }

  .history-engraving-list {
    grid-template-columns: 1fr;
  }

  .history-unit-tabs {
    grid-template-columns: 1fr;
  }

  .history-unit-btn {
    min-height: 42px;
  }

  .history-big-apply-btn {
    min-height: 46px;
    font-size: 14px;
  }
}