/* MMM 指標意味づけ・週次前処理状態UIパーツ用スタイル
 *
 * 仕様書: SPEC-mmm-metric-semantics.md / SPEC-ai-report-preprocessing.md
 * 対になるJS: mmm-semantics-parts.js / コントローラー: mmm-semantics.js
 *
 * style.css の CSS変数（--brand-primary 等）と既存クラス
 * （.report-settings-metric-*, .ai-report-insight-*, .settings-modal-* ほか）を
 * を前提とし、index.html で style.css より後に読み込む。
 *
 * 配色・寸法はすべて既存実装の実値に合わせている:
 *   - アンバー警告系: #fbf9f4 / #fdf3df / #fdecc8 / #854f0b / #b45309（共有 warning-bar）
 *   - 指標テーブル系: #fafbfc 容器 / hover #fff / 11px ヘッダー #6b7280（report-settings-metric-table）
 *   - MMMカード系: セル #f8fafc / 注記 10.5px #94a3b8 / コメント白地 12px #475569
 */

/* ================================================================
 * 1. レポート設定画面 — 指標テーブルの広告貢献度列（画面1・3・要件16）
 * ================================================================ */

/* 意味づけ表示を含む場合の列幅。既存の 84px×3 と同じ合計幅（270px）のまま、
 * 「種類の確認が必要」「⊘ 広告費のため」が収まるよう広告貢献度列だけを広げる。
 * head 行・データ行の両方（.report-settings-metric-row）に効く。 */
.report-settings-metric-table--semantics .report-settings-metric-row {
    grid-template-columns: 18px 1fr 72px 72px 108px;
}

/* 「種類の確認が必要」ボタン。要確認＝アンバー系（整合性警告と同系統）で、
 * チェックボックスの位置にピルとして置く。 */
.report-settings-semantics-needed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    padding: 3px 8px;
    border: none;
    border-radius: 999px;
    background: #fdf3df;
    color: #854f0b;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease;
}

.report-settings-semantics-needed:hover {
    background: #fdecc8;
}

.report-settings-semantics-needed:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 1px;
}

/* 未確定列の状態保持用hidden checkbox（[data-semantics-unresolved]）は
 * hidden属性で非表示のまま。確認ボタンだけをセルに見せる。 */
.report-settings-metric-check input[data-semantics-unresolved][hidden] {
    display: none;
}

/* 「広告貢献度に選択中の指標の種類が未確定です…」— 保存を拒否している間の案内。
 * 確認ボタンと同じアンバー系トーンの控えめなテキスト。 */
.report-settings-semantics-blocked-hint {
    margin: 8px 2px 0;
    font-size: 11.5px;
    line-height: 1.6;
    color: #854f0b;
}

/* 「⊘ 理由」— 選べない列の理由表示。無効状態の静かなグレー。 */
.report-settings-semantics-locked {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 100%;
    color: #9aa7b4;
    font-size: 10.5px;
    white-space: nowrap;
    cursor: default;
}

.report-settings-semantics-locked-icon {
    font-size: 12px;
    line-height: 1;
}

