/* ===== GetLove Notification UI v3 — LINE 風格對話視窗 =====
   設計原則:
   - 模擬 LINE 真實對話視窗(頂部 navbar / 訊息泡泡 / 模擬輸入欄)
   - 主色:LINE 綠 #06C755 + 白底 + 對話區 #EEF2F5
   - 字體:Hiragino Sans / 微軟正黑體 / Noto Sans TC(LINE 風)
   - 整個視窗點擊 → 開 LINE(齒輪/關閉鈕排除)
   - 動態高度:讀 --bottom-dock-reserved-height 自動避開底部 dock
*/

/* ========== Toast 主容器(LINE 對話視窗) ========== */
.gn-toast {
  position: fixed;
  bottom: var(--gn-bottom-offset, 28px);
  right: var(--gn-right-offset, 28px);
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--gn-bottom-offset, 28px) - 24px);
  max-height: calc(100dvh - var(--gn-bottom-offset, 28px) - 24px);
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.18),
    0 6px 14px rgba(15, 23, 42, 0.12);
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Sans GB",
    "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Segoe UI", sans-serif;
  color: #2c3239;
  z-index: 99999;
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.36s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* 平板+手機:讀取頁面 --bottom-dock-reserved-height 動態避開底部 dock */
@media (max-width: 900px) {
  .gn-toast {
    --gn-bottom-offset: calc(var(--bottom-dock-reserved-height, 28px) + 12px);
  }
}

@media (max-width: 480px) {
  .gn-toast {
    --gn-bottom-offset: calc(var(--bottom-dock-reserved-height, 16px) + 12px);
    --gn-right-offset: 12px;
    width: calc(100vw - 24px);
    border-radius: 12px;
  }
}

.gn-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gn-toast.is-leaving {
  opacity: 0;
  transform: translateY(40px);
}

.gn-toast:hover {
  box-shadow:
    0 22px 48px rgba(15, 23, 42, 0.22),
    0 8px 18px rgba(15, 23, 42, 0.14);
}

.gn-toast:focus-visible {
  outline: 2px solid #06c755;
  outline-offset: 2px;
}

/* ========== Header(LINE 綠頂條) ========== */
.gn-toast-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  background: linear-gradient(180deg, #06c755 0%, #04b34c 100%);
  color: #ffffff;
  position: relative;
  flex: 0 0 auto;
}

/* 大頭貼(支援 img 圖片或字母 fallback) */
.gn-toast-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #e8f9ef 100%);
  color: #06c755;
  font-size: 18px;
  font-weight: 700;
  font-family: "Microsoft JhengHei", "PingFang TC", "Hiragino Sans", sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 1px 4px rgba(0, 0, 0, 0.12);
  letter-spacing: 0;
  overflow: hidden;
}

.gn-toast-avatar img,
.gn-toast-avatar .gn-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
  user-select: none;
  -webkit-user-drag: none;
}

/* 名字+線上狀態 */
.gn-toast-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.gn-toast-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  line-height: 1.2;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 線上狀態小亮點 */
.gn-toast-name::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffe066;
  box-shadow: 0 0 0 2px rgba(255, 224, 102, 0.32);
  flex: 0 0 7px;
  animation: gn-pulse 2.4s ease-in-out infinite;
}

@keyframes gn-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.gn-toast-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.86);
  letter-spacing: 0.2px;
  margin-top: 2px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 右上角圖示按鈕(齒輪/關閉) */
.gn-toast-actions {
  display: flex;
  gap: 1px;
  flex: 0 0 auto;
  margin-left: 4px;
}

.gn-icon-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  transition:
    color 0.18s,
    background 0.18s,
    transform 0.12s;
  padding: 0;
  font-family: inherit;
}

.gn-icon-btn:hover,
.gn-icon-btn:focus-visible {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}

.gn-icon-btn:active {
  transform: scale(0.92);
}

.gn-icon-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

