/* 우측 사이드바 실시간 랭킹(거래대금/상한가/하한가) 위젯 (js/sidebar-rank.js)
 * 상승=빨강 #d24f45, 하락=파랑 #1261c4 (사이트 공통 컬러 - 지시서 원문 색상 대신 이 값을
 * 그대로 씀, js/sidebar-rank.js 상단 주석 참고)
 * .card/.sidebar-card/.sidebar-title/.sidebar-icon은 style.css의 기존 사이드바 카드
 * 스타일을 그대로 재사용 - 이 파일은 내부 리스트/행/뱃지 스타일만 추가한다.
 * 다크모드: html.dark #sidebar-rank ... !important (9bolt 스킨 블랑켓 규칙 대응) */

#sidebar-rank {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sidebar-rank .sr-card {
  height: 232px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
}

#sidebar-rank .sr-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 12px 0;
  padding: 3px;
  border-radius: 10px;
  background: #f1f3f2;
}
#sidebar-rank .sr-tab {
  min-height: 36px;
  padding: 6px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #667085;
  font-size: 12px;
  cursor: pointer;
}
#sidebar-rank .sr-tab.active {
  background: #fff;
  color: #082415;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
#sidebar-rank .sr-tab:focus-visible,
#sidebar-rank .sr-retry:focus-visible { outline: 2px solid #315b43; outline-offset: 1px; }

#sidebar-rank .sr-title {
  justify-content: space-between;
}
#sidebar-rank .sr-title-text { flex: 1; }
#sidebar-rank .sr-updated {
  font-size: 11px;
  font-weight: 400;
  color: #9ca3af;
}

#sidebar-rank .sr-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  flex: 1;
}

#sidebar-rank .sr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
#sidebar-rank .sr-rank {
  flex-shrink: 0;
  width: 16px;
  font-weight: 400;
  color: #9ca3af;
  font-size: 11.5px;
}
#sidebar-rank .sr-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
}
#sidebar-rank .sr-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  color: #0d1b40;
  text-decoration: none;
}
#sidebar-rank .sr-name:hover { text-decoration: underline; }

#sidebar-rank .sr-details {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
#sidebar-rank .sr-quote {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
#sidebar-rank .sr-price {
  display: block;
  font-weight: 400;
  font-size: 11.5px;
  line-height: 1.35;
  color: #222;
  white-space: nowrap;
}
#sidebar-rank .sr-rate {
  font-weight: 400;
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 999px;
  white-space: nowrap;
}
#sidebar-rank .sr-rate.sr-up { background: #fdeceb; color: #d24f45; }
#sidebar-rank .sr-rate.sr-down { background: #e9f1fb; color: #1261c4; }
#sidebar-rank .sr-rate.sr-flat { background: #f1f1f1; color: #666; }

#sidebar-rank .sr-amount {
  flex-shrink: 0;
  min-width: 52px;
  line-height: 1.35;
  text-align: right;
  font-size: 11.5px;
  color: #555;
}

#sidebar-rank .sr-hint {
  font-size: 12.5px;
  color: #9ca3af;
  padding: 6px 0;
  list-style: none;
}
#sidebar-rank .sr-error { color: #c0392b; }
#sidebar-rank .sr-error small { display: block; margin-top: 4px; color: #9ca3af; }
#sidebar-rank .sr-retry {
  display: inline-flex;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid #d8dedb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

#sidebar-rank .sr-more {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  color: #555;
  background: none;
  border: none;
  border-top: 1px solid #f0f0f0;
  padding: 4px 0 0;
  cursor: pointer;
}
#sidebar-rank .sr-more:hover { color: #222; }

/* ---- "더보기" 모달(TOP20) - #sidebar-rank 밖(document.body)에 붙으므로 위 .sr-row 등
   #sidebar-rank 스코프 규칙이 안 먹는다. 같은 스타일을 .sr-modal 아래에 다시 정의한다. */
