/**
 * sf-theme.css — ポータル / マーケットプレイス共通 Salesforce Classic 風テーマ (2026-06-11)
 *
 * GWSCRM WEB版 (google-workspace-crm/styles.css) の SF Classic 配色を
 * ポータル全ページへ拡張するオーバーライド層。
 * 全ルールを html.theme-sf 配下にスコープし、sf-theme.js のプリペイントで
 * クラスが付与されたときのみ有効化される（FOUC 回避）。
 *
 * 配色はGWSCRM版と共通:
 *   ヘッダー帯  linear-gradient(180deg, #1f7db6, #16527c) / 枠 #134668
 *   primaryボタン linear-gradient(#2f80cf, #236fbd) / 枠 #1c5a99
 *   ページ背景 #f3f2ee / カード白地 + 1px #dcdcdc + 角丸3px
 *   リンク #015ba7 / Arial 13px
 *
 * 読み込み順: 各ページの既存 CSS（design-tokens / shell / portal / marketplace /
 * theme / portal-refinement）より後ろ（</head> 直前）に置くこと。
 */

/* ============================================================
   1. CSS 変数の再定義（design-tokens / portal / legal / theme / Bootstrap）
   ============================================================ */
html.theme-sf {
  /* design-tokens.css (:root) の再定義 */
  --primary: #015ba7;
  --primary-gradient: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);
  --accent: #236fbd;
  --accent-gradient: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);
  --bg-page: #f3f2ee;
  --bg-card: #ffffff;
  --text-primary: #222222;
  --text-secondary: #444444;
  --card-radius: 3px;
  --btn-radius: 3px;
  --border-color: #dcdcdc;
  --font-family: Arial, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo, sans-serif;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.16);

  /* portal.css (:root) の再定義 */
  --user-card-gradient: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);

  /* legal.css (:root) の再定義 */
  --legal-accent: #015ba7;
  --legal-border: #dcdcdc;
  --legal-bg: #f3f2ee;

  /* theme.css (:root) の再定義 */
  --bg-primary: #ffffff;
  --bg-secondary: #f3f2ee;
  --bg-tertiary: #ecebe6;
  --primary-hover: #014a8c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);

  /* Bootstrap 5 変数の再定義（リンク色・角丸・本文） */
  --bs-body-bg: #f3f2ee;
  --bs-body-color: #222222;
  --bs-body-font-family: Arial, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo, sans-serif;
  --bs-body-font-size: 13px;
  --bs-border-radius: 3px;
  --bs-border-radius-sm: 3px;
  --bs-border-radius-lg: 3px;
  --bs-border-color: #dcdcdc;
  --bs-link-color: #015ba7;
  --bs-link-hover-color: #014a8c;
  --bs-link-color-rgb: 1, 91, 167;
  --bs-link-hover-color-rgb: 1, 74, 140;
  --bs-primary: #236fbd;
  --bs-primary-rgb: 35, 111, 189;
}

/* ============================================================
   2. ページ基盤（背景・フォント）
   ============================================================ */
html.theme-sf body,
html.theme-sf body.bg-light {
  background: #f3f2ee !important;
  color: #222222;
  font-family: Arial, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo, sans-serif;
  font-size: 13px;
}

/* ============================================================
   3. ナビバー（SF Classic タブ帯と同系の青グラデ）
   dashboard.html の inline <style> (.navbar-dark.bg-dark !important) より
   高い詳細度 + !important で上書きする。workflow_detail.html の
   style 属性（非 !important）にも勝つ。
   ============================================================ */
html.theme-sf nav.navbar.navbar-dark,
html.theme-sf .navbar-dark.bg-dark,
html.theme-sf .navbar-portal {
  background: linear-gradient(180deg, #1f7db6 0%, #16527c 100%) !important;
  border-bottom: 1px solid #134668;
}

/* legal ページの上部ナビ・ヘッダー帯（--primary-gradient 経由で追従するが明示） */
html.theme-sf .legal-nav,
html.theme-sf .legal-header {
  background: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);
}