.report-settings-semantics-locked-reason {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 「指標の種類を編集」— テーブル下に常設する控えめなテキストリンク（要件16）。
 * 警告内アクション（.ai-report-warning-action）のテキストリンク型と同トーン。 */
.report-settings-semantics-edit {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 8px 2px 0;
    padding: 0;
    border: none;
    background: none;
    color: var(--brand-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.report-settings-semantics-edit:hover {
    color: var(--brand-primary-hover);
    text-decoration: underline;
}

.report-settings-semantics-edit-icon {
    display: inline-flex;
}

.report-settings-semantics-edit-icon svg {
    width: 13px;
    height: 13px;
}

/* ================================================================
 * 2. 指標の種類の確認画面（画面2・要件10〜14）
 * ================================================================ */

/* モーダルパネル幅の拡張（.settings-modal-panel に併記して使う）。
 * 4択マトリクスのため既存の 420/480px より広くとる。 */
.mmm-sem-modal-panel {
    width: min(680px, calc(100vw - 32px));
}

/* リード文。既存 .settings-description と同トーン。 */
.mmm-sem-lead {
    margin: 0 0 16px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.7;
}

.mmm-sem-currency-field {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 88px;
    gap: 6px 12px;
    align-items: center;
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
}

.mmm-sem-currency-label {
    font-size: 12px;
    font-weight: 600;
    color: #0c356a;
}

.mmm-sem-currency-input {
    width: 88px;
    padding: 7px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #111827;
    font-size: 13px;
    text-transform: uppercase;
}

.mmm-sem-currency-input:focus {
    outline: 2px solid rgba(37, 99, 235, 0.18);
    border-color: #2563eb;
}

.mmm-sem-currency-hint {
    grid-column: 1 / -1;
    font-size: 11px;
    line-height: 1.6;
    color: #64748b;
}

/* 選択テーブル。指標テーブル（.report-settings-metric-table）と同じ器。 */
.mmm-sem-table {
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    background: #fafbfc;
    padding: 6px 8px;
}

.mmm-sem-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) repeat(4, 100px);
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
}

.mmm-sem-row + .mmm-sem-row {
    margin-top: 2px;
}

.mmm-sem-row:hover:not(.mmm-sem-row--head) {
    background: #ffffff;
}

.mmm-sem-row--head {
    color: #6b7280;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.mmm-sem-head-cell {
    text-align: center;
    line-height: 1.35;
}

.mmm-sem-head-cell--name {
    text-align: left;
}

.mmm-sem-name {
    font-size: 13px;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ラジオセル。セル全体（label）をクリック可能にする。 */
.mmm-sem-choice {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px 0;
    cursor: pointer;
}

.mmm-sem-choice input[type="radio"] {
    width: 15px;
    height: 15px;
    accent-color: var(--brand-primary);
    cursor: pointer;
}

/* フッター注記。カード内の柔らかい説明ボックス（#f8fafc）で線を使わずに区切る。 */
.mmm-sem-footnote {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
}

.mmm-sem-footnote-line {
    margin: 0;
    font-size: 12px;
    color: #64748b;
    line-height: 1.7;
}

.mmm-sem-footnote-line + .mmm-sem-footnote-line {
    margin-top: 4px;
}

/* AI推定の失敗案内（要件14）。鮮度警告と同じアンバーの帯。 */
.mmm-sem-ai-failed {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fbf9f4;
}

.mmm-sem-ai-failed-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: #fdecc8;
    color: #b45309;
}

.mmm-sem-ai-failed-text {
    margin: 3px 0 0;
    font-size: 12px;
    font-weight: 500;
    color: #854f0b;
    line-height: 1.6;
}

/* ローディング表示（要件11）。 */
.mmm-sem-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 44px 20px;
}

.mmm-sem-loading-spinner {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 3px solid rgba(37, 99, 235, 0.16);
    border-top-color: var(--brand-primary);
    animation: mmm-sem-spin 0.9s linear infinite;
}

@keyframes mmm-sem-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mmm-sem-loading-text {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
}

