/* ============================================================
   Dr.A 閒置視窗 Idle Popup v2（正式版）
   主題色：#49AA46（家電站綠）
   ------------------------------------------------------------
   重要：本站有載入 Bootstrap（含 .card / .card-body / .card-title
   等通用類名），為避免衝突，彈窗內所有類名皆改用 ipv2- 前綴，
   並將所有樣式限定在 .idle-popup-v2 作用域下，
   絕不影響站上其他區塊。
   請放到 /assets/css/custom/idle-popup.css 並在 header 載入。
   ============================================================ */

:root {
  --ipv2-brand: #49AA46;
  --ipv2-brand-dark: #3C8A3A;
  --ipv2-brand-tint: #EAF7EC;
  --ipv2-text-primary: #1e2a32;
  --ipv2-text-secondary: #5b6b76;
  --ipv2-text-muted: #93a1ab;
  --ipv2-border-color: #e6ecf0;
  --ipv2-bg-soft: #f5f8fa;
  --ipv2-price-color: #e5484d;
  --ipv2-radius: 14px;
  --ipv2-gap: 16px;
}

/* ---------- 外框：反灰底 + 置中容器（預設隱藏） ---------- */

.idle-popup-v2-bg {
  position: fixed;
  inset: 0;
  background: rgba(30, 41, 51, .5);
  z-index: 999998;
  display: none;
}
.idle-popup-v2-bg.ipv2-open { display: block; }

.idle-popup-v2 {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: 28px;
  -webkit-overflow-scrolling: touch;
  font-family: "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "Noto Sans TC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.idle-popup-v2.ipv2-open { display: flex; }

/* 作用域內基礎重置（僅影響彈窗內部，抵消 Bootstrap 對 button/ul/h2… 的預設） */
.idle-popup-v2 * { margin: 0; padding: 0; box-sizing: border-box; }
.idle-popup-v2 a { text-decoration: none; }
.idle-popup-v2 button { background: none; border: none; }

.idle-popup-v2 .ipv2-window {
  background: #ffffff;
  width: 760px;
  max-width: 100%;
  margin: auto;
  border-radius: 18px;
  padding: 24px 32px 20px;
  box-shadow: 0 24px 64px rgba(15, 35, 50, .28);
  position: relative;
}

/* ---------- 頂部：回首頁 / 標題 / 關閉 ---------- */

.idle-popup-v2 .ipv2-header { display: flex; align-items: flex-start; gap: 14px; }

.idle-popup-v2 .ipv2-icon-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--ipv2-bg-soft);
  color: var(--ipv2-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.idle-popup-v2 .ipv2-icon-btn:hover { background: var(--ipv2-brand-tint); color: var(--ipv2-brand-dark); }

.idle-popup-v2 .ipv2-header-text { flex: 1; min-width: 0; padding-top: 1px; }
.idle-popup-v2 .ipv2-header-text h2 { font-size: 17px; font-weight: 700; color: var(--ipv2-text-primary); letter-spacing: .3px; }
.idle-popup-v2 .ipv2-header-text p { font-size: 12.5px; color: var(--ipv2-text-muted); margin-top: 4px; line-height: 1.6; }

/* ---------- 分頁 ---------- */

.idle-popup-v2 .ipv2-tab-list {
  display: flex;
  gap: 26px;
  margin-top: 18px;
  border-bottom: 1px solid var(--ipv2-border-color);
}
.idle-popup-v2 .ipv2-tab {
  padding: 0 2px 11px;
  font-size: 15px;
  cursor: pointer;
  color: var(--ipv2-text-muted);
  position: relative;
  font-weight: 500;
  background: none;
  border: none;
  font-family: inherit;
}
.idle-popup-v2 .ipv2-tab.ipv2-active { color: var(--ipv2-text-primary); font-weight: 700; }
.idle-popup-v2 .ipv2-tab.ipv2-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--ipv2-brand);
}

/* ---------- 搜尋列 ---------- */

.idle-popup-v2 .ipv2-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  background: var(--ipv2-bg-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 8px 0 16px;
  height: 44px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.idle-popup-v2 .ipv2-search:focus-within {
  background: #ffffff;
  border-color: var(--ipv2-brand);
  box-shadow: 0 0 0 4px rgba(73, 170, 70, .12);
}
.idle-popup-v2 .ipv2-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--ipv2-text-primary);
  font-family: inherit;
  height: 100%;
}
.idle-popup-v2 .ipv2-search-input::placeholder { color: var(--ipv2-text-muted); }
.idle-popup-v2 .ipv2-search-btn {
  flex: none;
  border: none;
  cursor: pointer;
  background: var(--ipv2-brand);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 9px;
  transition: background .15s;
  font-family: inherit;
}
.idle-popup-v2 .ipv2-search-btn:hover { background: var(--ipv2-brand-dark); }

/* ---------- 共用四欄格線 ---------- */

.idle-popup-v2 .ipv2-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--ipv2-gap);
}

.idle-popup-v2 .ipv2-tab-content { margin-top: 22px; }
.idle-popup-v2 .ipv2-col-header-row { margin-bottom: 12px; }

.idle-popup-v2 .ipv2-col-header {
  grid-column: span 2;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
}

.idle-popup-v2 .ipv2-col-title {
  color: var(--ipv2-text-primary);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
  transition: color .15s;
}
.idle-popup-v2 .ipv2-col-title:hover { color: var(--ipv2-brand-dark); }
.idle-popup-v2 .ipv2-col-title h3 { font-size: 15px; font-weight: 700; display: inline; }

