/* Bootstrap 5 互換性レイヤー */
/* Bootstrap 4からBootstrap 5への移行をスムーズにするための互換性CSS */

/* ========================================
   削除されたユーティリティクラスの互換性
   ======================================== */

/* Badge関連 (BS4 → BS5) */
.badge-primary { 
  background-color: var(--bs-primary) !important;
  color: white !important;
}
.badge-secondary { 
  background-color: var(--bs-secondary) !important;
  color: white !important;
}
.badge-success { 
  background-color: var(--bs-success) !important;
  color: white !important;
}
.badge-danger { 
  background-color: var(--bs-danger) !important;
  color: white !important;
}
.badge-warning { 
  background-color: var(--bs-warning) !important;
  color: var(--bs-dark) !important;
}
.badge-info { 
  background-color: var(--bs-info) !important;
  color: white !important;
}
.badge-light { 
  background-color: var(--bs-light) !important;
  color: var(--bs-dark) !important;
}
.badge-dark { 
  background-color: var(--bs-dark) !important;
  color: white !important;
}

/* グリッドシステム互換性 */
.no-gutters { 
  --bs-gutter-x: 0;
  --bs-gutter-y: 0;
}

/* 左右マージン・パディング (BS4 → BS5) */
.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }
.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: 0.25rem !important; }
.ml-2 { margin-left: 0.5rem !important; }
.ml-3 { margin-left: 1rem !important; }
.ml-4 { margin-left: 1.5rem !important; }
.ml-5 { margin-left: 3rem !important; }
.mr-0 { margin-right: 0 !important; }
.mr-1 { margin-right: 0.25rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.mr-3 { margin-right: 1rem !important; }
.mr-4 { margin-right: 1.5rem !important; }
.mr-5 { margin-right: 3rem !important; }

.pl-0 { padding-left: 0 !important; }
.pl-1 { padding-left: 0.25rem !important; }
.pl-2 { padding-left: 0.5rem !important; }
.pl-3 { padding-left: 1rem !important; }
.pl-4 { padding-left: 1.5rem !important; }
.pl-5 { padding-left: 3rem !important; }
.pr-0 { padding-right: 0 !important; }
.pr-1 { padding-right: 0.25rem !important; }
.pr-2 { padding-right: 0.5rem !important; }
.pr-3 { padding-right: 1rem !important; }
.pr-4 { padding-right: 1.5rem !important; }
.pr-5 { padding-right: 3rem !important; }

/* テキスト配置 (BS4 → BS5) */
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

/* レスポンシブテキスト配置 (BS4 → BS5) */
@media (min-width: 576px) {
  .text-sm-left { text-align: left !important; }
  .text-sm-right { text-align: right !important; }
  .text-sm-center { text-align: center !important; }
}

@media (min-width: 768px) {
  .text-md-left { text-align: left !important; }
  .text-md-right { text-align: right !important; }
  .text-md-center { text-align: center !important; }
}

@media (min-width: 992px) {
  .text-lg-left { text-align: left !important; }
  .text-lg-right { text-align: right !important; }
  .text-lg-center { text-align: center !important; }
}

@media (min-width: 1200px) {
  .text-xl-left { text-align: left !important; }
  .text-xl-right { text-align: right !important; }
  .text-xl-center { text-align: center !important; }
}

/* Form関連 (BS4 → BS5) */
.form-control-file {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  background-clip: padding-box;
  border: var(--bs-border-width) solid var(--bs-border-color);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: var(--bs-border-radius);
  transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -5px;
  margin-left: -5px;
}

.form-row > .col,
.form-row > [class*="col-"] {
  padding-right: 5px;
  padding-left: 5px;
}

/* Input group関連 */
.input-group-append,
.input-group-prepend {
  display: flex;
}

.input-group > .input-group-append > .btn,
.input-group > .input-group-append > .input-group-text,
.input-group > .input-group-prepend > .btn,
.input-group > .input-group-prepend > .input-group-text {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Float関連 */
.float-left { float: left !important; }
.float-right { float: right !important; }

/* その他のユーティリティ */
.font-weight-bold { font-weight: 700 !important; }
.font-weight-normal { font-weight: 400 !important; }
.font-weight-light { font-weight: 300 !important; }

/* モーダル・ドロップダウンのdata属性サポート用クラス */
[data-toggle="collapse"],
[data-toggle="modal"],
[data-toggle="dropdown"],
[data-toggle="tab"],
[data-toggle="pill"] {
  cursor: pointer;
}

/* カスタムコントロール (BS4形式) */
.custom-control {
  position: relative;
  z-index: 1;
  display: block;
  min-height: 1.5rem;
  padding-left: 1.5rem;
  color-adjust: exact;
}

.custom-control-inline {
  display: inline-flex;
  margin-right: 1rem;
}

.custom-control-input {
  position: absolute;
  left: 0;
  z-index: -1;
  width: 1rem;
  height: 1.25rem;
  opacity: 0;
}

.custom-control-label {
  position: relative;
  margin-bottom: 0;
  vertical-align: top;
}

/* Jumbotron (BS5で削除) */
.jumbotron {
  padding: 2rem 1rem;
  margin-bottom: 2rem;
  background-color: #e9ecef;
  border-radius: 0.3rem;
}

@media (min-width: 576px) {
  .jumbotron {
    padding: 4rem 2rem;
  }
}

/* Media object (BS5で削除) */
.media {
  display: flex;
  align-items: flex-start;
}

.media-body {
  flex: 1;
}

/* Card deck (BS5で削除) */
.card-deck {
  display: flex;
  flex-flow: row wrap;
  margin-right: -15px;
  margin-left: -15px;
}

.card-deck .card {
  flex: 1 0 0%;
  margin-right: 15px;
  margin-bottom: 0;
  margin-left: 15px;
}

/* ========================================
   Bootstrap 5で変更されたボタンスタイル
   ======================================== */

/* btn-infoの文字色を白に（Bootstrap 4互換） */
.btn-info {
  color: white !important;
}

.btn-info:hover {
  color: white !important;
}

/* btn-info.activeの文字色を黒に（視認性向上） */
.btn-info.active,
.btn-info:active,
.btn-info.active:hover,
.btn-info.active:focus {
  color: #000 !important;
}

/* btn-successの文字色を白に */
.btn-success,
.btn-success.active,
.btn-success:active {
  color: white !important;
}

.btn-primary,
.btn-primary.active,
.btn-primary:active {
  color: white !important;
}

.btn-danger,
.btn-danger.active,
.btn-danger:active {
  color: white !important;
}

.btn-warning,
.btn-warning.active,
.btn-warning:active {
  color: black !important;
}

.btn-secondary,
.btn-secondary.active,
.btn-secondary:active {
  color: white !important;
}

.btn-dark,
.btn-dark.active,
.btn-dark:active {
  color: white !important;
}

/* ========================================
   table-responsiveの余白修正
   ======================================== */

/* Bootstrap 5でtable-responsiveに付く余分なパディングを削除 */
.table-responsive {
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* DataTablesのラッパーの余白も調整 */
.dataTables_wrapper {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* DataTables 2.xのレイアウトクラスの余白を削除 */
.dt-layout-row,
.dt-layout-cell,
.dt-layout-full,
[class*="dt-layout"] {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* DataTablesが追加するcol-mdクラスのパディングを削除 */
.dataTables_wrapper .col-md,
.dataTables_wrapper [class*="col-"] {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ========================================
   stretched-linkの互換性修正
   ======================================== */

/* Bootstrap 5でstretched-linkが動作するための親要素設定 */
.position-relative {
  position: relative !important;
}

/* よく使われるクラスにposition: relativeを追加 */
.races,
.card,
.card-body,
.list-group-item,
td.link,
.row,
[class*="col-"] {
  position: relative;
}

/* リンクを含む要素の最小高さ確保 */
.stretched-link {
  z-index: 1;
}

/* 他の要素がリンクを覆わないように */
.stretched-link::after {
  z-index: 1;
}

/* ========================================
   テーブル表示互換性（BS4 → BS5）
   ======================================== */

/* テーブルのフォントサイズとパディングをBS4相当に戻す */
.table {
  font-size: 0.875rem !important; /* BS5のRFSを無効化し、元のサイズに固定 */
}

/* 現本番と同じテーブルセルpadding (0.1em) - 詳細度を上げてBootstrap5を確実に上書き */
body .table td,
body .table th,
body table.dataTable td,
body table.dataTable th {
  padding: 0.1em !important;
  font-size: 0.875rem !important; /* 14px固定 */
}

/* table-smの場合はさらに小さく */
.table-sm td,
.table-sm th {
  padding: .2rem !important;
  font-size: 0.8rem !important;
}

/* DataTablesのセルも同様に調整 */
table.dataTable tbody td,
table.dataTable tbody th {
  padding: .3rem !important;
  font-size: 0.875rem !important;
}

/* ========================================
   テーブルヘッダー互換性（BS4 → BS5）
   ======================================== */

/* thead-dark (BS4) → table-dark (BS5相当) */
.thead-dark {
  background-color: #343a40 !important;
}

.thead-dark th {
  background-color: #343a40 !important;
  color: white !important;
  border-color: #454d55 !important;
}

/* thead-light (BS4) → デフォルトスタイル */
.thead-light {
  background-color: #f8f9fa !important;
}

.thead-light th {
  background-color: #f8f9fa !important;
  color: #495057 !important;
  border-color: #dee2e6 !important;
}

/* ========================================
   カードボディのパディング調整
   ======================================== */

/* card-bodyの上下パディングを広げる */
.card-body {
  padding-top: 1.5rem !important;
  padding-bottom: 1.5rem !important;
}

/* ========================================
   補足ヘルプアラートの改善デザイン
   ======================================== */

/* デフォルトの補足ヘルプスタイル（既存のalert-lightを改善） */
.alert-light {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-left: 3px solid #6c757d;
  border-radius: 6px;
}

.alert-light ul {
  margin-bottom: 0;
  padding-left: 1.2rem;
}

.alert-light li {
  color: #495057;
  line-height: 1.6;
}

/* コンパクトな情報表示用 */
.alert-info-compact {
  background: linear-gradient(to right, #e3f2fd, #f3f4f6);
  border: 1px solid #90caf9;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.alert-info-compact ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.alert-info-compact li {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
}

.alert-info-compact li:before {
  content: "▸";
  color: #1976d2;
  font-weight: bold;
  margin-right: 0.25rem;
}

/* ========================================
   DataTables 2.0+ 空レイアウトコンテナ非表示
   ======================================== */

/* DataTables 2.0+で自動生成される空のレイアウトコンテナを非表示 */
.dt-layout-start:empty,
.dt-layout-end:empty {
  display: none !important;
}

