/* path: frontend/css/modules/tooltip-base.css */

/* ========== 基本ツールチップスタイル ========== */
/* 既存レイアウトに影響しない独立したツールチップ実装 */

/* ========== 情報アイコンスタイル ========== */
.prompt-info-icon {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  font-size: 14px;
  margin-left: 6px;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s ease;
  vertical-align: middle;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.prompt-info-icon:hover {
  color: #007bff;
  background-color: rgba(0, 123, 255, 0.1);
  transform: scale(1.1);
}

.prompt-info-icon:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
  color: #007bff;
}

.prompt-info-icon:active {
  transform: scale(0.95);
}

/* アイコン内のSVG */
.prompt-info-icon svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

/* ========== ジャンルボタン内の情報アイコン ========== */
.genre-option {
  position: relative;
}

.genre-option .genre-info-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 2px;
  opacity: 0.7;
  z-index: 10;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.genre-option .genre-info-icon:hover {
  opacity: 1;
  transform: scale(1.1);
  background-color: rgba(0, 123, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.genre-option .genre-info-icon svg {
  width: 12px;
  height: 12px;
  color: #6c757d;
}

.genre-option .genre-info-icon:hover svg {
  color: #007bff;
}

/* ========== 文体ボタン内の情報アイコン ========== */
/* 文体ボタンの構造: div.style-option（ジャンルボタンと同じ構造） */
.style-selector .style-option .style-info-icon,
#rewriteModal .style-selector .style-option .style-info-icon,
#sectionRewriteModal .style-selector .style-option .style-info-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 2px;
  opacity: 0.7;
  z-index: 20;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.style-selector .style-option .style-info-icon:hover,
#rewriteModal .style-selector .style-option .style-info-icon:hover,
#sectionRewriteModal .style-selector .style-option .style-info-icon:hover {
  opacity: 1;
  transform: scale(1.1);
  background-color: rgba(0, 123, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.style-selector .style-option .style-info-icon svg,
#rewriteModal .style-selector .style-option .style-info-icon svg,
#sectionRewriteModal .style-selector .style-option .style-info-icon svg {
  width: 12px !important;
  height: 12px !important;
  color: #6c757d !important;
  pointer-events: none !important;
}

.style-selector .style-option .style-info-icon:hover svg,
#rewriteModal .style-selector .style-option .style-info-icon:hover svg,
#sectionRewriteModal .style-selector .style-option .style-info-icon:hover svg {
  color: #007bff !important;
}

/* ツールチップコンテナ */
.tooltip-container {
  position: absolute;
  z-index: 999999 !important; /* HTML5 dialog要素より高い優先度 */
  max-width: 320px;
  padding: 0;
  background: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  transform: translateY(-4px);
}

/* ツールチップ表示状態 */
.tooltip-container.tooltip-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* ID選択子による高優先度（!important不使用） */
#prompt-tooltip.tooltip-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* ツールチップ内容 */
.tooltip-content {
  padding: 16px;
}

/* ツールチップヘッダー */
.tooltip-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e9ecef;
}

.tooltip-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ツールチップボディ */
.tooltip-body {
  color: #6c757d;
}

/* ツールチップ矢印 */
.tooltip-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

/* 矢印の位置別スタイル */
.tooltip-container[data-placement="top"] .tooltip-arrow {
  bottom: -6px;
  left: 50%;
  margin-left: -6px;
  border-width: 6px 6px 0;
  border-color: #ffffff transparent transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.tooltip-container[data-placement="bottom"] .tooltip-arrow {
  top: -6px;
  left: 50%;
  margin-left: -6px;
  border-width: 0 6px 6px;
  border-color: transparent transparent #ffffff;
  filter: drop-shadow(0 -2px 4px rgba(0, 0, 0, 0.1));
}

.tooltip-container[data-placement="left"] .tooltip-arrow {
  right: -6px;
  top: 50%;
  margin-top: -6px;
  border-width: 6px 0 6px 6px;
  border-color: transparent transparent transparent #ffffff;
  filter: drop-shadow(2px 0 4px rgba(0, 0, 0, 0.1));
}

.tooltip-container[data-placement="right"] .tooltip-arrow {
  left: -6px;
  top: 50%;
  margin-top: -6px;
  border-width: 6px 6px 6px 0;
  border-color: transparent #ffffff transparent transparent;
  filter: drop-shadow(-2px 0 4px rgba(0, 0, 0, 0.1));
}

/* ========== ツールチップ内容スタイル ========== */

/* プロンプト方針表示用 */
.prompt-policy-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.policy-focus-areas {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.policy-focus-label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.focus-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.focus-tag {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
  white-space: nowrap;
}

.focus-tag.tag-primary {
  background-color: #e3f2fd;
  color: #1976d2;
  border: 1px solid #bbdefb;
}

.focus-tag.tag-secondary {
  background-color: #f3e5f5;
  color: #7b1fa2;
  border: 1px solid #e1bee7;
}

.focus-tag.tag-tertiary {
  background-color: #e8f5e8;
  color: #388e3c;
  border: 1px solid #c8e6c9;
}

.policy-default-style {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.policy-style-label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.policy-style-value {
  font-size: 12px;
  color: #6c757d;
  font-style: italic;
}

.policy-key-features {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.policy-features-label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.policy-features-list {
  margin: 0;
  padding-left: 16px;
  list-style-type: disc;
}

.policy-features-item {
  font-size: 12px;
  line-height: 1.3;
  color: #6c757d;
  margin-bottom: 2px;
}

/* 文体ガイド表示用 */
.style-guide-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.style-description {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.style-description-label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.style-examples {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.style-examples-label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

.style-examples-list {
  margin: 0;
  padding-left: 16px;
  list-style-type: disc;
}

.style-examples-item {
  font-size: 12px;
  line-height: 1.3;
  color: #6c757d;
  margin-bottom: 2px;
}

.style-use-cases {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.style-use-cases-label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
}

/* ========== レスポンシブ対応 ========== */
@media (max-width: 768px) {
  .tooltip-container {
    max-width: 280px;
    font-size: 12px;
  }
  
  .tooltip-content {
    padding: 12px;
  }
  
  .tooltip-title {
    font-size: 13px;
  }
  
  /* モバイルでは画面端からの距離を確保 */
  .tooltip-container {
    margin: 0 10px;
  }
  
  .focus-tag {
    font-size: 10px;
    padding: 1px 4px;
  }
  
  .policy-features-item,
  .style-examples-item {
    font-size: 11px;
  }
}

/* ========== アクセシビリティ ========== */
.tooltip-container:focus-within {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
  .tooltip-container {
    border: 2px solid #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  
  .focus-tag {
    border-width: 2px;
  }
}

/* モーション軽減設定対応 */
@media (prefers-reduced-motion: reduce) {
  .tooltip-container {
    transition: none;
  }
}

/* ダークモード対応（将来用） */
@media (prefers-color-scheme: dark) {
  .tooltip-container {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }
  
  .tooltip-header {
    border-bottom-color: #4a5568;
  }
  
  .tooltip-title {
    color: #e2e8f0;
  }
  
  .tooltip-body {
    color: #cbd5e0;
  }
  
  .focus-tag.tag-primary {
    background-color: #2b6cb0;
    color: #bee3f8;
    border-color: #3182ce;
  }
  
  .focus-tag.tag-secondary {
    background-color: #805ad5;
    color: #e9d8fd;
    border-color: #9f7aea;
  }
  
  .focus-tag.tag-tertiary {
    background-color: #38a169;
    color: #c6f6d5;
    border-color: #48bb78;
  }
}