/* 收起按鈕特化:藥丸形 + 文字 label, 避免被誤會成「關掉音樂」 */
.gn-close {
  width: auto;
  min-width: 54px;
  padding: 0 9px;
  gap: 3px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  font-family: inherit;
}

.gn-close:hover,
.gn-close:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.gn-close svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}

.gn-close-label {
  line-height: 1;
  white-space: nowrap;
  color: #ffffff;
}

/* ========== Body(對話訊息區) ========== */
.gn-toast-body {
  padding: 14px 12px 10px;
  background: #eef2f5;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.gn-toast-body-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06c755 0%, #04a045 100%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  font-family: "Microsoft JhengHei", "PingFang TC", sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  margin-top: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.gn-toast-body-avatar img,
.gn-toast-body-avatar .gn-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
  user-select: none;
  -webkit-user-drag: none;
}

.gn-toast-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1 1 auto;
  min-width: 0;
}

/* 訊息泡泡(LINE 對方訊息白底 + 左上小箭頭) */
.gn-toast-content {
  position: relative;
  background: #ffffff;
  color: #2c3239;
  font-size: 14.5px;
  line-height: 1.65;
  padding: 10px 13px;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.06);
  word-break: break-word;
  letter-spacing: 0.2px;
  max-width: 100%;
  font-weight: 400;
}

/* 左上小箭頭(指向頭像) */
.gn-toast-content::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 7px 7px 0;
  border-color: transparent #ffffff transparent transparent;
  filter: drop-shadow(-1px 0 0.5px rgba(0, 0, 0, 0.04));
}

/* 已讀+時間(泡泡下方) */
.gn-toast-meta-row {
  font-size: 10.5px;
  color: #8a939e;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 4px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.gn-toast-read {
  color: #06c755;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ========== Footer(模擬輸入欄) ========== */
.gn-toast-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 10px;
  background: #f7f8fa;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  flex: 0 0 auto;
}

.gn-toast-input {
  flex: 1 1 auto;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 13px;
  color: #aab1bb;
  letter-spacing: 0.3px;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  transition:
    border-color 0.18s,
    color 0.18s;
}

.gn-toast:hover .gn-toast-input {
  border-color: rgba(6, 199, 85, 0.32);
  color: #6e7681;
}

.gn-toast-send {
  background: linear-gradient(180deg, #06c755 0%, #04b34c 100%);
  color: #ffffff;
  border: 0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 32px;
  transition:
    transform 0.18s,
    box-shadow 0.18s,
    background 0.18s;
  box-shadow: 0 2px 5px rgba(6, 199, 85, 0.32);
  padding: 0;
}

.gn-toast-send:hover,
.gn-toast-send:focus-visible {
  background: linear-gradient(180deg, #07d65b 0%, #05c051 100%);
  transform: scale(1.06);
  box-shadow: 0 3px 8px rgba(6, 199, 85, 0.42);
  outline: none;
}

.gn-toast-send:active {
  transform: scale(0.96);
}

.gn-toast-send svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
  margin-left: 1px;
}

/* 手機版微調 */
@media (max-width: 480px) {
  .gn-toast-header {
    padding: 9px 10px 9px 12px;
  }
  .gn-toast-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    font-size: 16px;
  }
  .gn-toast-name {
    font-size: 14px;
  }
  .gn-toast-status {
    font-size: 10.5px;
  }
  .gn-toast-body {
    padding: 12px 10px 9px;
  }
  .gn-toast-content {
    font-size: 14px;
    line-height: 1.6;
    padding: 9px 12px;
  }
  .gn-toast-footer {
    padding: 8px 9px 9px;
  }
  .gn-toast-input {
    font-size: 12.5px;
    padding: 6px 12px;
  }
  .gn-toast-send {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
  }
}

/* ========== 設定選單(LINE 風配色) ========== */
.gn-menu {
  position: fixed;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 16px 40px rgba(15, 23, 42, 0.22),
    0 4px 12px rgba(15, 23, 42, 0.1);
  min-width: 220px;
  z-index: 100000;
  padding: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.24s ease,
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  overflow: hidden;
}