/* ============================================================
   4. カード（白地 + 1px枠 + 角丸3px + 淡灰ヘッダー帯）
   ============================================================ */
html.theme-sf .card,
html.theme-sf .card-portal {
  background-color: #ffffff;
  border: 1px solid #dcdcdc !important;
  border-radius: 3px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) !important;
}

html.theme-sf .card:hover,
html.theme-sf .card-portal:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) !important;
}

html.theme-sf .card-header {
  background: linear-gradient(180deg, #f8f8f8 0%, #efefec 100%);
  border-bottom: 1px solid #dcdcdc;
  color: #222222;
  font-weight: bold;
  border-radius: 3px 3px 0 0 !important;
}

/* ============================================================
   5. ボタン（SF Classic: グレーグラデ既定 + 青 primary）
   ============================================================ */
html.theme-sf .btn {
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
}

html.theme-sf .btn-secondary,
html.theme-sf .btn-light,
html.theme-sf .btn-outline-secondary,
html.theme-sf .btn-outline-primary {
  background: linear-gradient(180deg, #ffffff 0%, #e8e8e9 100%);
  border: 1px solid #b5b5b5;
  color: #333333;
}

html.theme-sf .btn-secondary:hover,
html.theme-sf .btn-light:hover,
html.theme-sf .btn-outline-secondary:hover,
html.theme-sf .btn-outline-primary:hover {
  background: linear-gradient(180deg, #f4f4f4 0%, #dcdcdd 100%);
  border-color: #9a9a9a;
  color: #222222;
}

html.theme-sf .btn-primary {
  background: linear-gradient(180deg, #2f80cf 0%, #236fbd 100%) !important;
  border: 1px solid #1c5a99 !important;
  color: #ffffff !important;
  box-shadow: 0 1px 3px rgba(35, 111, 189, 0.3);
}

html.theme-sf .btn-primary:hover {
  background: linear-gradient(180deg, #3a8cd9 0%, #2a7ac9 100%) !important;
  transform: none;
}

/* ナビバー内のアウトラインボタンは白文字を維持（青帯上） */
html.theme-sf .navbar-dark .btn-outline-light {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.75);
  color: #ffffff;
}

/* ============================================================
   6. フォーム・テーブル・バッジ・モーダル・タブ
   ============================================================ */
html.theme-sf .form-control,
html.theme-sf .form-select {
  border-radius: 3px;
  border-color: #b5b5b5;
  font-size: 13px;
}

html.theme-sf .form-control:focus,
html.theme-sf .form-select:focus {
  border-color: #015ba7;
  box-shadow: 0 0 0 0.15rem rgba(1, 91, 167, 0.2);
}

html.theme-sf .table {
  font-size: 12.5px;
  border-color: #dcdcdc;
}

html.theme-sf .table thead th {
  background-color: #f0efeb;
  border-color: #dcdcdc;
  color: #222222;
}

html.theme-sf .badge {
  border-radius: 3px;
  font-weight: bold;
}

html.theme-sf .modal-content {
  border-radius: 3px;
  border: 1px solid #b5b5b5;
}

html.theme-sf .nav-tabs .nav-link {
  border-radius: 3px 3px 0 0;
  color: #015ba7;
}

html.theme-sf .nav-tabs .nav-link.active {
  border-color: #dcdcdc #dcdcdc #ffffff;
  color: #222222;
  font-weight: bold;
}

/* ============================================================
   7. マーケットプレイス固有（紫グラデのハードコード箇所を SF 青へ）
   ============================================================ */
html.theme-sf .hero-section,
html.theme-sf .search-btn,
html.theme-sf .install-btn,
html.theme-sf .filter-actions .btn-primary,
html.theme-sf .provider-icon-large,
html.theme-sf .feature-icon {
  background: linear-gradient(180deg, #1f7db6 0%, #16527c 100%) !important;
}

html.theme-sf .search-btn:hover,
html.theme-sf .install-btn:hover,
html.theme-sf .filter-actions .btn-primary:hover {
  background: linear-gradient(180deg, #2a8ac4 0%, #1d618f 100%) !important;
}

html.theme-sf .provider-card.featured-card {
  border: 1px solid #236fbd;
  background: linear-gradient(180deg, rgba(35, 111, 189, 0.03) 0%, #ffffff 100%);
}

/* ============================================================
   8. テーマ切り替え UI（両テーマ共通 = html.theme-sf スコープ外）
   ============================================================ */
.sf-theme-toggle-btn {
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1.4;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid #b5b5b5;
  background: #ffffff;
  color: #333333;
  margin-left: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sf-theme-toggle-btn:hover {
  background: #f0f0f0;
}

/* 暗色ナビバー上では白アウトラインに */
.navbar-dark .sf-theme-toggle-btn,
.navbar-portal .sf-theme-toggle-btn {
  border-color: rgba(255, 255, 255, 0.75);
  background: transparent;
  color: #ffffff;
}

.navbar-dark .sf-theme-toggle-btn:hover,
.navbar-portal .sf-theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ナビバーが無いページ（auth_wizard / legal / provider_chat 等）用の右下固定ボタン */
.sf-theme-toggle-float {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 2050;
  margin-left: 0;
  padding: 6px 12px;
  font-size: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* 切り替え時のトースト通知 */
.sf-theme-toast {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: #222222;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 0.8rem;
  z-index: 3000;
  opacity: 0.95;
  pointer-events: none;
}

/* ============================================================
   9. 洗練層 v2（2026-06-11 第2弾: 幅・タイポ階層・メニュー統一・余白）
   機能保持の原則: ID/クラス/DOM 構造は一切変更せず CSS のみで整える。
   ============================================================ */

/* --- 9.1 コンテンツ幅の統一（ワイド画面での読みやすさ） --- */
html.theme-sf main.container,
html.theme-sf main.container-fluid {
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
}

html.theme-sf .usage-main {
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* --- 9.2 タイポグラフィ階層（SF Classic 比率・視認性確保） --- */
html.theme-sf h1 { font-size: 21px; }
html.theme-sf h2 { font-size: 18px; }
html.theme-sf h3 { font-size: 16px; }
html.theme-sf h4 { font-size: 15px; }
html.theme-sf h5 { font-size: 14px; }
html.theme-sf h6 { font-size: 13px; }

html.theme-sf h1,
html.theme-sf h2,
html.theme-sf h3,
html.theme-sf h4,
html.theme-sf h5,
html.theme-sf h6 {
  color: #222222;
  font-weight: bold;
  line-height: 1.4;
}

/* 補助テキストのコントラスト改善（淡灰背景上で読めるグレー） */
html.theme-sf .text-muted,
html.theme-sf .text-secondary {
  color: #6b695f !important;
}

html.theme-sf small,
html.theme-sf .small {
  font-size: 11.5px;
}

/* --- 9.3 統一ナビのSFタブ風スタイル（portal-nav.js 生成の項目） --- */
html.theme-sf .navbar {
  padding-top: 4px;
  padding-bottom: 4px;
}

html.theme-sf .navbar-brand {
  font-size: 15px;
  font-weight: bold;
}

html.theme-sf .navbar .navbar-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85) !important;
}

html.theme-sf .navbar .portal-nav-item {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: rgba(255, 255, 255, 0.92) !important;
  font-size: 12px;
  font-weight: bold;
  border-radius: 3px;
  padding: 5px 10px;
}

html.theme-sf .navbar .portal-nav-item:hover {
  background: rgba(255, 255, 255, 0.16) !important;
  color: #ffffff !important;
}

html.theme-sf .navbar .portal-nav-item.active {
  background: #f3f2ee !important;
  color: #16527c !important;
  border-color: #134668 !important;
}

/* ナビ項目が多いときは折り返して全項目到達可能に */
html.theme-sf .navbar .ms-auto.d-flex {
  flex-wrap: wrap;
}

/* provider-detail 等の白ナビは下線で SF 帯と調和させる */
html.theme-sf nav.navbar:not(.navbar-dark) {
  border-bottom: 2px solid #16527c;
}

html.theme-sf .nav-menu .nav-link {
  color: #015ba7;
  font-size: 13px;
  font-weight: bold;
}

/* --- 9.4 カード余白・密度（すっきりした情報密度） --- */
html.theme-sf .card-header {
  padding: 8px 12px;
  font-size: 13px;
}

html.theme-sf .card-body {
  padding: 14px 16px;
}

/* --- 9.5 テーブル（行ホバー・ヘッダー帯・余白） --- */
html.theme-sf .table thead th {
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

html.theme-sf .table td,
html.theme-sf .table th {
  padding: 8px 10px;
  vertical-align: middle;
}

html.theme-sf .table tbody tr:hover {
  background-color: #f7f6f1;
}

/* --- 9.6 フォーム（ラベルの視認性） --- */
html.theme-sf .form-label {
  font-size: 12px;
  font-weight: bold;
  color: #444444;
  margin-bottom: 4px;
}

/* --- 9.7 ボタン高さの統一 --- */
html.theme-sf .btn {
  padding: 5px 12px;
  line-height: 1.5;
}

html.theme-sf .btn-sm {
  padding: 3px 8px;
  font-size: 11.5px;
}

html.theme-sf .btn-lg {
  padding: 8px 18px;
  font-size: 14px;
}

/* --- 9.8 バッジ・区切り線 --- */
html.theme-sf .badge {
  font-size: 11px;
  padding: 3px 7px;
}

html.theme-sf hr {
  border-color: #dcdcdc;
  opacity: 1;
}

/* ============================================================
   10. /session（セッション管理）SF Classic 化
   session_management.mjs は単一のサーバー生成ページ。
   汎用クラス名（.container/.header/.section/.btn）を使うため、
   他ページへの漏れ防止に body.session-mgmt でスコープする。
   機能（フォーム・トグル・モーダル・JS）には一切触れない。
   ============================================================ */
html.theme-sf body.session-mgmt {
  padding: 16px;
}

html.theme-sf body.session-mgmt .container {
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* --- 10.1 ヘッダー帯（紫 → SF青） --- */
html.theme-sf body.session-mgmt .header {
  background: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);
  border-bottom: 1px solid #134668;
  padding: 22px 24px;
}

html.theme-sf body.session-mgmt .header h1 {
  font-size: 21px;
  letter-spacing: 0;
}

html.theme-sf body.session-mgmt .header p {
  font-size: 12.5px;
}

html.theme-sf body.session-mgmt .nav-link {
  border-radius: 3px;
  font-size: 12px;
}

/* --- 10.2 セクション（白カード + 淡灰見出し下線） --- */
html.theme-sf body.session-mgmt .section {
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 3px;
  padding: 20px;
}

html.theme-sf body.session-mgmt .section h2 {
  color: #222222;
  font-size: 16px;
  border-bottom: 2px solid #16527c;
}

/* --- 10.3 フォーム（角丸3px・青フォーカス） --- */
html.theme-sf body.session-mgmt .form-group input,
html.theme-sf body.session-mgmt .form-group select {
  border-radius: 3px;
  border: 1px solid #b5b5b5;
  font-size: 13px;
}

html.theme-sf body.session-mgmt .form-group input:focus,
html.theme-sf body.session-mgmt .form-group select:focus {
  border-color: #015ba7;
  box-shadow: 0 0 0 3px rgba(1, 91, 167, 0.15);
}

/* --- 10.4 ボタン（紫 → SF青、危険=赤・成功=緑は意味を維持） --- */
html.theme-sf body.session-mgmt .btn {
  background: linear-gradient(180deg, #2f80cf 0%, #236fbd 100%);
  border: 1px solid #1c5a99;
  border-radius: 3px;
  padding: 6px 14px;
  font-size: 12.5px;
}

html.theme-sf body.session-mgmt .btn:hover {
  background: linear-gradient(180deg, #3a8cd9 0%, #2a7ac9 100%);
  transform: none;
  box-shadow: 0 1px 3px rgba(35, 111, 189, 0.3);
}

html.theme-sf body.session-mgmt .btn-danger {
  background: linear-gradient(180deg, #e25d5d 0%, #c93a3a 100%);
  border-color: #a32e2e;
}

html.theme-sf body.session-mgmt .btn-danger:hover {
  background: linear-gradient(180deg, #e96e6e 0%, #d44848 100%);
  box-shadow: 0 1px 3px rgba(201, 58, 58, 0.3);
}

html.theme-sf body.session-mgmt .btn-success {
  background: linear-gradient(180deg, #4faa6d 0%, #3a8f57 100%);
  border-color: #2e7245;
}

html.theme-sf body.session-mgmt .btn-success:hover {
  background: linear-gradient(180deg, #5cb87a 0%, #459c63 100%);
  box-shadow: 0 1px 3px rgba(58, 143, 87, 0.3);
}

/* --- 10.5 URL 表示・バッジ --- */
html.theme-sf body.session-mgmt .url-section {
  background: #f7f6f1;
  border-radius: 3px;
  border-left: 3px solid #236fbd;
}

html.theme-sf body.session-mgmt .url-section code {
  border-radius: 3px;
  background: #ecebe6;
}

html.theme-sf body.session-mgmt .origin-crm {
  background: #e8f1f9;
  color: #15497c;
  border: 1px solid #c4d8ea;
}

/* --- 10.6 トグル（紫 → SF青。Code Mode の橙→赤は警告の意味なので維持） --- */
html.theme-sf body.session-mgmt .toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(180deg, #2f80cf 0%, #236fbd 100%);
}

html.theme-sf body.session-mgmt .toggle-label.on {
  color: #015ba7;
}

/* --- 10.7 絞り込みピル（紫 → SF青） --- */
html.theme-sf body.session-mgmt .filter-pill {
  border-radius: 3px;
  border-color: #b5b5b5;
  font-size: 12.5px;
}

html.theme-sf body.session-mgmt .filter-pill:hover {
  border-color: #236fbd;
  color: #015ba7;
}

html.theme-sf body.session-mgmt .filter-pill.active {
  background: linear-gradient(180deg, #2f80cf 0%, #236fbd 100%);
  border-color: #1c5a99;
  color: #ffffff;
}

/* --- 10.8 モーダル・フッター（紫帯 → SF青帯） --- */
html.theme-sf body.session-mgmt .modal-header {
  background: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);
  border-radius: 3px 3px 0 0;
}

html.theme-sf body.session-mgmt .footer-nav {
  background: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);
  border: 1px solid #134668;
  border-radius: 3px;
}

/* ============================================================
   11. /portal/ai_agent.html SF Classic 化
   既にサイト共通テーマは適用済みだが、hero の暗紺グラデと
   丸い角丸（999px / 0.75rem）が SF テーマ時に不統一のため、
   body.ai-agent スコープで揃える。機能・JS には触れない。
   ============================================================ */
html.theme-sf body.ai-agent .hero-card {
  background: linear-gradient(180deg, #1f7db6 0%, #16527c 100%);
  border: 1px solid #134668;
  border-radius: 3px;
}

html.theme-sf body.ai-agent .hero-chip {
  border-radius: 3px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.18);
}

html.theme-sf body.ai-agent .portal-shortcut {
  border-radius: 3px;
  font-size: 12.5px;
}

html.theme-sf body.ai-agent .hero-card .rounded-4 {
  border-radius: 3px !important;
}

html.theme-sf body.ai-agent .run-status {
  border-radius: 3px;
}

html.theme-sf body.ai-agent .json-box {
  border-radius: 3px;
}

html.theme-sf body.ai-agent .run-card:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
