/* =============================================================
 * /app/ テーマトークン + セマンティック複合クラス
 *
 * テーマ: 候補A（n2p ブランド: ベース黒 / アクセントイエロー）で確定済み。
 * 色は本ファイルにのみ定義する。画面 PHP への 16 進カラーコード直書きは禁止。
 * テーマ変更は :root の変数差し替えのみで完了する構造（phase1_ux_spec.md §2）。
 *
 * 注意: アクセント (--app-accent) は白地でのコントラストが低いため、
 * 文字色・単独ボタン色には使用禁止。装飾（左ボーダー・下線・ドット等）限定。
 * ============================================================= */

/* Tailwind の display ユーティリティ（.flex / .block 等）が HTML の hidden 属性に
 * 勝ってしまい、modal.hidden = true でも非表示にならない問題への対処。
 * hidden 属性を最優先で display:none にする（/app/ 全体が elem.hidden の
 * true/false でトグルする前提のため、この土台ルールが必須）。 */
[hidden] { display: none !important; }

:root {
  --app-brand:        #111111;  /* 主ボタン・サイドバーのアクティブ・見出し強調 */
  --app-brand-hover:  #2d2d2d;
  --app-accent:       #F4F400;  /* バナー左線・アクティブ下線等のポイント色（広面積・文字には使わない） */
  --app-surface:      #ffffff;  /* カード・サイドバー */
  --app-surface-soft: #f7f7f5;  /* ページ背景・テーブルヘッダ */
  --app-ink:          #111111;  /* 本文 */
  --app-ink-soft:     #6b7280;  /* 注記・補助 */
  --app-line:         #e5e7eb;  /* 罫線 */
  --app-danger:       #dc2626;
  --app-success:      #16a34a;
  --app-warning:      #d97706;

  /* 派生トークン（バッジ・flash 用の淡色系） */
  --app-green-bg:     #dcfce7;
  --app-green-text:   #15803d;
  --app-gray-bg:      #f3f4f6;
  --app-gray-text:    #374151;
  --app-red-bg:       #fee2e2;
  --app-red-text:     #b91c1c;
  --app-yellow-bg:    #fef9c3;
  --app-yellow-text:  #a16207;
  --app-blue-bg:      #dbeafe;
  --app-blue-text:    #1d4ed8;
  --app-disabled-bg:  #9ca3af;
  --app-disabled-text:#b3b6bd;
  --app-flash-success-bg:     #f0fdf4;
  --app-flash-success-border: #bbf7d0;
  --app-flash-error-bg:       #fef2f2;
  --app-flash-error-border:   #fecaca;
  --app-flash-warning-bg:     #fefce8;
  --app-flash-warning-border: #fef08a;
}

/* -------------------------------------------------------------
 * セマンティック複合クラス 11 種（phase1_ux_spec.md §2.2）
 * ------------------------------------------------------------- */

/* 1. 主ボタン（保存・作成・連携） */
.app-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--app-brand);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--app-brand);
  border-radius: 0.5rem;
  padding: 0.625rem 1.25rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.app-btn-primary:hover {
  background: var(--app-brand-hover);
  border-color: var(--app-brand-hover);
}
.app-btn-primary:disabled,
.app-btn-primary[aria-disabled="true"] {
  background: var(--app-disabled-bg);
  border-color: var(--app-disabled-bg);
  cursor: not-allowed;
}

/* 2. 副ボタン（戻る・キャンセル） */
.app-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--app-surface);
  color: var(--app-ink);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--app-line);
  border-radius: 0.5rem;
  padding: 0.625rem 1.25rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.app-btn-secondary:hover {
  background: var(--app-surface-soft);
}
.app-btn-secondary:disabled,
.app-btn-secondary[aria-disabled="true"] {
  color: var(--app-disabled-text);
  cursor: not-allowed;
}

/* 3. 破壊的操作ボタン */
.app-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--app-danger);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--app-danger);
  border-radius: 0.5rem;
  padding: 0.625rem 1.25rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.app-btn-danger:hover {
  opacity: 0.85;
}
.app-btn-danger:disabled,
.app-btn-danger[aria-disabled="true"] {
  background: var(--app-disabled-bg);
  border-color: var(--app-disabled-bg);
  opacity: 1;
  cursor: not-allowed;
}

/* 4. コンテンツカード */
.app-card {
  background: var(--app-surface);
  border: 1px solid var(--app-line);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

/* 5. 機能説明バナー */
.app-banner {
  background: var(--app-surface-soft);
  border-left: 4px solid var(--app-accent);
  border-radius: 0.5rem;
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--app-ink);
}

/* 6. input / textarea / select 共通 */
.app-input {
  display: block;
  width: 100%;
  background: var(--app-surface);
  color: var(--app-ink);
  font-size: 1rem; /* iOS ズーム防止のため text-base 相当 */
  border: 1px solid var(--app-line);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}
