/* 料金プラン画面・課金の確認ダイアログと、契約の状態の案内(サイト一覧・
   サイトの公開のタブ・ログインの画面でも出す)のスタイル
   (layout.tsのlayout()がapp.cssの後に読み込む) */

.billing-notice {
  border-color:#bfe8d7;
  background:var(--success-soft);
  color:var(--success);
  font-weight:600;
}

/* 料金プラン画面(中の確認ダイアログを含む): 文の途中では改行せず、
   句読点(、。)の後で改行する。収まらないときだけ途中で折り返す */
.billing-page {
  word-break:keep-all;
  overflow-wrap:anywhere;
}

/* 料金プラン画面のエラーの案内(支払いの失敗・カードの期限切れ等)は、
   日付・「」を含む長い文が多く、句読点の後でだけ改行するとスマホの幅で
   短い行が続く変な折り返しになるので、通常どおり行末で折り返す */
.billing-page .error {
  word-break:normal;
}

.billing-section-heading {
  margin-top:32px;
}

/* 料金プラン: プランの比較カード。同じ幅で横に並べ、
   今のプランを主色の枠で示す */
.billing-plan-cards {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(180px, 1fr));
  gap:14px;
}

.billing-plan-card {
  position:relative;
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:22px 18px 18px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow-small);
}

/* 押すと申し込み・変更の操作になるカード。押せることが分かるよう、
   指の形のカーソルと、上に乗せたときの枠の色で示す */
.billing-plan-card-selectable {
  cursor:pointer;
  transition:border-color .15s, box-shadow .15s;
}

.billing-plan-card-selectable:hover {
  border-color:var(--primary);
  box-shadow:0 8px 24px var(--primary-glow);
}

.billing-plan-card.is-current {
  border:2px solid var(--primary);
  box-shadow:0 8px 24px var(--primary-glow);
}

.billing-plan-name {
  font-size:15px;
}

/* 税込の月額と、その下の税抜の月額。税抜の行が無い無料のプランでも、
   下のできることの一覧の位置が他のカードと揃うよう高さを確保する */
.billing-plan-price-block {
  min-height:62px;
  margin:2px 0 10px;
}

.billing-plan-price {
  font-size:24px;
  font-weight:800;
}

/* 税込の月額の下に小さく添える税抜の月額 */
.billing-plan-price-excluding-tax,
.billing-credit-pack-excluding-tax {
  font-size:12px;
  font-weight:400;
}

.billing-plan-price-unit {
  font-size:12px;
  font-weight:400;
}

.billing-plan-features {
  list-style:none;
  margin:0;
  padding:12px 0 0;
  border-top:1px solid var(--border);
  font-size:13px;
  color:var(--text-muted);
}

.billing-plan-features li {
  display:flex;
  align-items:center;
  gap:6px;
  margin:4px 0;
}

.billing-plan-features .icon {
  color:var(--success);
}

/* 下に補足の行を添える項目。アイコンは1行目の高さに揃える */
.billing-plan-features .billing-plan-feature-with-note {
  align-items:flex-start;
}

.billing-plan-feature-with-note .icon {
  margin-top:3px;
}

/* 項目の下に小さく添える補足(容量の上限を写真の枚数で言い換えたもの等) */
.billing-plan-feature-note {
  display:block;
  font-size:12px;
}

/* 今のプランのカードの上辺に重ねて出すラベル */
.billing-current-plan-badge {
  position:absolute;
  top:-11px;
  left:16px;
  background:var(--accent);
  color:var(--accent-text);
}

/* 料金プラン: 申し込み・追加購入・予約・カードの各操作を2列に並べる */
.billing-panels {
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:16px;
  margin-top:32px;
  align-items:start;
}

.billing-panel {
  margin:0;
}

@media (max-width: 760px) {
  .billing-panels {
    grid-template-columns:minmax(0, 1fr);
  }
}

.billing-panel > h2:first-child {
  margin-top:0;
}

