/* PR-696: Billing v2 — Apple 風 customizer + GO 風 status hero
 *
 * 旧 5-step wizard を撤廃し、 単一画面で SNS 数選択 → 価格リアルタイム計算。
 * 旧 status table を dark gradient hero card に redesign。
 * mobile-first + 960px 以上で 2-column grid (customizer + sticky summary)。
 */

/* 0517 fix: 永続無料 (grandfathered) で customizer / summary / hero が CSS の
 * `display:grid` で HTML `[hidden]` を上書きされて見えてしまう問題。 [hidden] 属性が
 * 付いた要素は !important で display:none を強制し、 JS から hidden=true / style.display='none'
 * の両方で隠せるよう保険。 */
.bill-customizer[hidden],
.bill-summary[hidden],
.bill-hero[hidden] {
  display: none !important;
}

/* 0517 fix: 顧客向け UI に残る大文字英語ラベル (= テスト感を与える残骸) を一目で
 * 識別できるよう、 該当 class を持つ要素を赤文字 + 太字でマーキングする。
 * 開発時のチェック用、 順次日本語化していく際の目印。 */
.warn-english-leftover {
  color: #dc3545 !important;
  font-weight: 700 !important;
}


/* ================================================================
 * A: 「現在のご契約」 GO 風 dark hero
 * ================================================================ */
.bill-hero {
  position: relative;
  margin: 0 0 24px;
  padding: 28px 24px 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, #0e1530 0%, #18254d 45%, #2a3a72 100%);
  color: #f4f6ff;
  box-shadow: 0 24px 48px -28px rgba(10, 18, 50, 0.55);
  overflow: hidden;
  isolation: isolate;
}

.bill-hero::before {
  /* ロゴ透過装飾 (= GO のような大文字 watermark) */
  content: 'V';
  position: absolute;
  right: -28px;
  top: -16px;
  font-size: 240px;
  font-weight: 900;
  letter-spacing: -8px;
  line-height: 1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  pointer-events: none;
  z-index: 0;
}

.bill-hero__brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.62);
  text-transform: uppercase;
}

.bill-hero__rank {
  margin-left: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f7d168, #c89534);
  color: #1c1607;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
}

