/**
 * APP XiDEA 共通CSS
 *
 * docs/DESIGN_SYSTEM.md のデザインシステムに基づく
 */

/* ========================================
   CSS変数定義
   ======================================== */
:root {
  /* Brand */
  --xidea-primary: #1a1a2e;
  --xidea-accent: #FF6B35;
  --xidea-accent-hover: #e85a2c;

  /* Text */
  --xidea-text: #2a2a3e;
  --xidea-text-muted: #6c757d;
  --xidea-text-light: #adb5bd;

  /* Background */
  --xidea-bg: #ffffff;
  --xidea-bg-soft: #f8f9fb;
  --xidea-bg-card: #ffffff;

  /* Border */
  --xidea-border: #e9ecef;
  --xidea-border-light: #f1f3f5;

  /* Status */
  --xidea-success: #2ecc71;
  --xidea-warning: #f39c12;
  --xidea-danger: #e74c3c;
  --xidea-info: #3498db;

  /* Shadow */
  --xidea-shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --xidea-shadow: 0 2px 10px rgba(0,0,0,0.06);
  --xidea-shadow-lg: 0 12px 30px rgba(0,0,0,0.10);

  /* Radius */
  --xidea-radius-sm: 4px;
  --xidea-radius: 8px;
  --xidea-radius-lg: 12px;

  /* Spacing */
  --xidea-space-xs: 0.25rem;
  --xidea-space-sm: 0.5rem;
  --xidea-space-md: 1rem;
  --xidea-space-lg: 2rem;
  --xidea-space-xl: 4rem;
}

/* ========================================
   基本スタイル
   ======================================== */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
               "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: var(--xidea-text);
  background-color: var(--xidea-bg-soft);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
}

main {
  flex: 1;
}

a {
  color: var(--xidea-accent);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--xidea-accent-hover);
  text-decoration: underline;
}

/* ========================================
   タイポグラフィ
   ======================================== */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  color: var(--xidea-primary);
  margin-top: 0;
}

.text-display {
  font-size: 2.5rem;
  font-weight: 800;
}

.text-h1 {
  font-size: 2rem;
  font-weight: 700;
}

.text-h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.text-h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.text-body {
  font-size: 1rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

/* ========================================
   ボタン
   ======================================== */
.btn-xidea-primary {
  background: var(--xidea-accent);
  color: white;
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: var(--xidea-radius);
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.btn-xidea-primary:hover {
  background: var(--xidea-accent-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(255,107,53,0.25);
  text-decoration: none;
}

.btn-xidea-outline {
  background: white;
  color: var(--xidea-primary);
  border: 2px solid var(--xidea-primary);
  padding: 0.65rem 1.75rem;
  border-radius: var(--xidea-radius);
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.btn-xidea-outline:hover {
  background: var(--xidea-primary);
  color: white;
  text-decoration: none;
}

.btn-xidea-ghost {
  background: transparent;
  color: var(--xidea-text);
  border: none;
  padding: 0.5rem 1rem;
  transition: background 0.2s;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}

.btn-xidea-ghost:hover {
  background: var(--xidea-bg-soft);
  text-decoration: none;
}

.btn-xidea-danger {
  background: var(--xidea-danger);
  color: white;
  border: none;
  padding: 0.75rem 1.75rem;
  border-radius: var(--xidea-radius);
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}

.btn-xidea-danger:hover {
  background: #c0392b;
  color: white;
  text-decoration: none;
}

/* ========================================
   カード
   ======================================== */
.xidea-card {
  background: var(--xidea-bg-card);
  border: 1px solid var(--xidea-border);
  border-radius: var(--xidea-radius-lg);
  box-shadow: var(--xidea-shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.2s;
}

.xidea-card:hover {
  box-shadow: var(--xidea-shadow);
}

.xidea-card-header {
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--xidea-border-light);
}

.xidea-card-body {
  /* カード本文のスタイル */
}

/* ========================================
   フォーム
   ======================================== */
.xidea-form-group {
  margin-bottom: 1.5rem;
}

.xidea-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: var(--xidea-text);
}

.xidea-label .required {
  color: var(--xidea-danger);
  margin-left: 0.25rem;
}

.xidea-input,
.xidea-select,
.xidea-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--xidea-border);
  border-radius: var(--xidea-radius);
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
  font-family: inherit;
}

.xidea-input:focus,
.xidea-select:focus,
.xidea-textarea:focus {
  outline: none;
  border-color: var(--xidea-accent);
  box-shadow: 0 0 0 3px rgba(255,107,53,0.1);
}

.xidea-input::placeholder {
  color: var(--xidea-text-light);
}

.xidea-textarea {
  min-height: 100px;
  resize: vertical;
}

.xidea-help {
  display: block;
  font-size: 0.8rem;
  color: var(--xidea-text-muted);
  margin-top: 0.25rem;
}

.xidea-error {
  display: block;
  font-size: 0.8rem;
  color: var(--xidea-danger);
  margin-top: 0.25rem;
}

/* ========================================
   バッジ・タグ
   ======================================== */
.xidea-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--xidea-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.4;
}

