/* @mql5/core-price-alarm — 알람 오버레이/칩 스타일 (FXTester + GoldMiner 공용).
 *
 * 양앱 index.html 이 <link href="/packages/core-price-alarm/src/price-alarm.css"> 로 로드
 * (두 서버 모두 /packages/ 정적 서빙).
 *
 * .tp-sl-overlay(z-index:10) 바로 위(11)에 둬서 BE 라벨과 겹칠 때 알람 칩이 이긴다.
 * 2단계 터치: 기본 칩은 pointer-events:none → 첫 터치의 event.target 은 절대 칩이
 * 될 수 없다(= 항상 reveal 단계). .is-revealed 에서만 잡을 수 있게 된다.
 * (core-be-drag 의 .be-label 과 완전히 같은 수법)
 */

.price-alarm-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 11;
}

.price-alarm-chip {
  position: absolute;
  left: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  touch-action: none;
  opacity: 0.72;
  font: 600 10px/1.6 "Segoe UI", Consolas, monospace;
  background: rgba(13, 17, 23, 0.88);
  color: #e3b341;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.price-alarm-chip .pa-bell {
  font-size: 9px;
  line-height: 1;
}

.price-alarm-chip .pa-close {
  display: none;
}

.price-alarm-chip.is-revealed {
  opacity: 1;
  pointer-events: auto;
  cursor: ns-resize;
}

/* position:relative + z-index 는 필수 — 아래 .is-revealed::before 가 position:absolute
   라서 positioned-descendant 레이어에 그려지고, static 인 ✕ 버튼보다 위에 쌓여
   클릭을 가로챈다. 버튼을 같은 레이어로 올려 히트 순서를 되돌린다. */
.price-alarm-chip.is-revealed .pa-close {
  display: inline-block;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  cursor: pointer;
  margin-left: 2px;
  padding: 0 4px;
  font-size: 9px;
  line-height: 1.3;
  color: #8b949e;
  background: rgba(13, 17, 23, 0.96);
  border: 1px solid #484f58;
  border-radius: 2px;
}

.price-alarm-chip.is-revealed .pa-close:hover {
  color: #f0f6fc;
  border-color: #8b949e;
}

/* 노출된 칩은 손가락으로 잡아야 하므로 터치 그랩 영역을 넓힌다(시각 영향 없음).
   pseudo 영역을 눌러도 event.target 은 .price-alarm-chip 으로 해석된다. */
.price-alarm-chip.is-revealed::before {
  content: '';
  position: absolute;
  left: -14px;
  right: -14px;
  top: -14px;
  bottom: -14px;
}

.price-alarm-chip.is-dragging {
  opacity: 1;
  border-style: dashed;
}

/* ── 알람 스냅샷 카드 (createAlarmSnapshotToast) ─────────────────────────────
   발동 알림을 텍스트 토스트 대신 "그때의 차트 그림" 으로 띄운다. 우상단 스택 →
   8초 자동 소멸 → 카드 클릭 시 확대 팝업.

   앱 토스트(GoldMiner .toast-container z=1000대 / FXTester .fx-toast-container
   z=2000)보다 위에 둔다 — 알람은 그림을 봐야 의미가 있으므로 가려지면 안 된다.
   카드가 항상 다크인 이유: 안에 든 스냅샷 배경이 차트색(#0d1117)이라 라이트 테마
   에서도 다크 카드가 이미지와 이어져 보인다. */

.alarm-snap-stack {
  position: fixed;
  top: 60px;
  right: 14px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none; /* 카드만 받는다 — 스택 빈 공간이 차트 클릭을 먹지 않게 */
}

.alarm-snap-card {
  position: relative;
  width: 300px;
  padding: 0 0 6px;
  background: rgba(13, 17, 23, 0.97);
  border: 1px solid #e3b341;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.alarm-snap-card.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.alarm-snap-card.is-leaving {
  opacity: 0;
  transform: translateX(16px);
}

.alarm-snap-card[role='status'] {
  cursor: default; /* 스냅샷이 없으면 확대할 것도 없다 */
}

.alarm-snap-thumb {
  display: block;
  width: 100%;
  height: auto;
  max-height: 170px;
  object-fit: cover;
  object-position: center right; /* 최신 캔들 쪽을 남긴다 */
  background: #0d1117;
  border-bottom: 1px solid #30363d;
}

.alarm-snap-thumb--empty {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #6e7681;
}

.alarm-snap-body {
  padding: 6px 26px 0 10px;
}

.alarm-snap-title {
  font-size: 12px;
  font-weight: 600;
  color: #f0f6fc;
  line-height: 1.35;
}

.alarm-snap-sub {
  margin-top: 2px;
  font-size: 10px;
  color: #8b949e;
  line-height: 1.3;
}

.alarm-snap-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  width: 20px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: #c9d1d9;
  background: rgba(13, 17, 23, 0.82);
  border: 1px solid #484f58;
  border-radius: 3px;
  cursor: pointer;
}

.alarm-snap-close:hover {
  color: #f0f6fc;
  border-color: #8b949e;
}

/* ── 확대 팝업 ─────────────────────────────────────────────────────────── */

.alarm-snap-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(1, 4, 9, 0.82);
}

.alarm-snap-lightbox-inner {
  position: relative;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
  padding: 8px;
  background: rgba(13, 17, 23, 0.98);
  border: 1px solid #30363d;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
}

.alarm-snap-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 46px);
  width: auto;
  height: auto;
  border-radius: 4px;
}

.alarm-snap-lightbox-caption {
  padding: 6px 4px 2px;
  font-size: 12px;
  color: #c9d1d9;
  text-align: center;
}

.alarm-snap-lightbox-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: #f0f6fc;
  background: #21262d;
  border: 1px solid #8b949e;
  border-radius: 50%;
  cursor: pointer;
}

.alarm-snap-lightbox-close:hover {
  background: #30363d;
}

@media (max-width: 720px) {
  .alarm-snap-stack {
    top: auto;
    bottom: 12px;
    right: 8px;
    left: 8px;
  }

  .alarm-snap-card {
    width: auto;
  }
}