.sr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}
.sr-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Malgun Gothic", "맑은 고딕", sans-serif;
}
.sr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #eee;
  font-size: 17px;
  font-weight: 700;
  color: #222;
}
.sr-modal-close {
  border: none;
  background: transparent;
  font-size: 17px;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.sr-modal-close:hover { color: #333; }
.sr-modal-list {
  overflow-y: auto;
  padding: 8px 12px 18px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
}
.sr-modal-list .sr-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  padding: 12px 10px;
  border-radius: 10px;
}
.sr-modal-list .sr-row:hover { background: #f7f8fa; }
.sr-modal-list .sr-rank { flex-shrink: 0; width: 24px; font-weight: 400; color: #9ca3af; font-size: 13.5px; }
.sr-modal-list .sr-icon { flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; object-fit: contain; background: #fff; }
.sr-modal-list .sr-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 400; font-size: 15px; color: #0d1b40; text-decoration: none;
}
.sr-modal-list .sr-name:hover { text-decoration: underline; }
.sr-modal-list .sr-quote { flex-shrink: 0; display: flex; flex-direction: row; align-items: center; gap: 8px; }
.sr-modal-list .sr-price { font-weight: 400; font-size: 14px; color: #222; white-space: nowrap; }
.sr-modal-list .sr-rate { font-weight: 400; font-size: 13px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.sr-modal-list .sr-rate.sr-up { background: #fdeceb; color: #d24f45; }
.sr-modal-list .sr-rate.sr-down { background: #e9f1fb; color: #1261c4; }
.sr-modal-list .sr-rate.sr-flat { background: #f1f1f1; color: #666; }
.sr-modal-list .sr-amount { flex-shrink: 0; min-width: 72px; text-align: right; font-size: 13.5px; color: #555; }
.sr-modal-list .sr-hint { font-size: 14px; color: #9ca3af; padding: 10px; }
.sr-modal-list .sr-error { color: #c0392b; }

/* 2026-07-28: 사이트 다크모드 전체 재통일(style.css 기타 규칙 참고)에 맞춰 #1A1A1A
   배경 + #F5EFE0 글자로 교체. 등락 배지(sr-up/down/flat)는 의미가 있는 색이라 유지. */
html.dark #sidebar-rank .sr-updated { color: rgba(245, 239, 224, 0.55) !important; }
html.dark #sidebar-rank .sr-tabs { background: rgba(245, 239, 224, .08) !important; }
html.dark #sidebar-rank .sr-tab { color: rgba(245, 239, 224, .65) !important; }
html.dark #sidebar-rank .sr-tab.active { background: rgba(245, 239, 224, .16) !important; color: #F5EFE0 !important; }
html.dark #sidebar-rank .sr-retry { background: transparent !important; color: #F5EFE0 !important; border-color: rgba(245,239,224,.25) !important; }
html.dark #sidebar-rank .sr-name { color: #F5EFE0 !important; }
html.dark #sidebar-rank .sr-price { color: #F5EFE0 !important; }
html.dark #sidebar-rank .sr-rate.sr-up { background: #3a2523 !important; color: #e8776d !important; }
html.dark #sidebar-rank .sr-rate.sr-down { background: #20304a !important; color: #6ea8e8 !important; }
html.dark #sidebar-rank .sr-rate.sr-flat { background: rgba(245, 239, 224, 0.12) !important; color: rgba(245, 239, 224, 0.7) !important; }
html.dark #sidebar-rank .sr-amount { color: rgba(245, 239, 224, 0.6) !important; }
html.dark #sidebar-rank .sr-hint { color: rgba(245, 239, 224, 0.55) !important; }
html.dark #sidebar-rank .sr-more { color: rgba(245, 239, 224, 0.65) !important; border-color: rgba(245, 239, 224, 0.2) !important; }
html.dark #sidebar-rank .sr-more:hover { color: #F5EFE0 !important; }

html.dark .sr-modal { background: #1A1A1A !important; border: 1px solid rgba(245, 239, 224, 0.14) !important; }
html.dark .sr-modal-header { border-color: rgba(245, 239, 224, 0.14) !important; color: #F5EFE0 !important; }
html.dark .sr-modal-close { color: rgba(245, 239, 224, 0.55) !important; }
html.dark .sr-modal-close:hover { color: #F5EFE0 !important; }
html.dark .sr-modal-list .sr-name { color: #F5EFE0 !important; }
html.dark .sr-modal-list .sr-price { color: #F5EFE0 !important; }
html.dark .sr-modal-list .sr-rank { color: rgba(245, 239, 224, 0.55) !important; }
html.dark .sr-modal-list .sr-amount { color: rgba(245, 239, 224, 0.6) !important; }
html.dark .sr-modal-list .sr-hint { color: rgba(245, 239, 224, 0.55) !important; }
html.dark .sr-modal-list .sr-rate.sr-up { background: #3a2523 !important; color: #e8776d !important; }
html.dark .sr-modal-list .sr-rate.sr-down { background: #20304a !important; color: #6ea8e8 !important; }
html.dark .sr-modal-list .sr-rate.sr-flat { background: rgba(245, 239, 224, 0.12) !important; color: rgba(245, 239, 224, 0.7) !important; }
html.dark .sr-modal-list .sr-row:hover { background: rgba(245, 239, 224, 0.08) !important; }
