/**
 * NOPICKLE Trending – 스타일시트
 *
 * 라이트모드 / 다크모드 자동 지원 (prefers-color-scheme)
 * 반응형 (모바일 / 태블릿 / PC 모두 지원)
 * CLS 방지를 위한 최소 높이 예약
 *
 * @package NopickleTrending
 * @since   1.0.0
 */

/* ─── CSS 커스텀 프로퍼티 (라이트모드 기본값) ─── */
:root {
  --npt-bg:           #ffffff;
  --npt-bg-item:      #f8f9fa;
  --npt-bg-item-hover:#fff0f0;
  --npt-border:       #e9ecef;
  --npt-text:         #212529;
  --npt-text-muted:   #6c757d;
  --npt-accent:       #e63946;
  --npt-rank-color:   #adb5bd;
  --npt-rank-top:     #e63946;
  --npt-up:           #e63946;
  --npt-down:         #4361ee;
  --npt-new:          #2dc653;
  --npt-same:         #adb5bd;
  --npt-header-bg:    linear-gradient(135deg, #e63946 0%, #c1121f 100%);
  --npt-header-text:  #ffffff;
  --npt-live-bg:      rgba(255,255,255,0.25);
  --npt-shadow:       0 2px 12px rgba(0,0,0,0.08);
  --npt-radius:       12px;
  --npt-radius-sm:    8px;
  --npt-tooltip-bg:   #212529;
  --npt-tooltip-text: #ffffff;
  --npt-transition:   0.18s ease;
}

/* ─── 다크모드 ─── */
@media (prefers-color-scheme: dark) {
  :root {
    --npt-bg:           #1a1a2e;
    --npt-bg-item:      #16213e;
    --npt-bg-item-hover:#1f2d4a;
    --npt-border:       #2a2a4a;
    --npt-text:         #e9ecef;
    --npt-text-muted:   #868e96;
    --npt-accent:       #ff6b6b;
    --npt-rank-color:   #495057;
    --npt-rank-top:     #ff6b6b;
    --npt-up:           #ff6b6b;
    --npt-down:         #74b0ff;
    --npt-new:          #51cf66;
    --npt-same:         #495057;
    --npt-header-bg:    linear-gradient(135deg, #c1121f 0%, #9a031e 100%);
    --npt-shadow:       0 2px 12px rgba(0,0,0,0.4);
    --npt-tooltip-bg:   #2d2d2d;
    --npt-tooltip-text: #f1f1f1;
  }
}

/* ─── 위젯 컨테이너 ─── */
.npt-widget {
  background: var(--npt-bg);
  border: 1px solid var(--npt-border);
  border-radius: var(--npt-radius);
  box-shadow: var(--npt-shadow);
  /* overflow: hidden 제거 → 툴팁이 위젯 밖으로 나올 수 있도록 */
  overflow: visible;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--npt-text);
  /* CLS 방지: 콘텐츠 로드 전에도 높이를 예약합니다 */
  min-height: 360px;
  contain: layout;
}

/* ─── 헤더 ─── */
.npt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--npt-header-bg);
  color: var(--npt-header-text);
  /* overflow:visible 보정 – 위쪽 모서리만 둥글게 */
  border-radius: var(--npt-radius) var(--npt-radius) 0 0;
}

.npt-header__title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.npt-header__live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--npt-live-bg);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* LIVE 점 애니메이션 */
.npt-header__live::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: npt-pulse 1.6s ease-in-out infinite;
}

@keyframes npt-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}

/* ─── 리스트 ─── */
.npt-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

/* ─── 개별 아이템 ─── */
.npt-item {
  opacity: 0;
  animation: npt-fade-slide-up 0.35s forwards;
  position: relative;
  z-index: 0;
}

/* 호버된 아이템을 다른 항목 위로 올려 툴팁이 가리지 않도록 */
.npt-item:hover,
.npt-item:focus-within {
  z-index: 100;
}

