/* ========== 1. 基礎樣式 (Member News feed ads) ========== */
#memberNewsModal .kms-feed-ad-header-btn span,
.kms-feed-ad-modal-root .kms-feed-ad-modal__head h2 {
  font-weight: 700;
  color: #e8ecf4;
}

.kms-feed-ad-modal-root .glass-modal {
  background: linear-gradient(155deg, rgba(36, 44, 72, 0.92) 0%, rgba(24, 28, 48, 0.94) 100%);
  border: 1px solid rgba(120, 140, 200, 0.35);
  color: #dce2f0;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.kms-feed-ad-modal__hint,
.kms-feed-ad-policy {
  font-size: 13px;
  line-height: 1.55;
  color: #aeb8d4;
  margin: 0 0 14px;
}

.kms-feed-ad-input,
.kms-feed-ad-textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(120, 140, 200, 0.35);
  background: rgba(14, 18, 32, 0.65);
  color: #e8ecf4;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

/* 隱藏原生 file，改由 .kms-file-input-trigger 觸發（Safari 相容） */
.kms-file-input-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.kms-feed-ad-file-wrap {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.kms-file-input-name {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
  color: #aeb8d4;
  word-break: break-all;
}

.kms-feed-ad-textarea {
  resize: vertical;
  min-height: 88px;
  max-height: 200px;
}

.kms-feed-ad-form__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #9aa6cc;
  margin: 12px 0 6px;
}

.kms-feed-ad-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
  color: #c5cee8;
  cursor: pointer;
}

