/* ═══════════════════════════════════════════════════════════════════════════
   App Popup Design System (TradeAlertModal / tam- 기준)
   신규 팝업: AppPopup 컴포넌트 + app-popup-* 클래스 사용
   ═══════════════════════════════════════════════════════════════════════════ */

.app-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}
.app-popup-overlay--dim {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.45);
}
.app-popup-overlay--dim > .app-popup-shell,
.app-popup-overlay--dim > .tam-modal,
.app-popup-overlay--dim > .lsp-modal,
.app-popup-overlay--dim > .gc-popup-panel,
.brm-overlay > .brm-modal,
.ism-overlay > .ism-dialog,
.ibsm-overlay > .ibsm-dialog,
.mcs-overlay > .mcs-dialog,
.dsm-overlay > .dsm-dialog,
.sp-modal-overlay > .sp-modal,
.obj-tree-overlay > .obj-tree-panel,
.ind-overlay > .ind-panel,
.plsp-overlay > .plsp-popup,
.login-modal-backdrop > .login-modal {
  pointer-events: auto;
}

.app-popup-overlay > .app-popup-shell,
.tam-overlay > .tam-modal,
.lsp-overlay > .lsp-modal {
  pointer-events: auto;
}

/* ── 셸 (모달 컨테이너) ── */
.app-popup-shell,
.tam-modal,
.lsp-modal,
.gc-popup-panel,
.bts-modal,
.brm-modal,
.ism-dialog,
.ibsm-dialog,
.mcs-dialog,
.dsm-dialog,
.sp-modal,
.obj-tree-panel,
.ind-panel,
.plsp-popup,
.indicator-modal,
.login-modal {
  position: fixed;
  display: flex;
  flex-direction: column;
  background: var(--bg2, #1e222d);
  border: 1px solid var(--app-popup-accent, var(--tam-accent, rgba(63, 126, 245, 0.35)));
  border-radius: 12px;
  box-shadow:
    0 0 0 1px var(--app-popup-accent-glow, var(--tam-accent-glow, rgba(63, 126, 245, 0.08))),
    0 20px 60px rgba(0, 0, 0, 0.65),
    0 0 40px var(--app-popup-accent-glow, rgba(63, 126, 245, 0.06));
  overflow: hidden;
  font-size: 13px;
  color: var(--text, #c0caf5);
  font-family: var(--font, 'Noto Sans KR', sans-serif);
  max-width: 96vw;
  max-height: 90vh;
}

/* ── 헤더 ── */
.app-popup-header,
.gc-popup-header.tam-header,
.gc-popup-header.lsp-header,
.gc-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border-bottom: 1px solid var(--border, rgba(122, 162, 247, 0.12));
  background: linear-gradient(
    180deg,
    rgba(63, 126, 245, 0.14) 0%,
    rgba(63, 126, 245, 0.04) 28px,
    var(--bg3, #1f2335) 100%
  );
}
.app-popup-header:active,
.gc-popup-header:active { cursor: grabbing; }

.app-popup-header-left,
.tam-header-left,
.lsp-header-left {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.app-popup-badge,
.tam-badge,
.lsp-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1.2px;
  flex-shrink: 0;
}

.app-popup-header-title,
.tam-header-title,
.lsp-header-title,
.gc-popup-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #c0caf5);
  letter-spacing: 0.4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-popup-header-ko,
.tam-header-ko,
.lsp-header-ko {
  font-size: 12px;
  font-weight: 400;
  color: var(--text2, #9aa5ce);
}

.app-popup-close,
.tam-close,
.lsp-close,
.gc-popup-close,
.bts-close,
.brm-close,
.ism-close,
.ibsm-close,
.login-modal-close {
  background: none;
  border: none;
  color: var(--text3, #6272a4);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.app-popup-close:hover,
.tam-close:hover,
.lsp-close:hover,
.gc-popup-close:hover,
.bts-close:hover,
.brm-close:hover { color: var(--text, #c0caf5); background: var(--bg4, rgba(255, 255, 255, 0.07)); }

/* ── 본문 ── */
.app-popup-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.app-popup-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, rgba(122, 162, 247, 0.1));
}
.app-popup-section--gradient {
  background: linear-gradient(
    135deg,
    var(--app-popup-accent-glow, rgba(63, 126, 245, 0.08)) 0%,
    transparent 60%
  );
}

.app-popup-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 14px;
  padding: 11px 14px;
  background: var(--bg3, #1f2335);
  border: 1px solid var(--border, rgba(122, 162, 247, 0.12));
  border-radius: 9px;
}

.app-popup-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-popup-field-label {
  font-size: 11.5px;
  color: var(--text2, #9aa5ce);
  flex-shrink: 0;
  min-width: 42px;
}

.app-popup-input,
.app-popup-select {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  background: var(--bg3, #1f2335);
  border: 1px solid var(--border, rgba(122, 162, 247, 0.18));
  border-radius: 6px;
  outline: none;
  color: var(--text, #c0caf5);
  font-size: 12.5px;
  padding: 7px 10px;
  transition: border-color 0.15s;
}
.app-popup-input:focus,
.app-popup-select:focus {
  border-color: var(--app-popup-accent, #3f7ef5);
}

.app-popup-btn {
  padding: 7px 11px;
  border: 1px solid var(--border, rgba(122, 162, 247, 0.18));
  border-radius: 6px;
  background: var(--bg3, #1f2335);
  color: var(--text2, #9aa5ce);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.app-popup-btn:hover {
  border-color: var(--app-popup-accent, #3f7ef5);
  color: var(--text, #c0caf5);
  background: var(--bg4, #414868);
}
.app-popup-btn--primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--app-popup-accent, #3f7ef5);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 4px 16px var(--app-popup-accent-glow, rgba(63, 126, 245, 0.25));
}
.app-popup-btn--primary:hover { opacity: 0.92; }

.app-popup-disclaimer {
  font-size: 10.5px;
  color: var(--text3, #6272a4);
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

/* 레거시 오버레이 통일 */
.brm-overlay,
.ism-overlay,
.ibsm-overlay,
.mcs-overlay,
.dsm-overlay,
.sp-modal-overlay,
.obj-tree-overlay,
.ind-overlay,
.plsp-overlay,
.login-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.45);
}

/* 라이트 테마 — body 포털(html.theme-light) · 앱 내부(.app.light) 공통 */
html.theme-light .app-popup-shell,
.app.light .app-popup-shell,
html.theme-light .tam-modal,
.app.light .tam-modal,
html.theme-light .lsp-modal,
.app.light .lsp-modal,
html.theme-light .gc-popup-panel,
.app.light .gc-popup-panel,
html.theme-light .bts-modal,
.app.light .bts-modal,
html.theme-light .brm-modal,
.app.light .brm-modal,
html.theme-light .ism-dialog,
.app.light .ism-dialog,
html.theme-light .login-modal,
.app.light .login-modal {
  background: #ffffff;
  border-color: rgba(25, 118, 210, 0.35);
  color: #212121;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 0 40px rgba(25, 118, 210, 0.08);
}
html.theme-light .app-popup-header,
.app.light .app-popup-header,
html.theme-light .gc-popup-header,
.app.light .gc-popup-header {
  background: linear-gradient(180deg, rgba(25, 118, 210, 0.1) 0%, #f5f7fa 100%);
  border-color: rgba(0, 0, 0, 0.1);
}
html.theme-light .app-popup-header-title,
.app.light .app-popup-header-title,
html.theme-light .gc-popup-title,
.app.light .gc-popup-title { color: #1a237e; }
html.theme-light .app-popup-header-ko,
.app.light .app-popup-header-ko { color: #546e7a; }
html.theme-light .app-popup-card,
.app.light .app-popup-card { background: #f5f7fa; border-color: rgba(0, 0, 0, 0.1); }
html.theme-light .app-popup-input,
.app.light .app-popup-input,
html.theme-light .app-popup-select,
.app.light .app-popup-select { background: #f0f3f8; border-color: rgba(0, 0, 0, 0.12); color: #212121; }
