/* ============================================================
   Cyvate - 解約処理 統合スタイル
   白基調 / 浅葱色 (--asagi: var(--asagi)) アクセント
   ============================================================ */

/* ---------- top-fixed-bar wrapper（ヘッダー + バナーを束ねる） ---------- */
.top-fixed-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}
/* wrapper 内ではヘッダー自身の fixed を解除（DOM 上の自然な流れで配置） */
.top-fixed-bar > .header {
    position: static;
}

/* ---------- サブスク状態バナー ---------- */
.subscription-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 24px;
    font-size: 14px;
    line-height: 1.5;
    background: var(--white);
    border-bottom: 1px solid #e8f4f6;
    /* wrapper 内で自然な縦並びになるよう、固定位置を持たない */
    position: static;
    box-shadow: 0 1px 0 rgba(0, 163, 175, 0.04);
}

/* バナー表示時はメインコンテンツの padding-top をヘッダー+バナー分に拡張
   wrapper の実高は 〜120px 程度（ヘッダー68 + バナー52）想定 */
body.has-subscription-banner .main {
    padding-top: calc(60px + 60px + 1.5rem);
}

/* ============================================================
   ダークモード対応
   ============================================================ */

/* バナー本体 */
html[data-theme="dark"] .subscription-banner {
    background: var(--bg-surface);
    border-bottom-color: var(--border-color);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
html[data-theme="dark"] .subscription-banner__message {
    color: var(--text-primary);
}
html[data-theme="dark"] .subscription-banner__message strong {
    color: var(--text-primary);
}
html[data-theme="dark"] .subscription-banner__link {
    color: var(--asagi);
    background: transparent;
    border-color: var(--asagi);
}
html[data-theme="dark"] .subscription-banner__link:hover {
    background: var(--asagi);
    color: var(--text-inverse);
}

/* Info variant */
html[data-theme="dark"] .subscription-banner--info {
    background: rgba(0, 163, 175, 0.12);
    border-bottom-color: rgba(0, 163, 175, 0.35);
}

/* Warning variant: 背景は薄く、ボタンは濃い黄色＋白文字を維持 */
html[data-theme="dark"] .subscription-banner--warning {
    background: rgba(245, 158, 11, 0.12);
    border-bottom-color: rgba(245, 158, 11, 0.35);
}
html[data-theme="dark"] .subscription-banner--warning .subscription-banner__icon {
    background: var(--warning);
    color: var(--text-inverse);
}
html[data-theme="dark"] .subscription-banner--warning .subscription-banner__message strong {
    color: var(--warning-text);
}
html[data-theme="dark"] .subscription-banner--warning .subscription-banner__link {
    background: #D97706;
    border-color: #D97706;
    color: #ffffff;
}
html[data-theme="dark"] .subscription-banner--warning .subscription-banner__link:hover {
    background: #B45309;
    border-color: #B45309;
    color: #ffffff;
}

/* Danger variant: 背景は薄赤、ボタンは赤＋白文字 */
html[data-theme="dark"] .subscription-banner--danger {
    background: rgba(220, 38, 38, 0.12);
    border-bottom-color: rgba(220, 38, 38, 0.35);
}
html[data-theme="dark"] .subscription-banner--danger .subscription-banner__icon {
    background: #DC2626;
}
html[data-theme="dark"] .subscription-banner--danger .subscription-banner__message strong {
    color: var(--danger-text);
}
html[data-theme="dark"] .subscription-banner--danger .subscription-banner__link {
    background: #DC2626;
    border-color: #DC2626;
    color: #ffffff;
}
html[data-theme="dark"] .subscription-banner--danger .subscription-banner__link:hover {
    background: #991B1B;
    border-color: #991B1B;
    color: #ffffff;
}
.subscription-banner__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    background: var(--asagi);
    color: #ffffff;
}
.subscription-banner__message {
    flex: 1;
    color: #2d4a54;
}
.subscription-banner__message strong {
    color: var(--asagi-dark);
    font-weight: 600;
}
.subscription-banner__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.subscription-banner__link {
    color: var(--asagi-dark);
    text-decoration: none;
    font-weight: 600;
    padding: 6px 14px;
    border: 1px solid var(--asagi);
    border-radius: 6px;
    background: var(--white);
    font-size: 13px;
    transition: all 0.15s;
}
.subscription-banner__link:hover {
    background: var(--asagi);
    color: #ffffff;
}