.xidea-badge-success {
  background: rgba(46,204,113,0.15);
  color: #1e7e44;
}

.xidea-badge-warning {
  background: rgba(243,156,18,0.15);
  color: #c87f0a;
}

.xidea-badge-danger {
  background: rgba(231,76,60,0.15);
  color: #b03328;
}

.xidea-badge-info {
  background: rgba(52,152,219,0.15);
  color: #1b6ca8;
}

.xidea-badge-muted {
  background: var(--xidea-border-light);
  color: var(--xidea-text-muted);
}

/* ========================================
   テーブル
   ======================================== */
.xidea-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--xidea-radius);
  overflow: hidden;
}

.xidea-table thead {
  background: var(--xidea-bg-soft);
}

.xidea-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--xidea-border);
  font-size: 0.875rem;
  color: var(--xidea-text-muted);
}

.xidea-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--xidea-border-light);
}

.xidea-table tbody tr:hover {
  background: var(--xidea-bg-soft);
}

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

/* ========================================
   アラート
   ======================================== */
.xidea-alert {
  padding: 1rem 1.25rem;
  border-radius: var(--xidea-radius);
  margin-bottom: 1rem;
  border-left: 4px solid;
}

.xidea-alert-success {
  background: rgba(46,204,113,0.08);
  border-color: var(--xidea-success);
  color: #1e7e44;
}

.xidea-alert-warning {
  background: rgba(243,156,18,0.08);
  border-color: var(--xidea-warning);
  color: #c87f0a;
}

.xidea-alert-danger {
  background: rgba(231,76,60,0.08);
  border-color: var(--xidea-danger);
  color: #b03328;
}

.xidea-alert-info {
  background: rgba(52,152,219,0.08);
  border-color: var(--xidea-info);
  color: #1b6ca8;
}

/* ========================================
   ヘッダー・フッター
   ======================================== */
.xidea-header {
  background: white;
  box-shadow: var(--xidea-shadow-sm);
}

.xidea-footer {
  margin-top: auto;
}

/* ========================================
   ユーティリティ
   ======================================== */
.text-primary {
  color: var(--xidea-primary) !important;
}

.text-accent {
  color: var(--xidea-accent) !important;
}

.bg-soft {
  background: var(--xidea-bg-soft) !important;
}

.xidea-divider {
  height: 1px;
  background: var(--xidea-border);
  margin: 2rem 0;
}

/* ========================================
   レスポンシブ
   ======================================== */
/* パンくずリストとページタイトルの間の余白 */
nav[aria-label="breadcrumb"] {
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .breadcrumb {
    font-size: 0.72rem;
  }

  .xidea-card {
    padding: 1rem;
  }

  .btn-xidea-primary,
  .btn-xidea-outline,
  .btn-xidea-danger {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
  }

  .text-display {
    font-size: 2rem;
  }

  .text-h1 {
    font-size: 1.75rem;
  }
}

/* ========================================
   アニメーション
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* ========================================
   Bootstrap オーバーライド
   ======================================== */
.btn-primary {
  background: var(--xidea-accent) !important;
  border-color: var(--xidea-accent) !important;
}

.btn-primary:hover {
  background: var(--xidea-accent-hover) !important;
  border-color: var(--xidea-accent-hover) !important;
}

.btn-outline-primary {
  color: var(--xidea-accent) !important;
  border-color: var(--xidea-accent) !important;
}

.btn-outline-primary:hover {
  background: var(--xidea-accent) !important;
  border-color: var(--xidea-accent) !important;
  color: white !important;
}

.text-primary {
  color: var(--xidea-accent) !important;
}

.border-primary {
  border-color: var(--xidea-accent) !important;
}

.text-muted {
  color: var(--xidea-text-muted) !important;
}

/* ========================================
   バリデーションツールチップ
   ======================================== */

/* 旧形式のエラー表示を強制的に非表示（ツールチップ導入後） */
/* 詳細度を上げてページ固有のCSSより優先 */
body .is-invalid + .invalid-feedback,
body .invalid-feedback.d-block {
  display: none !important;
}

.validation-tooltip {
  position: absolute;
  z-index: 10000;
  background: var(--xidea-danger);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: var(--xidea-radius-sm);
  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  max-width: 300px;
  word-wrap: break-word;
  pointer-events: none;
  animation: tooltipFadeIn 0.2s ease-out;
}

/* 上部表示時の矢印（下向き） */
.validation-tooltip.validation-tooltip-top::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--xidea-danger);
}

/* 下部表示時の矢印（上向き） */
.validation-tooltip.validation-tooltip-bottom::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid var(--xidea-danger);
}

/* フェードインアニメーション */
@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ボタン無効状態 */
.btn-xidea-primary:disabled,
.btn-xidea-primary[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}