@keyframes npt-fade-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.npt-item__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--npt-text);
  background: var(--npt-bg-item);
  margin: 2px 8px;
  border-radius: var(--npt-radius-sm);
  transition:
    background var(--npt-transition),
    transform var(--npt-transition),
    box-shadow var(--npt-transition);
  position: relative;
  outline-offset: 2px;
}

.npt-item__link:hover,
.npt-item__link:focus-visible {
  background: var(--npt-bg-item-hover);
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(230,57,70,0.12);
  color: var(--npt-accent);
  text-decoration: none;
}

.npt-item__link:focus-visible {
  outline: 2px solid var(--npt-accent);
}

/* 순위 번호 */
.npt-item__rank {
  min-width: 30px;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--npt-rank-color);
  flex-shrink: 0;
  letter-spacing: -0.3px;
}

/* 상위 3위는 강조 */
.npt-item:nth-child(1) .npt-item__rank,
.npt-item:nth-child(2) .npt-item__rank,
.npt-item:nth-child(3) .npt-item__rank {
  color: var(--npt-rank-top);
  font-size: 13px;
}

/* 카테고리 아이콘 */
.npt-item__icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}

/* 키워드 텍스트 */
.npt-item__keyword {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 상태 뱃지 영역 */
.npt-item__status {
  flex-shrink: 0;
  margin-left: auto;
}

/* ─── 상태 뱃지 ─── */
.npt-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.6;
  min-width: 32px;
  text-align: center;
}

.npt-badge--up   { color: var(--npt-up);   }
.npt-badge--down { color: var(--npt-down); }
.npt-badge--new  {
  color: #fff;
  background: var(--npt-new);
  border-radius: 4px;
  font-size: 10px;
  padding: 1px 4px;
}
.npt-badge--same { color: var(--npt-same); }

/* ─── 툴팁 ─── */
.npt-item__link[data-tooltip] {
  cursor: pointer;
}

.npt-item__link[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--npt-tooltip-bg);
  color: var(--npt-tooltip-text);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: pre-line;
  width: max-content;
  max-width: 180px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.npt-item__link[data-tooltip]:hover::after,
.npt-item__link[data-tooltip]:focus-visible::after {
  opacity: 1;
}

/* ─── 푸터 ─── */
.npt-footer {
  padding: 7px 14px;
  border-top: 1px solid var(--npt-border);
  text-align: right;
  /* overflow:visible 보정 – 아래쪽 모서리만 둥글게 */
  border-radius: 0 0 var(--npt-radius) var(--npt-radius);
}

.npt-footer__updated {
  font-size: 11px;
  color: var(--npt-text-muted);
}

/* ─── 오류 / 비어있음 ─── */
.npt-widget--error,
.npt-widget--empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--npt-text-muted);
}

/* ─── 반응형 ─── */
@media (max-width: 480px) {
  .npt-item__link {
    padding: 8px 10px;
  }
  .npt-widget {
    font-size: 13px;
  }
}

/* ──────────────────────────────────────────────
   관리자 페이지 전용 스타일
   ────────────────────────────────────────────── */
.npt-admin-wrap {
  max-width: 1100px;
}

.npt-admin-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px !important;
}

.npt-admin-version {
  font-size: 13px;
  font-weight: 400;
  color: #888;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 20px;
}

.npt-admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 20px;
}

.npt-admin-panel--preview {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .npt-admin-grid { grid-template-columns: 1fr; }
  .npt-admin-panel--preview { grid-column: auto; }
}

.npt-admin-panel {
  background: #fff;
  border: 1px solid #e2e4e7;
  border-radius: 8px;
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.npt-admin-panel h2 {
  margin-top: 0;
  font-size: 16px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.npt-admin-status-box {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.npt-admin-status-box h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.npt-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.npt-status-badge--active   { background: #d1fae5; color: #065f46; }
.npt-status-badge--inactive { background: #fee2e2; color: #991b1b; }

.npt-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.npt-admin-result {
  background: #f0f4f8;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  margin-top: 8px;
}

.npt-admin-result--success { background: #d1fae5; color: #065f46; }
.npt-admin-result--error   { background: #fee2e2; color: #991b1b; }

.npt-admin-preview-wrap {
  max-width: 300px;
}