/* 操作の枠の中に置くフォームは、枠を重ねず中身だけ見せる */
.billing-panel .billing-narrow-card {
  margin:0;
  padding:0;
  border:0;
  background:none;
  box-shadow:none;
}

.billing-checkout-button {
  margin-top:12px;
}

.billing-submit-button {
  margin-top:12px;
}

/* 追加のAI利用回数のパック(枠の中に小さな枠として並べる) */
.billing-credit-packs {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));
  gap:12px;
}

.billing-credit-packs .card {
  margin:0;
  padding:14px;
  background:var(--surface-tint);
  box-shadow:none;
  font-weight:700;
}

/* 課金の確認ダイアログ: 金額の明細と、買うと何が変わるかの一覧は左揃えにする */
.purchase-confirm-dialog {
  width:min(520px, calc(100vw - 32px));
  max-height:calc(100dvh - 32px);
}

/* 項目が多く画面に収まらないときは、ヘッダー・確認文・金額の明細と
   ボタンを固定して、その間の項目の一覧だけをスクロールさせる(金額は
   常に見えるようにする)。ダイアログ全体をスクロールさせると、ボタンに
   当たるフォーカスでヘッダーが上に隠れる */
.purchase-confirm-dialog form {
  display:flex;
  flex-direction:column;
  max-height:calc(100dvh - 32px);
}

.purchase-confirm-dialog .confirm-dialog-header,
.purchase-confirm-fixed,
.purchase-confirm-footer {
  flex:none;
}

.purchase-confirm-fixed {
  padding-bottom:16px;
}

/* スクロールする項目の一覧は、上の明細と区切り線で分ける(スクロールした
   項目が明細の下に入り込んで見えるように) */
.purchase-confirm-scroll {
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  padding-top:0;
  padding-bottom:16px;
  border-top:1px solid var(--border);
}

.purchase-confirm-scroll dl.purchase-details {
  margin-top:0;
}

.purchase-confirm-footer {
  padding:16px 20px 20px;
  border-top:1px solid var(--border);
}

.purchase-confirm-footer .confirm-dialog-actions {
  margin-top:0;
}

.purchase-summary {
  margin:16px 0 0;
  padding:12px 16px;
  border:1px solid var(--border);
  border-radius:8px;
  text-align:left;
}

.purchase-summary-row {
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:3px 0;
  font-size:14px;
}

.purchase-summary-row dt {
  color:var(--text-muted);
}

/* 金額は狭い画面でも途中で折り返さない(「−¥3,000」が割れないように) */
.purchase-summary-row dd {
  margin:0;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}

/* 品目が複数あるときの合計(差額など)は、品目の下に区切り線を引いて示す */
.purchase-summary-subtotal {
  margin-top:4px;
  padding-top:7px;
  border-top:1px dashed var(--border);
  font-weight:700;
}

.purchase-summary-subtotal dt {
  color:inherit;
}

/* お支払い金額(税込)の合計行は区切り線の下で大きく見せる */
.purchase-summary-total {
  margin-top:6px;
  padding-top:9px;
  border-top:1px solid var(--border);
  font-size:17px;
  font-weight:700;
}

.purchase-summary-total dt {
  color:inherit;
}

.confirm-dialog-body dl.purchase-details,
.billing-card-dialog dl.purchase-details {
  grid-template-columns:auto 1fr;
  margin:16px 0 0;
  font-size:13px;
  text-align:left;
}

/* 項目名と内容の間を空ける(一覧のgapは0なので、最も長い項目名が内容に
   くっつかないように) */
.confirm-dialog-body dl.purchase-details dt,
.billing-card-dialog dl.purchase-details dt {
  padding-right:16px;
}

/* 特定商取引法に基づく表記への案内(課金の確認の最後に添える) */
.purchase-legal-note {
  margin:12px 0 0;
  font-size:12px;
}