.kms-feed-ad-modal-root .kms-feed-ad-check input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid rgba(120, 140, 200, 0.45);
  background: rgba(14, 18, 32, 0.85);
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.06);
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kms-feed-ad-modal-root .kms-feed-ad-check input[type="checkbox"]:checked {
  border-color: rgba(255, 186, 0, 0.65);
  background: linear-gradient(145deg, #fff8e8, #ffba00);
  box-shadow:
    0 2px 8px rgba(255, 186, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.kms-feed-ad-modal-root .kms-feed-ad-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: 2px solid #1f2436;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg);
}

/* 數字欄隱藏上下微調箭頭（內建 spinner） */
.kms-feed-ad-modal-root input[type="number"] {
  -moz-appearance: textfield;
}

.kms-feed-ad-modal-root input[type="number"]::-webkit-outer-spin-button,
.kms-feed-ad-modal-root input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ========== 2. 布局樣式 ========== */
.kms-feed-ad-modal {
  position: relative;
  z-index: 2;
  width: 92%;
  max-width: 520px;
  max-height: min(88vh, 720px);
  border-radius: 20px;
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kms-feed-ad-modal--wide {
  max-width: 720px;
}

.kms-feed-ad-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.kms-feed-ad-modal__x {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #e8ecf4;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.kms-feed-ad-modal__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.kms-feed-ad-modal__scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.kms-feed-ad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.kms-feed-ad-grid::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.kms-feed-ad-slot {
  background: rgba(20, 26, 44, 0.75);
  border: 1px solid rgba(100, 120, 190, 0.35);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kms-feed-ad-slot__head {
  font-size: 14px;
  color: #e8ecf4;
}

.kms-feed-ad-slot__after {
  font-size: 12px;
  color: #7ec8ff;
  margin-left: 4px;
}

.kms-feed-ad-slot__status {
  font-size: 11px;
  color: #f0c674;
}

.kms-feed-ad-slot__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* 白色立體按鈕：與 #memberNewsModal 內 btn-confirm 相同（廣告彈層在 modal 外，需獨立作用域） */
.kms-feed-ad-modal-root .btn-confirm {
  all: unset !important;
  position: relative !important;
  border-radius: 999vw !important;
  background-color: transparent !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 10px 20px !important;
  box-sizing: border-box !important;
  transition: transform 0.05s linear !important;
  cursor: pointer !important;
  font-weight: 800 !important;
  font-size: 14px !important;
}

.kms-feed-ad-modal-root .btn-confirm::after {
  content: "" !important;
  position: absolute !important;
  z-index: 0 !important;
  width: calc(100% + 0.3em) !important;
  height: calc(100% + 0.3em) !important;
  top: -0.15em !important;
  left: -0.15em !important;
  border-radius: inherit !important;
  background: linear-gradient(-135deg, rgba(5, 5, 5, 0.5), transparent 20%, transparent 100%) !important;
  filter: blur(0.0125em) !important;
  opacity: 0.25 !important;
  mix-blend-mode: multiply !important;
}

.kms-feed-ad-modal-root .btn-sm {
  padding: 6px 12px !important;
  font-size: 12px !important;
}

.kms-feed-ad-modal-root .btn-sm::before {
  clip-path: inset(0 0 0 0 round 8px) !important;
}

.kms-feed-ad-modal-root .btn-sm::after {
  border-radius: 10px !important;
}

.kms-feed-ad-modal-root .btn-confirm::before {
  content: "" !important;
  position: absolute !important;
  inset: 0 !important;
  border-radius: inherit !important;
  background-image: linear-gradient(135deg, #ffffff, #f9f9f9) !important;
  z-index: 1 !important;
  box-shadow:
    0 0.05em 0.05em -0.01em rgba(5, 5, 5, 1),
    0 0.01em 0.01em -0.01em rgba(5, 5, 5, 0.5),
    0.15em 0.3em 0.1em -0.01em rgba(5, 5, 5, 0.25),
    -0.05em -0.05em 0.05em 0 inset rgba(5, 5, 5, 0.25),
    0 0 0.05em 0.2em inset rgba(255, 255, 255, 0.25),
    0.025em 0.05em 0.1em 0 inset rgba(255, 255, 255, 1),
    0.12em 0.12em 0.12em inset rgba(255, 255, 255, 0.25),
    -0.075em -0.25em 0.25em 0.1em inset rgba(5, 5, 5, 0.25) !important;
  clip-path: inset(0 0 0 0 round 999vw) !important;
}

.kms-feed-ad-modal-root .btn-confirm span {
  position: relative !important;
  z-index: 4 !important;
  color: #ffba00 !important;
  text-shadow: none !important;
  font-weight: 500 !important;
}

.kms-feed-ad-modal-root .btn-confirm:active {
  transform: scale(0.975) !important;
  transition: transform 0.01s linear !important;
}

.kms-feed-ad-modal-root .btn-confirm.active::before {
  background-image: linear-gradient(135deg, #ffba00, #ffc400) !important;
}

.kms-feed-ad-modal-root .btn-confirm.active span {
  color: #ffffff !important;
}

.kms-feed-ad-duration-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kms-feed-ad-modal-root .btn-confirm.kms-feed-ad-submit {
  width: 100%;
  margin-top: 16px;
  padding: 14px 22px !important;
  box-sizing: border-box !important;
}

.news-card.kms-feed-ad-card {
  position: relative;
  background: linear-gradient(160deg, rgba(42, 52, 88, 0.95) 0%, rgba(26, 32, 56, 0.96) 100%);
  border: 1px solid rgba(110, 168, 255, 0.35);
  overflow: visible;
}

.kms-feed-ad__ribbon {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #5ad8ff, #6b7cff);
  color: #0f1424;
  z-index: 2;
}

.kms-feed-ad__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 36px 12px 8px 12px;
  border-bottom: 1px solid rgba(120, 140, 200, 0.2);
}

.kms-feed-ad__slot {
  font-size: 12px;
  color: #aeb8d4;
  flex: 1 1 auto;
}

.kms-feed-ad__timer {
  font-size: 11px;
  font-weight: 700;
  color: #f0c674;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 8px;
  border-radius: 8px;
}

.kms-feed-ad__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kms-feed-ad__body {
  padding: 12px 14px 16px;
}

.kms-feed-ad__title {
  margin: 0 0 8px;
  font-size: 17px;
  color: #e8ecf4;
}

.kms-feed-ad__text {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
  color: #c5cee8;
}

.kms-feed-ad__media {
  margin: 10px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(120, 140, 200, 0.25);
}

.kms-feed-ad__media img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}

.kms-feed-ad__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(90, 216, 255, 0.15);
  border: 1px solid rgba(90, 216, 255, 0.45);
  color: #7ec8ff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

/* ========== 3. 交互樣式 ========== */
@media (hover: hover) {
  .kms-feed-ad-modal__x:hover {
    background: rgba(255, 255, 255, 0.14);
  }

  .kms-feed-ad__link:hover {
    background: rgba(90, 216, 255, 0.28);
  }

  #memberNewsModal .kms-feed-ad-card .btn-confirm,
  .kms-feed-ad-modal-root .btn-confirm {
    cursor: pointer;
  }
}

/* 卡片內按鈕改為 btn-confirm，樣式由 #memberNewsModal .btn-confirm 提供；此處僅保留觸控優化 */
#memberNewsModal .kms-feed-ad-card .btn-confirm {
  touch-action: manipulation;
}

.kms-feed-ad-grid__loading,
.kms-feed-ad-grid__err {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: #9aa6cc;
}

/* ========== 4. 響應式樣式 ========== */
@media screen and (max-width: 600px) {
  .kms-feed-ad-modal {
    width: 96%;
    max-height: 92vh;
    padding: 14px 12px 16px;
  }

  .kms-feed-ad-grid {
    grid-template-columns: repeat(2, 1fr);
    max-height: 48vh;
  }

  .kms-feed-ad__top {
    padding-top: 40px;
  }

  .kms-feed-ad__actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@supports (-webkit-touch-callout: none) {
  .kms-feed-ad-modal__scroll,
  .kms-feed-ad-grid {
    -webkit-overflow-scrolling: touch;
  }
}
