/* FontAwesomeはPHP側でenqueueしています */

/* CSS変数とトランジション */
.etb-wrapper {
  --details-transition: height 0.35s ease, opacity 0.35s ease;
  --icon-transition: transform 0.3s ease;
  position: relative;
  overflow: visible; /* 吹き出しが見切れないように */
}

/* テーブル基本スタイル */
.etb-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 20px 0;
  border: var(--border-width, 1px) var(--border-style, solid) var(--border-color, #ddd);
  table-layout: fixed;
}

.etb-table th,
.etb-table td {
  border: var(--border-width, 1px) var(--border-style, solid) var(--border-color, #ddd);
  padding: var(--cell-padding, 8px);
  text-align: left;
  line-height: 1.4;
  vertical-align: middle;
  word-wrap: break-word;
  overflow: hidden;
  position: relative; /* ノッチ疑似要素の基準にする */
}

/* 1列目セル用ノッチ（左下） */
.etb-first-cell[data-notch-type="triangle"]::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border-left: var(--etb-notch-size, 12px) solid var(--etb-notch-color, var(--border-color, #ddd));
  border-top: var(--etb-notch-size, 12px) solid transparent;
  pointer-events: none;
  z-index: 1;
}

.etb-first-cell[data-notch-type="circle"]::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: var(--etb-notch-size, 12px);
  height: var(--etb-notch-size, 12px);
  background: var(--etb-notch-color, var(--border-color, #ddd));
  border-top-right-radius: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ヘッダースタイル - !importantを削除して優先度を調整 */
.etb-wrapper .etb-table th {
  background-color: var(--header-bg-color, #000000);
  color: var(--header-text-color, #ffffff);
  font-weight: bold;
  font-size: 16px;
  padding: 12px var(--cell-padding, 8px);
  vertical-align: middle;
  text-align: var(--header-text-align, left);
  border: var(--border-width, 1px) var(--border-style, solid) var(--border-color, #ddd);
}

.etb-wrapper .etb-table .etb-row-section-header td {
  background-color: var(--header-bg-color, #000000);
  color: var(--header-text-color, #ffffff);
  font-weight: bold;
  font-size: 16px;
  padding: 12px var(--cell-padding, 8px);
  vertical-align: middle;
  text-align: var(--header-text-align, left);
  border: var(--border-width, 1px) var(--border-style, solid) var(--border-color, #ddd);
}

/* 行スタイル - シマシマ背景対応 */
.etb-wrapper .etb-table .etb-row {
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
  background-color: var(--row-bg-color, #ffffff);
  color: var(--row-text-color, #333333);
  -webkit-tap-highlight-color: transparent;
}

/* シマシマ背景設定 - 優先度を上げる */
.etb-wrapper[data-striped="true"] .etb-table .etb-row.etb-striped-odd {
  background-color: var(--row-striped-odd-color, #f9f9f9);
}

.etb-wrapper[data-striped="true"] .etb-table .etb-row.etb-striped-even {
  background-color: var(--row-striped-even-color, #ffffff);
}

/* ホバー時もストライプを維持 */
.etb-wrapper[data-striped="true"] .etb-table .etb-row.etb-striped-odd:hover {
  background-color: var(--row-hover-bg-color, #e6f3ff);
}

.etb-wrapper[data-striped="true"] .etb-table .etb-row.etb-striped-even:hover {
  background-color: var(--row-hover-bg-color, #e6f3ff);
}

/* ホバー時の背景色と文字色 */
.etb-wrapper .etb-table .etb-row:hover,
.etb-wrapper .etb-table .etb-row.active {
  background-color: var(--row-hover-bg-color, #e6f3ff);
  color: var(--row-hover-text-color, #333333);
}

/* セクションヘッダー行の統一 */
.etb-wrapper .etb-table .etb-row-section-header {
  background-color: var(--header-bg-color);
  color: var(--header-text-color);
  font-weight: bold;
  cursor: default;
}

.etb-wrapper .etb-table .etb-row-section-header:hover {
  background-color: var(--header-bg-color);
  color: var(--header-text-color);
}

/* 展開アイコン - サイズ調整 */
.etb-expand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  color: var(--row-text-color, #333333);
  min-width: 20px;
  height: 100%;       /* 行の高さに追従して上下中央寄せしやすくする */
  min-height: 20px;   /* アイコンが小さくなりすぎないように */
  text-align: center;
  vertical-align: middle;
}

/* アイコン基本スタイル - 三角アイコンを大きく */
.etb-icon {
  transition: var(--icon-transition);
  font-size: 14px;
}

.etb-wrapper[data-expand-icon-type="arrow"] .etb-icon {
  font-size: 18px;
}

/* ホバー時のアイコン色変更 */
.etb-row:hover .etb-expand-icon {
  color: var(--row-hover-text-color, #333333);
}

/* 三角アイコン（右向き→下向き 90度回転） */
.etb-wrapper[data-expand-icon-type="arrow"] .etb-expand-icon.open .etb-icon {
  transform: rotate(90deg);
}

/* プラス/マイナスアイコン（クルクル回転） */
.etb-wrapper[data-expand-icon-type="plus"] .etb-icon {
  transition: transform 0.3s ease;
}

/* シェブロンアイコン（右向き→下向き 90度回転） */
.etb-wrapper[data-expand-icon-type="chevron"] .etb-expand-icon.open .etb-icon {
  transform: rotate(90deg);
}

.etb-wrapper[data-expand-icon-type="chevron"] .etb-row:hover .etb-expand-icon .etb-icon {
  transform: scale(1.1);
  color: var(--row-hover-text-color, #333);
}

.etb-wrapper[data-expand-icon-type="chevron"] .etb-row:hover .etb-expand-icon.open .etb-icon {
  transform: rotate(90deg) scale(1.1);
  color: var(--row-hover-text-color, #333);
}

/* 展開トグルボタン - エディター風の見た目 */
.etb-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  padding: 0;
  margin-right: 6px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: pointer;
}

.etb-toggle-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-1px);
}

.etb-toggle-btn .etb-expand-icon {
  margin: 0;
}

/* 詳細行 */
.etb-details {
  display: table-row; /* SEOのためDOM上は表示しておき、内部で折りたたむ */
}

.etb-details td {
  padding: 0;
  border: none;
  border-top: var(--border-width, 1px) var(--border-style, solid) var(--border-color, #ddd);
}

/* 非表示の詳細行は隙間を出さない */
.etb-details[aria-hidden="true"] td {
  border-top: none;
  padding: 0;
  line-height: 0;
  font-size: 0;
}

/* 非表示の詳細行を挟んだ2行間の二重ボーダーを解消 */
.etb-details[aria-hidden="true"] + .etb-row td {
  border-top: none;
}

/* 詳細コンテンツアニメーション */
.etb-details-outer {
  overflow: hidden;
  height: 0;
  opacity: 0;
  background-color: var(--details-bg-color, #ffffff);
  color: var(--details-text-color, #333333);
  transition: height 0.35s ease, opacity 0.35s ease;
  will-change: height, opacity;
  border: none;
}

/* 開いている詳細のみ枠線を表示（行間の1px隙間防止） */
.etb-details[aria-hidden="false"] .etb-details-outer {
  border: var(--border-width, 1px) var(--border-style, solid) var(--border-color, #ddd);
  border-top: none;
}

.etb-details-inner {
  padding: var(--details-padding, 15px);
}

.etb-details-inner > *:first-child {
  margin-top: 0;
}

.etb-details-inner > *:last-child {
  margin-bottom: 0;
}

/* 詳細内の段落余白を適切に確保 */
.etb-details-inner p {
  margin: 0 0 1em;
  line-height: 1.7;
}
.etb-details-inner p:first-child {
  margin-top: 0;
}
.etb-details-inner p:last-child {
  margin-bottom: 0;
}

/* 閉じるボタン */
.etb-close {
  display: block;
  width: 100%;
  margin: 15px auto 0;
  padding: 10px 0;
  font-weight: bold;
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  border: none;
  background: var(--close-bg-color, #ef4444);
  color: var(--close-text-color, #ffffff);
  transition: filter 0.2s, background-color 0.2s, color 0.2s;
}

.etb-close:hover {
  filter: brightness(0.9);
}

.etb-close.style-outline {
  background: transparent;
  color: var(--close-text-color, #ef4444);
  border: 2px solid var(--close-border-color, #ef4444);
}

.etb-close.style-outline:hover {
  background: var(--close-bg-color, #ef4444);
  color: var(--close-text-color, #ffffff);
}

.etb-close.style-link {
  background: none;
  border: none;
  color: var(--close-text-color, #ef4444);
  padding: 0;
  margin-top: 10px;
  width: auto;
  text-align: left;
  display: inline-block;
  text-decoration: underline;
}

.etb-close.style-link:hover {
  text-decoration: none;
  filter: brightness(0.8);
}

/* 操作ガイドバブル - 見切れ対策と改善されたスタイル */
.etb-guide-bubble {
  position: fixed; /* body に固定して位置ブレ防止 */
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  animation: etbBubbleBounce 2s infinite;
  max-width: 280px;
  min-width: 220px;
  border: 2px solid transparent;
  /* 見切れ対策 */
  margin: 20px;
}

/* 左側表示の吹き出し - 見切れ対策 */
.etb-guide-bubble.position-left {
  top: 100px;
  left: 20px; /* 見切れないように調整 */
  transform: translateX(0); /* 見切れ防止 */
}

.etb-guide-bubble.position-left::before {
  content: "";
  position: absolute;
  top: 50%;
  right: -14px;
  transform: translateY(-50%);
  border: 12px solid transparent;
  border-left-color: var(--guide-bubble-bg-color, #2271b1);
}

/* 右側表示の吹き出し - 見切れ対策 */
.etb-guide-bubble.position-right {
  top: 100px;
  right: 20px; /* 見切れないように調整 */
  transform: translateX(0); /* 見切れ防止 */
}

.etb-guide-bubble.position-right::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -14px;
  transform: translateY(-50%);
  border: 12px solid transparent;
  border-right-color: var(--guide-bubble-bg-color, #2271b1);
}

.etb-guide-bubble-title {
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 16px;
}

.etb-guide-bubble-content {
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.4;
}

.etb-guide-bubble-ok {
  border: 2px solid transparent;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.etb-guide-bubble-ok:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 中央オーバーレイ */
.etb-guide-overlay.style-center {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.etb-guide-overlay.style-center .etb-guide-content {
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  text-align: center;
  animation: etbModalSlideIn 0.3s ease-out;
}

.etb-guide-overlay.style-center .etb-guide-ok {
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 15px;
}

/* 右下ポップアップ */
.etb-guide-popup.style-bottom-right {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  max-width: 300px;
  animation: etbSlideInRight 0.5s ease-out;
}

.etb-guide-popup.style-bottom-right .etb-guide-ok {
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
}

/* サイドバー - アニメーション修正 */
.etb-guide-sidebar.style-left-sidebar {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 20px;
  border-radius: 0 8px 8px 0;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  max-width: 250px;
  animation: etbSlideInLeftFixed 0.5s ease-out forwards;
}

.etb-guide-sidebar.style-left-sidebar .etb-guide-ok {
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 15px;
  width: 100%;
}

.etb-guide-sidebar.style-right-sidebar {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 20px;
  border-radius: 8px 0 0 8px;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  max-width: 250px;
  animation: etbSlideInRightFixed 0.5s ease-out forwards;
}

.etb-guide-sidebar.style-right-sidebar .etb-guide-ok {
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 15px;
  width: 100%;
}

/* レスポンシブ対応 - 小さい画面では吹き出しを調整 */
@media (max-width: 768px) {
  .etb-guide-bubble {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    max-width: none;
    margin: 0;
  }

  .etb-guide-bubble.position-left,
  .etb-guide-bubble.position-right {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    transform: none;
  }

  .etb-guide-bubble.position-left::before,
  .etb-guide-bubble.position-right::before {
    display: none;
  }
}

/* “にゅっと”出現用の初期状態とアニメーション */
.etb-animate-in {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  will-change: transform, opacity;
  transition: opacity 220ms ease, transform 240ms ease;
}
.etb-animate-in.etb-animate-in--play {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* 低モーション環境ではアニメーションを抑制 */
@media (prefers-reduced-motion: reduce) {
  .etb-details-outer,
  .etb-icon,
  .etb-guide-bubble,
  .etb-guide-overlay .etb-guide-content,
  .etb-guide-popup,
  .etb-guide-sidebar {
    transition: none !important;
    animation: none !important;
  }
}

/* アニメーション定義 - サイドバー修正版 */
@keyframes etbBubbleBounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes etbModalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes etbSlideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes etbSlideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* サイドバー用の固定アニメーション */
@keyframes etbSlideInLeftFixed {
  from {
    opacity: 0;
    transform: translateX(-100%) translateY(-50%);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(-50%);
  }
}

@keyframes etbSlideInRightFixed {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(-50%);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(-50%);
  }
}

/* セル内画像（改行させて配置、整列オプション） */
.etb-img-ol {
  display: block;             /* テキストの次行に強制改行（デフォルト） */
  margin-top: 6px;            /* テキストとの間隔 */
}
.etb-img-ol.etb-inline {
  display: inline-block;      /* テキストと同じ行に表示 */
  margin-top: 0;              /* 余分な上マージンを解除 */
  vertical-align: middle;
}
.etb-img-ol img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: var(--etb-h, auto);       /* JSから可変（px） */
  object-fit: var(--etb-fit, contain);
  object-position: 50% var(--etb-y, 50%);
}

.etb-img-ol.align-left {
  margin-left: 0;
  margin-right: auto;
}
.etb-img-ol.align-center {
  margin-left: auto;
  margin-right: auto;
}
.etb-img-ol.align-right {
  margin-left: auto;
  margin-right: 0;
}

/* インラインレイアウト時の配置（テキスト回り込み） */
.etb-img-ol.etb-inline.align-left {
  float: left;
  margin-left: 0;
  margin-right: 8px;
}
.etb-img-ol.etb-inline.align-right {
  float: right;
  margin-left: 8px;
  margin-right: 0;
}
.etb-img-ol.etb-inline.align-center {
  float: none;
  display: block;     /* 中央寄せ時は1行下にブロック表示 */
  margin-left: auto;
  margin-right: auto;
}

/* スマホ時の画像見切れ対策 */
@media (max-width: 640px) {
  .etb-img-ol,
  .etb-img-ol.etb-inline {
    float: none !important;         /* 回り込みを解除して縦積み */
    display: block !important;
    width: 100% !important;         /* セル幅いっぱいに収める */
    max-width: 100% !important;
    margin-left: 0;
    margin-right: 0;
  }

  .etb-img-ol img {
    width: 100% !important;         /* インライン style=width:XXXpx を上書き */
    max-width: 100% !important;
    height: auto;                   /* 高さも自動にして縦方向の見切れを抑える */
    object-fit: contain;
  }
}