.gn-menu.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gn-menu-item {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 9px 12px;
  font-size: 13.5px;
  color: #2c3239;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.3px;
  transition:
    background 0.16s,
    color 0.16s;
  font-weight: 400;
}

.gn-menu-item:hover,
.gn-menu-item:focus-visible {
  background: rgba(6, 199, 85, 0.08);
  color: #06c755;
  outline: none;
}

.gn-menu-item.is-warn {
  color: #d04a4a;
}

.gn-menu-item.is-warn:hover {
  background: rgba(208, 74, 74, 0.08);
  color: #b03838;
}

.gn-menu-sep {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 4px 6px;
}

.gn-menu-item.is-cancel {
  color: rgba(44, 50, 57, 0.6);
  font-size: 12.5px;
}

/* ========== 確認彈窗 ========== */
.gn-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.28s ease;
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
}

.gn-confirm-overlay.is-visible {
  opacity: 1;
}

.gn-confirm {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px 26px 20px;
  width: 100%;
  max-width: 380px;
  box-shadow:
    0 28px 60px rgba(15, 23, 42, 0.32),
    0 8px 22px rgba(15, 23, 42, 0.18);
  transform: scale(0.94) translateY(8px);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.gn-confirm-overlay.is-visible .gn-confirm {
  transform: scale(1) translateY(0);
}

.gn-confirm-title {
  font-size: 17px;
  font-weight: 600;
  color: #2c3239;
  margin: 0 0 10px;
  letter-spacing: 0.4px;
}

.gn-confirm-msg {
  font-size: 13.5px;
  color: #5a6573;
  line-height: 1.7;
  margin: 0 0 20px;
  letter-spacing: 0.3px;
}

.gn-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.gn-btn {
  border: 1px solid transparent;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.6px;
  transition: all 0.18s;
}

.gn-btn-cancel {
  background: transparent;
  color: #5a6573;
  border-color: rgba(0, 0, 0, 0.12);
}

.gn-btn-cancel:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #2c3239;
  border-color: rgba(0, 0, 0, 0.2);
}

.gn-btn-danger {
  background: #d04a4a;
  color: #ffffff;
  border-color: #d04a4a;
}

.gn-btn-danger:hover {
  background: #b03838;
  border-color: #b03838;
}

.gn-btn:active {
  transform: scale(0.97);
}

/* ========== 右下小鈴鐺(關閉/暫停期間) ========== */
.gn-bell {
  position: fixed;
  bottom: var(--gn-bottom-offset, 28px);
  right: var(--gn-right-offset, 28px);
  background: linear-gradient(180deg, #06c755 0%, #04b34c 100%);
  color: #ffffff;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow:
    0 12px 28px rgba(6, 199, 85, 0.32),
    0 4px 10px rgba(6, 199, 85, 0.2);
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.6px;
  z-index: 99998;
  opacity: 0.92;
  transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 900px) {
  .gn-bell {
    --gn-bottom-offset: calc(var(--bottom-dock-reserved-height, 28px) + 12px);
  }
}

@media (max-width: 480px) {
  .gn-bell {
    --gn-bottom-offset: calc(var(--bottom-dock-reserved-height, 16px) + 12px);
    --gn-right-offset: 12px;
    padding: 8px 14px;
    font-size: 12px;
  }
}

.gn-bell:hover,
.gn-bell:focus-visible {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow:
    0 16px 36px rgba(6, 199, 85, 0.42),
    0 6px 14px rgba(6, 199, 85, 0.28);
  outline: none;
}

.gn-bell-icon {
  font-size: 13px;
  line-height: 1;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
}

.gn-bell-text:empty {
  display: none;
}

/* 鈴鐺與通知不重疊 */
.gn-toast.is-visible ~ .gn-bell {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .gn-toast,
  .gn-menu,
  .gn-confirm-overlay,
  .gn-confirm,
  .gn-bell {
    transition-duration: 0.01ms !important;
  }
  .gn-toast-name::after {
    animation: none;
  }
}