/* カード入力ダイアログ。形は他の確認ダイアログ(.confirm-dialog)と同じ。
   帯のヘッダーとボタンだけを固定し、その間(案内・金額の明細・契約の
   内容・カード入力欄)はまとめて1つの枠でスクロールさせる。スクロール
   する場所を1つにして、どこを回せば動くかで迷わないようにする。
   カード入力欄を広く使いたいときは、契約の内容を閉じれば金額の明細と
   同じ画面に収まる(.confirm-dialogの幅より優先させるため、両方の
   クラスで指定する) */
.confirm-dialog.billing-card-dialog {
  width:min(520px, calc(100vw - 32px));
  max-height:calc(100dvh - 32px);
}

/* ダイアログの中の文字等を押すとダイアログ自体にフォーカスが移るが、
   ダイアログは操作する部品ではないので枠線を出さない */
.billing-card-dialog:focus-visible {
  outline:none;
}

/* 閉じているときのdisplay:noneを上書きしないよう、開いているときだけ
   フレックスにする */
.billing-card-dialog[open] {
  display:flex;
  flex-direction:column;
}

.billing-card-dialog > * {
  flex:none;
}

/* スクロールの端に着いても後ろの画面へスクロールを伝えない */
.billing-card-dialog > .billing-card-dialog-body {
  flex:1 1 auto;
  min-height:0;
  padding:20px;
  overflow-y:auto;
  overscroll-behavior:contain;
}

.billing-card-dialog-guide {
  margin:0;
}

/* カードの変更だけのときの、折りたたまないカード入力欄 */
.billing-card-form-standalone {
  margin-top:16px;
}

/* 契約の内容・カード入力欄の折りたたみ。見出しを押すと開き、山括弧が
   上向きになる */
.billing-card-disclosure {
  margin-top:16px;
  border:1px solid var(--border);
  border-radius:8px;
}

.billing-card-disclosure summary {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 16px;
  font-size:14px;
  font-weight:700;
  cursor:pointer;
  list-style:none;
}

.billing-card-disclosure summary::-webkit-details-marker {
  display:none;
}

.billing-card-disclosure summary .icon {
  flex:none;
  color:var(--text-muted);
  transition:transform .15s;
}

.billing-card-disclosure[open] summary .icon {
  transform:rotate(180deg);
}

.billing-card-dialog .billing-card-disclosure dl.purchase-details {
  margin:0;
  padding:0 16px 4px;
}

/* 決済サービスが埋め込むカード入力欄。折りたたみの枠の内側に収める */
.billing-card-form {
  padding:0 16px 16px;
}

/* 料金プラン: プランのカードの下の操作(申し込み・変更のボタン)。
   カードの高さが違っても、ボタンの位置を下端に揃える */
.billing-plan-action {
  margin-top:auto;
  padding-top:14px;
}

.billing-plan-action form {
  margin:0;
}

.billing-plan-button {
  width:100%;
  justify-content:center;
}

.billing-plan-note {
  margin:0 0 8px;
  font-size:12px;
}

/* 料金プラン: 解約の枠。プランの変更より一段重い操作なので、他の操作と
   並べず画面の一番下に置き、赤い枠と見出しで注意を促す */
.billing-danger-zone {
  margin-top:40px;
  border:1px solid var(--danger);
  background:var(--danger-soft);
}

.billing-danger-zone-heading {
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:0;
  color:var(--danger);
}

/* 料金プラン: お支払いの履歴の表。内容の欄だけを折り返し、狭い画面でも
   領収書のリンクまで見えるようにする(収まらなければ表だけを横にずらせる) */
/* 表の見出しを画面上に固定するため、スクロールの枠を作らないclipで
   はみ出しを切る(autoだと見出しがこの枠の中でしか止まらない) */
.billing-history {
  padding:0;
  overflow:clip;
}

.billing-history-table {
  width:100%;
  border-collapse:collapse;
  font-size:14px;
}

.billing-history-table th,
.billing-history-table td {
  padding:12px 16px;
  border-bottom:1px solid var(--border);
  text-align:left;
}