/* 「待たずに自分で選ぶ」— テキストリンク型アクション。 */
.mmm-sem-loading-skip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
    padding: 0;
    border: none;
    background: none;
    color: var(--brand-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.mmm-sem-loading-skip:hover {
    color: var(--brand-primary-hover);
    text-decoration: underline;
}

.mmm-sem-loading-skip-icon {
    display: inline-flex;
}

.mmm-sem-loading-skip-icon svg {
    width: 14px;
    height: 14px;
}

/* ---------- MMM週次前処理・実行状態 ---------- */

.ai-report-mmm-cell-eyebrow {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.06em;
}

.ai-report-mmm-shortfall {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ai-report-mmm-shortfall-line {
    margin: 0;
    font-size: 12px;
    line-height: 1.8;
    color: #64748b;
}

.ai-report-mmm-shortfall-strong {
    font-weight: 700;
    color: var(--brand-dark);
}

.ai-report-mmm-shortfall-line--ahead {
    margin-top: 4px;
}

.ai-report-mmm-shortfall-reason {
    margin: 0;
    max-width: 400px;
    font-size: 11px;
    line-height: 1.7;
    color: #94a3b8;
}

.ai-report-mmm-period {
    margin: 2px 0 0;
}

.ai-report-mmm-period-line {
    margin: 0;
    font-size: 10.5px;
    font-weight: 500;
    color: #94a3b8;
    letter-spacing: 0.02em;
    line-height: 1.6;
}

.ai-report-mmm-period-line + .ai-report-mmm-period-line {
    margin-top: 1px;
}

.ai-report-mmm-period-reason {
    margin: 2px 0 0;
    font-size: 10.5px;
    color: #94a3b8;
    line-height: 1.6;
}

.ai-report-mmm-reference-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    background: #fdf3df;
    color: #854f0b;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
}

.ai-report-mmm-reference-note {
    margin: 2px 0 0;
    font-size: 11px;
    line-height: 1.6;
    color: #854f0b;
}

.ai-report-mmm-usage-excluded-dates {
    margin: 1px 0 0;
    padding-left: 26px;
    font-size: 10.5px;
    color: #94a3b8;
    line-height: 1.6;
}

.ai-report-mmm-usage-dates-link {
    padding: 0;
    border: none;
    background: none;
    color: var(--brand-primary);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
}

.ai-report-mmm-usage-dates-link:hover {
    color: var(--brand-primary-hover);
    text-decoration: underline;
}

.ai-report-mmm-usage-fix-note {
    margin: 3px 0 0;
    padding-left: 14px;
    font-size: 10.5px;
    color: #94a3b8;
    line-height: 1.6;
}

.ai-report-mmm-blocked-target {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    margin: 4px 0 0;
    padding: 7px 14px;
    border-radius: 8px;
    background: #ffffff;
    font-size: 12px;
    line-height: 1.5;
}

.ai-report-mmm-blocked-target-label {
    font-weight: 500;
    color: #64748b;
}

.ai-report-mmm-blocked-target-value {
    font-weight: 700;
    color: var(--brand-dark);
    letter-spacing: 0.01em;
}

.ai-report-mmm-alt-notice {
    grid-column: 1 / -1;
    margin: 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fbf9f4;
    font-size: 11.5px;
    line-height: 1.6;
    color: #854f0b;
}

/* ================================================================
 * 3. 結果画面 — MMMカードの追加要素（画面5〜7・要件29・32・38）
 * ================================================================ */

/* 基準線キャプション（チャート直下・中央寄せ）。 */
.ai-report-mmm-baseline-note {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    margin: 2px 0 0;
    text-align: center;
}

.ai-report-mmm-baseline-note-value {
    font-size: 11px;
    font-weight: 600;
    color: #0c356a;
}

.ai-report-mmm-baseline-note-caption {
    font-size: 10.5px;
    color: #94a3b8;
}

/* ⓘ 説明文ボックス。既存 .ai-report-insight-comment と同じ白地トーン。 */
.ai-report-mmm-explain {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #ffffff;
}

.ai-report-mmm-explain-icon {
    flex: 0 0 auto;
    display: flex;
    margin-top: 1px;
    color: #64748b;
}

.ai-report-mmm-explain-icon svg {
    width: 14px;
    height: 14px;
}

.ai-report-mmm-explain-text {
    margin: 0;
    font-size: 12px;
    color: #475569;
    line-height: 1.55;
}

/* 「分析に使った広告費 / 分析対象外」脚注。集計期間の注記と同トーン。 */
.ai-report-mmm-usage {
    margin: 2px 0 0;
}

.ai-report-mmm-usage-used {
    margin: 0;
    font-size: 10.5px;
    font-weight: 500;
    color: #94a3b8;
    letter-spacing: 0.02em;
}

.ai-report-mmm-usage-excluded {
    margin-top: 2px;
}

.ai-report-mmm-usage-excluded-label {
    margin: 0;
    font-size: 10.5px;
    font-weight: 500;
    color: #94a3b8;
    letter-spacing: 0.02em;
}

.ai-report-mmm-usage-excluded-row {
    margin: 1px 0 0;
    padding-left: 14px;
    font-size: 10.5px;
    color: #94a3b8;
    line-height: 1.6;
}

/* 「種類を確認する」— 分析対象外（種類が未確定）行の導線（画面7）。 */
.ai-report-mmm-usage-confirm-link {
    padding: 0;
    border: none;
    background: none;
    color: var(--brand-primary);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
}

.ai-report-mmm-usage-confirm-link:hover {
    color: var(--brand-primary-hover);
    text-decoration: underline;
}

/* ================================================================
 * 4. 結果画面 — 全面状態セル（画面8〜10）
 * ================================================================ */

/* 既存の MMM 特殊状態セル（.ai-report-mmm-insufficient 等）と同じ中央寄せの器。 */
.ai-report-mmm-state-cell {
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 48px 32px;
}

.ai-report-mmm-state-cell .ai-report-insight-cell-special-title {
    margin: 0;
}

.ai-report-mmm-state-cell .ai-report-insight-cell-special-body {
    margin: 0;
}

/* 特殊セル内の本文行間（gap はセルの flex 側で確保されるため微調整のみ）。 */
.ai-report-mmm-state-cell .ai-report-insight-cell-special-body + .ai-report-insight-cell-special-body {
    margin-top: -4px;
}

/* 画面8のCTA。Primaryボタン（.settings-btn-primary）と同トーンの小型版。 */
.ai-report-mmm-state-cta {
    margin-top: 8px;
    height: 34px;
    padding: 0 18px;
    border: none;
    border-radius: 8px;
    background: var(--brand-primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ai-report-mmm-state-cta:hover {
    background: var(--brand-primary-hover);
}

.ai-report-mmm-state-cta:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}