.app-input:focus,
.app-input:focus-visible {
  outline: 2px solid var(--app-brand);
  outline-offset: 1px;
  border-color: var(--app-brand);
}
.app-input:disabled {
  background: var(--app-surface-soft);
  color: var(--app-ink-soft);
  cursor: not-allowed;
}

/* 7. フォームラベル */
.app-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--app-ink);
  margin-bottom: 0.25rem;
}

/* 8. 注記（「ユーザーには表示されません」等） */
.app-note {
  font-size: 0.75rem;
  color: var(--app-ink-soft);
}

/* 9. フィールドエラー文言 */
.app-error {
  font-size: 0.875rem;
  color: var(--app-danger);
  margin-top: 0.25rem;
}

/* 10. ステータスバッジ（green / gray / red / yellow / blue） */
.app-badge-green,
.app-badge-gray,
.app-badge-red,
.app-badge-yellow,
.app-badge-blue {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.app-badge-green  { background: var(--app-green-bg);  color: var(--app-green-text); }
.app-badge-gray   { background: var(--app-gray-bg);   color: var(--app-gray-text); }
.app-badge-red    { background: var(--app-red-bg);    color: var(--app-red-text); }
.app-badge-yellow { background: var(--app-yellow-bg); color: var(--app-yellow-text); }
.app-badge-blue   { background: var(--app-blue-bg);   color: var(--app-blue-text); }

/* 11. 一覧テーブル */
.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.app-table thead th {
  background: var(--app-surface-soft);
  color: var(--app-ink-soft);
  text-align: left;
  font-weight: 600;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--app-line);
  white-space: nowrap;
}
.app-table tbody td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--app-line);
  color: var(--app-ink);
}
.app-table tbody tr:hover {
  background: var(--app-surface-soft);
}

/* -------------------------------------------------------------
 * レイアウト補助（サイドバーナビ / flash / ページネーション）
 * ------------------------------------------------------------- */

/* サイドバーナビ項目（アクティブ: 左ボーダー 3px アクセント + surface-soft + semibold） */
.app-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  border-left: 3px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--app-ink-soft);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.app-nav-item:hover {
  background: var(--app-surface-soft);
  color: var(--app-ink);
}
.app-nav-active {
  border-left-color: var(--app-accent);
  background: var(--app-surface-soft);
  color: var(--app-ink);
  font-weight: 600;
}
.app-nav-disabled,
.app-nav-disabled:hover {
  color: var(--app-disabled-text);
  background: transparent;
  cursor: not-allowed;
}

/* flash メッセージ（success / error / warning。自動消滅させない） */
.app-flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid;
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}
.app-flash-success {
  background: var(--app-flash-success-bg);
  border-color: var(--app-flash-success-border);
  color: var(--app-green-text);
}
.app-flash-error {
  background: var(--app-flash-error-bg);
  border-color: var(--app-flash-error-border);
  color: var(--app-red-text);
}
.app-flash-warning {
  background: var(--app-flash-warning-bg);
  border-color: var(--app-flash-warning-border);
  color: var(--app-yellow-text);
}
.app-flash-close {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 1.125rem;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  padding: 0 0.25rem;
}

/* 中央配置ページネーション */
.app-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 1.5rem;
  font-size: 0.875rem;
}
.app-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--app-line);
  border-radius: 0.375rem;
  background: var(--app-surface);
  color: var(--app-ink-soft);
}
a.app-page-link:hover {
  background: var(--app-surface-soft);
  color: var(--app-ink);
}
.app-page-current {
  background: var(--app-brand);
  border-color: var(--app-brand);
  color: #ffffff;
}
.app-page-ellipsis {
  padding: 0 0.25rem;
  color: var(--app-ink-soft);
}

/* -------------------------------------------------------------
 * ImStar Pro の案内（一文）。lib/app/ui.php app_pro_hint_html() が出力する。
 * 注記（.app-note）と同じ大きさで、作業の流れを邪魔しない。黄色は印の下線だけ（装飾限定の決まりどおり）。
 * ------------------------------------------------------------- */
.app-pro-hint {
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--app-ink-soft);
}
.app-pro-hint a {
  color: var(--app-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.app-pro-hint a:hover {
  text-decoration: none;
}
.app-pro-chip {
  display: inline-block;
  margin-right: 0.375rem;
  padding: 0 0.3rem;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--app-ink);
  background: var(--app-surface);
  border: 1px solid var(--app-ink);
  border-radius: 0.25rem;
  box-shadow: inset 0 -3px 0 var(--app-accent);
  vertical-align: 1px;
  white-space: nowrap;
}

/* フォーカスリングは消さない（focus-visible で brand 色リング） */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--app-brand);
  outline-offset: 2px;
}