.billing-history-table th,
.billing-history-table .billing-history-date,
.billing-history-table .billing-history-amount,
.billing-history-table td:last-child {
  white-space:nowrap;
}

/* 見出しはスクロールしても固定したヘッダーの下に残す。行と見分けられ、
   重なった行が透けないよう色を塗り、表と一緒に動かない枠線の代わりに
   影で下線を引く */
.billing-history-table th {
  position:sticky;
  top:var(--app-header-height);
  z-index:1;
  background:var(--track);
  box-shadow:inset 0 -1px 0 var(--border-strong);
  color:var(--text);
  font-size:12px;
  font-weight:600;
}

/* 履歴の表がある画面では、固定したヘッダーを不透明にして下に影を落とす。
   スクロールして表の見出しがヘッダーの下に付いたときに、2つの境目が
   分かるようにする(半透明のままだと、後ろを流れる文字が透けて紛れる) */
body:has(.billing-history-table) header.app {
  background:var(--surface);
  box-shadow:0 4px 12px rgba(35, 35, 58, .10);
}

.billing-history-table tbody tr:last-child td {
  border-bottom:none;
}

/* 行を目で追いやすいよう、1行おきに色を付ける(狭い画面の1件ごとの
   並びでも同じ) */
.billing-history-table tbody tr:nth-child(even) {
  background:var(--background);
}

.billing-history-table .billing-history-amount {
  text-align:right;
}

/* 料金プラン画面では直近の分だけ出すので、表の右下に全件への入口を置く */
.billing-history-more {
  margin:8px 0 0;
  text-align:right;
}

/* 領収書の画面: 上に宛名の入力と印刷のボタン、下に領収書(紙の形) */
.receipt-page {
  display:flex;
  flex-direction:column;
  gap:20px;
}

.receipt-toolbar {
  display:flex;
  flex-direction:column;
  gap:12px;
}

.receipt-recipient-form {
  margin:0;
}

.receipt-recipient-form .row input {
  flex:1 1 240px;
}

.receipt-print .muted {
  margin:8px 0 0;
}

.receipt {
  padding:40px;
  background:var(--surface);
  border:1px solid var(--border);
  color:var(--text);
  /* 印刷でも金額の欄・表の見出しの背景色を落とさない */
  -webkit-print-color-adjust:exact;
  print-color-adjust:exact;
}

.receipt-title {
  margin:0 0 16px;
  text-align:center;
  font-size:28px;
  letter-spacing:.4em;
}

.receipt-meta {
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  margin:0 0 24px;
  font-size:13px;
}

.receipt-meta div,
.receipt-totals div {
  display:flex;
  gap:12px;
}

.receipt-meta dd,
.receipt-totals dd {
  margin:0;
}

.receipt-meta dt {
  white-space:nowrap;
}

.receipt-recipient {
  width:min(100%, 28em);
  margin:0 0 24px;
  padding-bottom:6px;
  border-bottom:1px solid var(--text);
  font-size:20px;
}

.receipt-recipient-name {
  display:inline-block;
  min-width:12em;
  margin-right:8px;
}

.receipt-amount {
  display:flex;
  align-items:baseline;
  justify-content:center;
  gap:16px;
  margin:0 auto 12px;
  padding:12px 24px;
  max-width:420px;
  background:var(--surface-sunken);
}

.receipt-amount strong {
  font-size:28px;
}

.receipt-proviso {
  margin:0 0 28px;
  text-align:center;
}

.receipt-items {
  width:100%;
  margin-bottom:16px;
  border-collapse:collapse;
  font-size:14px;
}

.receipt-items th,
.receipt-items td {
  padding:8px 10px;
  border:1px solid var(--border-strong);
  text-align:left;
}

.receipt-items th {
  background:var(--surface-sunken);
  font-weight:600;
}

.receipt-items .receipt-number {
  text-align:right;
  white-space:nowrap;
}

.receipt-totals {
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:4px;
  margin:0 0 32px;
  font-size:14px;
}

.receipt-totals dt {
  color:var(--text-muted);
}