.bill-hero__rank.is-trialing { background: linear-gradient(135deg, #6ce6c8, #38a18a); color: #0a2a22; }
.bill-hero__rank.is-canceled { background: linear-gradient(135deg, #ff8b6a, #c4503a); color: #2a0d05; }
.bill-hero__rank.is-paused   { background: linear-gradient(135deg, #c1c8d8, #6a7390); color: #181c2a; }
.bill-hero__rank.is-grandfathered { background: linear-gradient(135deg, #b4c8ff, #5e7bd4); color: #0e1740; }

.bill-hero__plan {
  position: relative;
  z-index: 1;
  margin: 6px 0 18px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.bill-hero__meta {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px 22px;
  margin: 0 0 14px;
  padding: 0;
}
.bill-hero__meta dt {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  margin: 0 0 2px;
}
.bill-hero__meta dd {
  font-size: 15px;
  font-weight: 600;
  color: #f4f6ff;
  margin: 0;
}

.bill-hero__details {
  position: relative;
  z-index: 1;
  margin: 14px 0 0;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13.5px;
}

.bill-hero__details summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.92);
}
.bill-hero__details summary::-webkit-details-marker { display: none; }
.bill-hero__details summary::after {
  content: '▾';
  font-size: 11px;
  opacity: 0.6;
  transition: transform 0.18s ease;
}
.bill-hero__details[open] summary::after { transform: rotate(180deg); }
.bill-hero__details > *:not(summary) { margin-top: 10px; }

.bill-hero__usage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin: 6px 0;
}
.bill-hero__usage-row > span:first-child { flex: 0 0 96px; color: rgba(255, 255, 255, 0.7); }
.bill-hero__usage-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}
.bill-hero__usage-fill {
  height: 100%;
  background: linear-gradient(90deg, #6ce6c8, #4d8df0);
  border-radius: inherit;
  transition: width 0.3s ease;
}
.bill-hero__usage-num { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: #f4f6ff; }

.bill-hero__actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.bill-hero__btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.06);
  color: #f4f6ff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.bill-hero__btn:hover { background: rgba(255, 255, 255, 0.12); }
.bill-hero__btn:active { transform: scale(0.98); }
.bill-hero__btn.is-danger { color: #ffb1a3; border-color: rgba(255, 138, 116, 0.45); }
.bill-hero__btn.is-danger:hover { background: rgba(255, 138, 116, 0.12); }

.bill-hero__cancel-pred {
  position: relative;
  z-index: 1;
  margin: 14px 0 0;
  padding: 10px 14px;
  background: rgba(255, 200, 132, 0.16);
  border: 1px solid rgba(255, 200, 132, 0.38);
  border-radius: 10px;
  font-size: 13px;
  color: #ffe6c9;
}

/* ================================================================
 * B: Apple 風 customizer (= 単一画面で全選択 + 価格 reactive)
 * ================================================================ */
.bill-customizer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 0 0 32px;
}

@media (min-width: 960px) {
  .bill-customizer {
    grid-template-columns: 1fr 340px;
    align-items: start;
  }
}

.bill-cfg {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.bill-cfg__section {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px -16px rgba(15, 23, 42, 0.18);
  border: 1px solid #e7eaf3;
}

.bill-cfg__section h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: #1a3a6c;
  font-weight: 700;
}

.bill-cfg__section .bill-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: #6b7894;
  line-height: 1.55;
}

/* SNS chip (= 必須 + 追加) */
.bill-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
}
.bill-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  background: #f0f4fa;
  border: 1.5px solid transparent;
  color: #4a5872;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.bill-chip:hover { background: #e6eef9; }
.bill-chip[data-selected="true"] {
  background: #e8f1ff;
  border-color: #2e6db4;
  color: #1a3a6c;
}
.bill-chip[data-required="true"] {
  background: #fff8e2;
  border-color: #f3c351;
  color: #6e4c00;
  cursor: not-allowed;
}
.bill-chip__check {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #cfd8e8;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.bill-chip[data-selected="true"] .bill-chip__check { background: #2e6db4; }
.bill-chip[data-required="true"] .bill-chip__check { background: #c89534; }

/* Stepper (= 数量増減) */
.bill-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid #d6dde9;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.bill-stepper button {
  appearance: none;
  border: none;
  background: transparent;
  width: 40px;
  height: 44px;
  font-size: 20px;
  font-weight: 600;
  color: #2e6db4;
  cursor: pointer;
  transition: background 0.15s ease;
}
.bill-stepper button:hover { background: #f0f5fc; }
.bill-stepper button:disabled {
  color: #c8d0dd;
  cursor: not-allowed;
  background: transparent;
}
.bill-stepper input {
  width: 56px;
  height: 44px;
  text-align: center;
  border: none;
  border-left: 1px solid #d6dde9;
  border-right: 1px solid #d6dde9;
  font-size: 16px;
  font-weight: 600;
  color: #1a3a6c;
  background: #fff;
  -moz-appearance: textfield;
}
.bill-stepper input::-webkit-outer-spin-button,
.bill-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.bill-cfg__row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0;
  flex-wrap: wrap;
}
.bill-cfg__row label {
  font-size: 13.5px;
  color: #4a5872;
  flex: 1 0 140px;
  min-width: 0;
}
.bill-cfg__row .bill-cfg__sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #8896ab;
}

/* Day chips (= 0-7 day toggle) */
.bill-day-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bill-day {
  appearance: none;
  border: 1.5px solid #d6dde9;
  background: #fff;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  color: #4a5872;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.bill-day[data-selected="true"] {
  background: #2e6db4;
  border-color: #2e6db4;
  color: #fff;
}

/* Right: sticky summary (Apple カート風) */
.bill-summary {
  background: #ffffff;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 12px 32px -18px rgba(15, 23, 42, 0.22);
  border: 1px solid #e7eaf3;
  position: sticky;
  top: 24px;
}

.bill-summary h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #1a3a6c;
  font-weight: 700;
}

.bill-summary__list {
  list-style: none;
  margin: 0;
  padding: 0 0 12px;
  border-bottom: 1px dashed #e0e6ef;
}
.bill-summary__list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  color: #4a5872;
  padding: 6px 0;
  gap: 10px;
}
.bill-summary__list li > span:first-child { color: #6b7894; }
.bill-summary__list li > span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: #1a3a6c; }
.bill-summary__list li.is-empty { color: #8896ab; font-style: italic; justify-content: center; padding: 16px 0; }

.bill-summary__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 14px 0 6px;
}
.bill-summary__total > span:first-child {
  font-size: 14px;
  color: #6b7894;
}
.bill-summary__total .amount {
  font-size: 26px;
  font-weight: 800;
  color: #1a3a6c;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.bill-summary__total .month-label {
  font-size: 12px;
  color: #8896ab;
  margin-left: 4px;
}

.bill-summary__trial {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #eef9f3;
  border: 1px solid #b6e3cc;
  border-radius: 10px;
  font-size: 12.5px;
  color: #156c46;
  line-height: 1.5;
}

.bill-summary__cta {
  appearance: none;
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2e6db4, #1a3a6c);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 18px -8px rgba(46, 109, 180, 0.6);
}
.bill-summary__cta:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -8px rgba(46, 109, 180, 0.7); }
.bill-summary__cta:active { transform: translateY(0); }
.bill-summary__cta:disabled {
  background: #cfd8e8;
  color: #fff;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.bill-summary__hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: #8896ab;
  line-height: 1.5;
}

/* mobile (< 960px) で summary を画面下 sticky に固定 (= スクロールしても金額常時可視) */
@media (max-width: 959px) {
  .bill-customizer { grid-template-columns: 1fr; }
  .bill-cfg { padding-bottom: 240px; /* summary 分の余白確保 */ }
  .bill-summary {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 14px 16px 18px;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 24px -8px rgba(15, 23, 42, 0.18);
    border-top: 1px solid #e7eaf3;
    z-index: 50;
    max-height: 60vh;
    overflow-y: auto;
  }
  .bill-summary h3 { font-size: 13px; margin-bottom: 6px; }
  .bill-summary__list { padding-bottom: 8px; max-height: 22vh; overflow-y: auto; }
  .bill-summary__total { margin: 8px 0 4px; }
  .bill-summary__total .amount { font-size: 22px; }
  .bill-summary__trial { padding: 8px 10px; font-size: 11.5px; margin: 0 0 8px; }
  .bill-summary__cta { height: 44px; font-size: 14px; }
  .bill-summary__hint { display: none; }
}

@media (max-width: 480px) {
  .bill-hero { padding: 22px 18px 18px; border-radius: 18px; }
  .bill-hero__plan { font-size: 22px; }
  .bill-hero::before { font-size: 180px; }
  .bill-cfg__section { padding: 16px 18px; }
}

/* 0517 onboarding: 小型スマホ (~375px) の stepper / config row 崩れ対策 (E2 既知バグ)。
   stepper button 幅を 40→32px, input を 56→44px に圧縮し、 数量変更ボタンの
   文字 (+/-) が重ならないようにする。 cfg__row の gap も詰めて 1 行内に収める。 */
@media (max-width: 375px) {
  .bill-stepper button {
    width: 32px;
    height: 40px;
    font-size: 18px;
  }
  .bill-stepper input {
    width: 44px;
    height: 40px;
    font-size: 14px;
  }
  .bill-cfg__row {
    gap: 8px;
  }
  .bill-cfg__row label {
    font-size: 12.5px;
  }
}

/* prefers-reduced-motion で transition 削除 */
@media (prefers-reduced-motion: reduce) {
  .bill-hero__btn,
  .bill-summary__cta,
  .bill-chip,
  .bill-day,
  .bill-stepper button,
  .bill-hero__details summary::after,
  .bill-hero__usage-fill { transition: none; }
}