.idle-popup-v2 .ipv2-col-stat { font-size: 12px; color: var(--ipv2-text-muted); white-space: nowrap; }

/* ---------- 卡片 ---------- */

.idle-popup-v2 .ipv2-card {
  min-width: 0;
  cursor: pointer;
  border-radius: var(--ipv2-radius);
  display: flex;
  flex-direction: column;
  border: none;
  background: transparent;
  transition: transform .18s, box-shadow .18s;
}
.idle-popup-v2 .ipv2-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15, 35, 50, .10); }
.idle-popup-v2 .ipv2-card:hover .ipv2-card-title { color: var(--ipv2-brand-dark); }

.idle-popup-v2 .ipv2-card-link { display: block; }

.idle-popup-v2 .ipv2-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  flex: none;
  display: block;
  object-fit: cover;
  border-radius: var(--ipv2-radius) var(--ipv2-radius) 0 0;
  background: var(--ipv2-bg-soft);
}
.idle-popup-v2 .ipv2-thumb-square { aspect-ratio: 1 / 1; }

.idle-popup-v2 .ipv2-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--ipv2-border-color);
  border-top: none;
  border-radius: 0 0 var(--ipv2-radius) var(--ipv2-radius);
  padding: 11px 12px 12px;
  background: #fff;
}
.idle-popup-v2 .ipv2-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ipv2-text-primary);
  line-height: 1.6;
  transition: color .15s;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.idle-popup-v2 .ipv2-card-title a { color: inherit; text-decoration: none; font-size: 13px;}

.idle-popup-v2 .ipv2-card-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 12px;
  color: var(--ipv2-text-muted);
}
.idle-popup-v2 .ipv2-card-details-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--ipv2-text-muted); }
.idle-popup-v2 .ipv2-card-details-item .fa { color: var(--ipv2-text-muted); }

/* ---------- 商品卡 ---------- */

.idle-popup-v2 .ipv2-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 10px;
}
.idle-popup-v2 .ipv2-price-old {
  font-size: 12px;
  color: var(--ipv2-text-muted);
  text-decoration: line-through;
  white-space: nowrap;
}
.idle-popup-v2 .ipv2-price-new {
  font-size: 16px;
  font-weight: 700;
  color: var(--ipv2-price-color);
  white-space: nowrap;
  letter-spacing: .2px;
}
.idle-popup-v2 .ipv2-price-new small { font-size: 12px; font-weight: 600; margin-right: 1px; }

.idle-popup-v2 .ipv2-actions { display: flex; gap: 8px; margin-top: 10px; }
.idle-popup-v2 .ipv2-cart-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ipv2-border-color);
  background: #ffffff;
  color: var(--ipv2-text-secondary);
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s, background .15s;
}
.idle-popup-v2 .ipv2-cart-btn:hover { border-color: var(--ipv2-brand); color: var(--ipv2-brand); background: var(--ipv2-brand-tint); }
.idle-popup-v2 .ipv2-detail-btn {
  flex: 1;
  height: 34px;
  border: 1px solid var(--ipv2-brand);
  background: #ffffff;
  color: var(--ipv2-brand);
  border-radius: 9px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.idle-popup-v2 .ipv2-detail-btn:hover { background: var(--ipv2-brand); color: #ffffff; }

/* ---------- 底部按鈕 ---------- */

.idle-popup-v2 .ipv2-footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--ipv2-border-color);
}
.idle-popup-v2 .ipv2-footer-btn {
  position: relative;
  grid-column: span 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  cursor: pointer;
  background: var(--ipv2-brand-tint);
  color: var(--ipv2-brand-dark);
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 0;
  border-radius: 10px;
  transition: background .15s, color .15s;
  min-width: 0;
  font-family: inherit;
}
.idle-popup-v2 .ipv2-footer-btn + .ipv2-footer-btn::before {
  content: "";
  position: absolute;
  left: calc(var(--ipv2-gap) / -2);
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 16px;
  background: var(--ipv2-border-color);
}
.idle-popup-v2 .ipv2-footer-btn svg { color: var(--ipv2-brand-dark); transition: color .15s; flex: none; }
.idle-popup-v2 .ipv2-footer-btn:hover { background: var(--ipv2-brand); color: #ffffff; }
.idle-popup-v2 .ipv2-footer-btn:hover svg { color: #ffffff; }

/* ---------- 分頁面板（用 !important 確保不被站上樣式覆蓋） ---------- */

.idle-popup-v2 .ipv2-panel { display: none !important; }
.idle-popup-v2 .ipv2-panel.ipv2-active { display: block !important; }

/* ---------- 手機版：講座/消息各 1 篇、商品 2 個 ---------- */

@media (max-width: 640px) {
  .idle-popup-v2 { padding: 14px; }
  .idle-popup-v2 .ipv2-window { padding: 18px 16px 16px; border-radius: 16px; }
  .idle-popup-v2 .ipv2-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .idle-popup-v2 .ipv2-col-header { grid-column: span 1; }
  .idle-popup-v2 .ipv2-col-stat { flex-basis: 100%; }
  .idle-popup-v2 .ipv2-col-header-full { grid-column: span 2 !important; }
  .idle-popup-v2 .ipv2-mobile-hidden { display: none; }
  .idle-popup-v2 .ipv2-footer-btn { grid-column: span 1; }
  .idle-popup-v2 .ipv2-footer-btn + .ipv2-footer-btn::before { left: -6px; }
  .idle-popup-v2 .ipv2-header-text h2 { font-size: 15.5px; }
  .idle-popup-v2 .ipv2-tab-list { gap: 20px; }
}