.receipt-totals .receipt-total {
  padding-top:4px;
  border-top:1px solid var(--text);
  font-size:16px;
  font-weight:700;
}

.receipt-totals .receipt-total dt {
  color:var(--text);
}

.receipt-issuer {
  margin-left:auto;
  width:fit-content;
  font-size:13px;
}

.receipt-issuer p {
  margin:0;
}

.receipt-issuer .receipt-issuer-name {
  font-size:15px;
  font-weight:700;
}

@media (max-width: 760px) {
  /* 狭い画面では表の見出しを出さず、1件ごとにお支払い日を1行目、
     内容・金額・領収書を2行目に並べる */
  .billing-history-table thead {
    display:none;
  }

  .billing-history-table tr {
    display:grid;
    grid-template-columns:1fr auto auto;
    align-items:baseline;
    column-gap:12px;
    padding:12px 16px;
    border-bottom:1px solid var(--border);
  }

  .billing-history-table tbody tr:last-child {
    border-bottom:none;
  }

  .billing-history-table td {
    padding:0;
    border-bottom:none;
  }

  .billing-history-table .billing-history-date {
    grid-column:1 / -1;
    color:var(--text-muted);
    font-size:12px;
  }

  .receipt {
    padding:24px 16px;
  }

  .receipt-amount strong {
    font-size:22px;
  }
}

/* 印刷では領収書だけを出す(画面の枠・宛名の入力・ボタンを隠す) */
@page {
  margin:20mm;
}

@media print {
  header.app,
  .app-footer,
  .receipt-toolbar {
    display:none;
  }

  body {
    background:var(--surface);
  }

  main {
    margin:0;
    padding:0;
    max-width:none;
  }

  .receipt {
    padding:0;
    border:none;
  }
}

/* 来月からの下位プランへの変更の確認ダイアログで、公開を続けるサイトを選ぶ欄。
   明細と同じく左揃えにし、選択肢は小さめに並べる */
.kept-site-selection {
  margin:16px 0 0;
  padding:0;
  border:none;
  text-align:left;
}

.kept-site-selection legend {
  padding:0;
  font-weight:700;
}

.kept-site-selection .choices {
  grid-template-columns:repeat(auto-fill,minmax(160px,1fr));
  gap:8px;
  margin-top:8px;
}

.kept-site-selection .choice {
  min-height:48px;
  padding:10px 30px;
  font-size:14px;
}

/* 選ぶ数に達したら、選んでいない選択肢は押せないことが分かるよう薄くする */
.kept-site-selection .choice:has(input:disabled) {
  opacity:.5;
  cursor:not-allowed;
}

/* 今の契約の状態(解約済み・退会の予約中など)の案内 */
.status-notice {
  border-color:var(--warning);
  background:var(--warning-soft);
}

/* 予約したプラン変更で、更新日にサイトの公開を止めることの案内(サイト一覧・
   サイトの公開の欄)と、料金プラン画面の閲覧だけのプランの案内。文の途中では
   改行せず、句読点(、。)の後で改行する。句読点の間が1行に収まらないとき
   だけ、途中で折り返す */
.plan-change-stop-notice,
.view-only-plan-notice {
  word-break:keep-all;
  overflow-wrap:anywhere;
}

/* ── 数字を大きく見せる枠の並び(料金プランの契約の要約など) ── */

.stat-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));
  gap:14px;
  margin-bottom:8px;
}

.stat {
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:18px 20px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow-small);
}

.stat-label {
  color:var(--text-muted);
  font-size:13px;
  font-weight:600;
}

.stat-value {
  font-size:26px;
  font-weight:800;
  line-height:1.3;
}

.stat-value small {
  margin-left:2px;
  font-size:14px;
  font-weight:600;
}

.stat-value-small {
  font-size:18px;
}

/* 値の下に添える補足(次回更新日の欄の「○○ 23:59:59まで」など) */
.stat-note {
  color:var(--text-muted);
  font-size:12px;
}