.subscription-banner--info {
    background: #f0fafb;
    border-bottom-color: var(--asagi-light);
}
.subscription-banner--warning {
    background: #fffaf3;
    border-bottom-color: #fcd9b6;
}
.subscription-banner--warning .subscription-banner__icon {
    background: var(--warning);
}
.subscription-banner--warning .subscription-banner__message strong { color: #8a4b00; }
/* キャンセル取り消し等の警告ボタン: 濃い黄色背景 + 白文字 */
.subscription-banner--warning .subscription-banner__link {
    color: #ffffff;
    background: var(--warning);
    border-color: var(--warning);
}
.subscription-banner--warning .subscription-banner__link:hover {
    background: #D97706;
    border-color: #D97706;
    color: #ffffff;
}
.subscription-banner--danger {
    background: #fef5f5;
    border-bottom-color: #fcc7c7;
}
.subscription-banner--danger .subscription-banner__icon {
    background: #c81e1e;
}
.subscription-banner--danger .subscription-banner__message strong { color: #9b1c1c; }
.subscription-banner--danger .subscription-banner__link {
    color: #9b1c1c;
    border-color: #c81e1e;
}
.subscription-banner--danger .subscription-banner__link:hover {
    background: #c81e1e;
    color: #ffffff;
}

/* ---------- 請求書払いの契約期間セクション（form-section内に配置） ---------- */
.invoice-contract-section { /* form-section の中の box として配置 */ }
.invoice-contract-section__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.invoice-contract-section__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--asagi-light);
    color: var(--asagi);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.invoice-contract-section__icon svg { width: 20px; height: 20px; }
.invoice-contract-section__title {
    margin: 0;
    color: var(--gray-800);
    font-size: 1.1rem;
    font-weight: 700;
}
.invoice-contract-section__desc {
    margin: 2px 0 0;
    color: var(--gray-500);
    font-size: 0.85rem;
}
.invoice-contract-section__current {
    background: linear-gradient(135deg, #f0fafb 0%, var(--white) 100%);
    border: 1px solid var(--asagi-light);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.invoice-contract-section__current-label {
    font-size: 13px;
    color: #5a7d81;
}
.invoice-contract-section__current-date {
    font-size: 16px;
    font-weight: 600;
    color: #2d4a54;
}
.invoice-contract-section__date-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1e3e6;
    border-radius: 8px;
    font-size: 14px;
    color: #2d4a54;
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.invoice-contract-section__date-input:focus {
    outline: none;
    border-color: var(--asagi);
    box-shadow: 0 0 0 3px var(--asagi-light);
}
.invoice-contract-section__presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.btn-quick-set {
    background: var(--white);
    border: 1px solid var(--asagi);
    color: var(--asagi-dark);
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-quick-set:hover {
    background: var(--asagi);
    color: #ffffff;
}
.btn-quick-set--clear {
    border-color: var(--gray-300);
    color: var(--gray-500);
}
.btn-quick-set--clear:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}
.invoice-contract-section__hint {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.7;
    margin-top: 12px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
}

/* 残日数バッジ */
.days-left-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.days-left-badge--ok {
    background: var(--asagi-light);
    color: var(--asagi-dark);
}
.days-left-badge--soon {
    background: #fff5e6;
    color: #8a4b00;
}
.days-left-badge--overdue {
    background: #fde8e8;
    color: #9b1c1c;
}

/* ---------- 解約・停止・復活 操作セクション ---------- */
/* 単独カードとして使う場合（agency等、form-card配下でない場面） */
.cancellation-card {
    background: var(--white);
    border: 1px solid #e8f4f6;
    border-radius: 12px;
    padding: 20px 24px;
    margin: 0 0 24px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.cancellation-card + .cancellation-card { margin-top: 0; }

/* form-section内に置く場合は既存の .form-section スタイルに溶け込ませる */
.cancellation-controls { }
.cancellation-controls__title {
    margin: 0 0 1rem;
    color: var(--gray-800);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.cancellation-controls__title::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 18px;
    background: #c81e1e;
    border-radius: 2px;
}
.cancellation-controls__buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.btn-cancel-action {
    background: var(--white);
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-cancel-action:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}
.btn-cancel-action--danger {
    background: #c81e1e;
    border-color: #c81e1e;
    color: #ffffff;
}
.btn-cancel-action--danger:hover {
    background: #9b1c1c;
    border-color: #9b1c1c;
}
.btn-cancel-action--asagi {
    background: var(--asagi);
    border-color: var(--asagi);
    color: #ffffff;
}
.btn-cancel-action--asagi:hover {
    background: var(--asagi-dark);
    border-color: var(--asagi-dark);
}

/* ---------- 解約モーダル ---------- */
.cancellation-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45, 74, 84, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.cancellation-modal.is-open { display: flex; }
.cancellation-modal__inner {
    background: var(--white);
    border-radius: 14px;
    padding: 28px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 163, 175, 0.18);
}
.cancellation-modal__header {
    border-left: 4px solid var(--asagi);
    padding-left: 12px;
    margin-bottom: 20px;
}
.cancellation-modal__title {
    margin: 0;
    color: #2d4a54;
    font-size: 18px;
    font-weight: 600;
}
.cancellation-modal__subtitle {
    margin: 4px 0 0;
    color: #5a7d81;
    font-size: 13px;
}
.cancellation-modal__field {
    margin-bottom: 18px;
}
.cancellation-modal__label {
    display: block;
    margin-bottom: 8px;
    color: #2d4a54;
    font-size: 13px;
    font-weight: 600;
}
.cancellation-modal__select,
.cancellation-modal__textarea,
.cancellation-modal__input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1e3e6;
    border-radius: 8px;
    font-size: 14px;
    color: #2d4a54;
    background: var(--white);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.cancellation-modal__select:focus,
.cancellation-modal__textarea:focus,
.cancellation-modal__input:focus {
    outline: none;
    border-color: var(--asagi);
    box-shadow: 0 0 0 3px var(--asagi-light);
}
.cancellation-modal__textarea { resize: vertical; min-height: 96px; }
.cancellation-modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}
.cancellation-modal__btn {
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.cancellation-modal__btn--secondary {
    background: var(--white);
    border-color: var(--gray-300);
    color: var(--gray-700);
}
.cancellation-modal__btn--secondary:hover {
    background: var(--gray-50);
}
.cancellation-modal__btn--primary {
    background: var(--asagi);
    color: #ffffff;
}
.cancellation-modal__btn--primary:hover { background: var(--asagi-dark); }
.cancellation-modal__btn--danger {
    background: #c81e1e;
    color: #ffffff;
}
.cancellation-modal__btn--danger:hover { background: #9b1c1c; }

.cancellation-modal__warning {
    background: #fef5f5;
    border: 1px solid #fcc7c7;
    border-radius: 8px;
    padding: 12px 14px;
    color: #9b1c1c;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
}

/* ---------- 履歴ビューア ---------- */
/* form-section内では装飾なし（コンテンツ直接） */
.status-history {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
}
.status-history__header {
    background: transparent;
    color: var(--gray-800);
    padding: 0 0 1rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: none;
}
.status-history__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.status-history__title::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--asagi);
    border-radius: 2px;
}
.status-history__refresh {
    background: var(--asagi-light);
    border: 1px solid var(--asagi-light);
    color: var(--asagi-dark);
    padding: 4px 14px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}
.status-history__refresh:hover { background: var(--asagi); color: #ffffff; }

/* 単独カードとして使う場合（agency等） */
.cancellation-card .status-history,
.status-history.status-history--card {
    background: var(--white);
    border: 1px solid #e8f4f6;
    border-radius: 10px;
}
.cancellation-card .status-history .status-history__header,
.status-history.status-history--card .status-history__header {
    padding: 12px 18px;
    border-bottom: 1px solid #e8f4f6;
    background: #f8fbfc;
}
.cancellation-card .status-history .status-history__title,
.status-history.status-history--card .status-history__title {
    font-size: 14px;
}
.cancellation-card .status-history .status-history__title::before,
.status-history.status-history--card .status-history__title::before {
    height: 16px;
}
.status-history__list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid #f0f7f8;
}
.status-history__item {
    padding: 12px 0;
    border-bottom: 1px solid #f0f7f8;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: center;
}
.status-history__item:last-child { border-bottom: none; }
/* カード型のときだけ左右パディングを付ける */
.cancellation-card .status-history__item,
.status-history--card .status-history__item {
    padding: 12px 18px;
}
.cancellation-card .status-history__list,
.status-history--card .status-history__list { border-top: none; }
.status-history__item:hover { background: #f8fbfc; }
.status-history__date {
    font-size: 12px;
    color: #5a7d81;
    white-space: nowrap;
}
.status-history__transition {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    flex-wrap: wrap;
}
.status-history__chip {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f7f8;
    color: #5a7d81;
}
.status-history__chip--to {
    background: var(--asagi-light);
    color: var(--asagi-dark);
}
.status-history__chip--disabled {
    background: #fde8e8;
    color: #9b1c1c;
}
.status-history__arrow { color: #a8bfc2; }
.status-history__reason {
    font-size: 12px;
    color: #5a7d81;
    margin-left: 6px;
}
.status-history__actor {
    font-size: 11px;
    color: #5a7d81;
    background: var(--white);
    border: 1px solid #e8f4f6;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}
.status-history__actor--admin { color: var(--asagi-dark); border-color: var(--asagi-light); }
.status-history__actor--webhook { color: #6f42c1; border-color: #e2d4f5; }
.status-history__actor--batch { color: #047857; border-color: #c5e8d8; }
.status-history__empty {
    padding: 24px 0;
    text-align: center;
    color: #a8bfc2;
    font-size: 13px;
    border-bottom: none !important;
}

/* ---------- アカウント編集画面ステータスselectの注釈 ---------- */
.account-status-warning {
    color: #9b1c1c;
    font-size: 12px;
    display: block;
    margin-top: 6px;
    padding-left: 4px;
    border-left: 2px solid #fcc7c7;
    padding-left: 8px;
}

/* ---------- 編集ボタン（一覧画面） ---------- */
.action-btn-edit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--white);
    border: 1px solid var(--asagi-light);
    color: var(--asagi-dark);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.action-btn-edit:hover {
    background: var(--asagi);
    border-color: var(--asagi);
    color: #ffffff;
}
