/* ===== 統合モーダルスタイル ===== */
/* モーダル関連のすべてのスタイルを1つのファイルに統合 */

/* ────────────────────────────────────────────────
   製品モーダル (#detailModal) 専用スタイル
   ──────────────────────────────────────────────── */

/* 旧 bottom 固定ボタンの無効化を削除（閉じるボタンを表示） */

/* 製品モーダルの閉じるボタンを確実に表示 */
#detailModal .modal-content > .modal-close:first-of-type {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* モーダル本体を flex 縦積みにして余白を排除 */
#detailModal .modal-content {
  position: relative;                /* 絶対配置の基準 */
  display: flex;
  flex-direction: column;
  max-height: 95vh;
  width: min(920px, 90vw);
  overflow: hidden;                  /* 外にスクロールバーを出さない */
  margin: 0 !important;              /* 不要な外側余白を殺す */
}

/* 上部ヘッダーは shrink、本文は flex:1 で全残り高さ */
#detailModal .modal-header-wrapper {
  flex: 0 0 auto;
}

#detailModal .modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  /* -webkit-overflow-scrollingを削除してスクロールを安定化 */
  -webkit-overflow-scrolling: auto;
  padding-bottom: 100vh !important; /* ビューポート高さ分の余白を追加 */
  /* スクロール時のパフォーマンス向上 */
  will-change: scroll-position;
}

/* 閉じるボタンを下部中央に固定配置 */
#detailModal .modal-close,
#detailModal .modal-content .modal-close {
  /* 表示を強制 */
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  
  /* 位置を下部中央に固定 */
  position: fixed !important;
  bottom: 3.5rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  
  /* 上部・右側の位置設定を無効化 */
  top: auto !important;
  right: auto !important;
  
  /* サイズと形状 */
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  margin: 0 !important;
  
  /* グラスモーフィズムデザイン */
  background: rgba(0, 0, 0, 0.7) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
  
  /* 中央揃え */
  align-items: center !important;
  justify-content: center !important;
  
  /* インタラクション */
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  
  /* 最前面に配置 */
  z-index: 999999 !important;
}

/* detailModal直下に移動された閉じるボタンは非表示にする（削除） */

/* ホバー時 */
#detailModal .modal-close:hover,
#detailModal .modal-content .modal-close:hover {
  background: rgba(255, 190, 100, 0.3) !important;
  border-color: var(--app-yellow, #FFBE64) !important;
  box-shadow: 0 0 20px rgba(255, 190, 100, 0.5) !important;
  transform: translateX(-50%) scale(1.1) !important;
}

/* アクティブ時 */
#detailModal .modal-close:active,
#detailModal .modal-content .modal-close:active {
  transform: translateX(-50%) scale(0.95) !important;
}

/* アイコンスタイル */
#detailModal .modal-close svg,
#detailModal .modal-content .modal-close svg {
  width: 24px !important;
  height: 24px !important;
  stroke: rgba(255, 255, 255, 0.9) !important;
  stroke-width: 2.5 !important;
  fill: none !important;
  display: block !important;
}

/* iOS のスクロールグラデーションを消す（下部白帯対策） */
#detailModal .modal-body::-webkit-scrollbar {
  display: none;
}

/* Force mini header to be compact */
#detailModal .modal-header-mini {
  height: 2.5rem !important;
  padding: 0.25rem 1rem !important;
}

#detailModal.header-minimized .modal-tabs {
  margin-top: 2.5rem !important;
}

/* Normal header padding */
#detailModal .modal-header {
  padding: 2rem !important;
}

/* Remove margin from app icon */
#detailModal .app-icon-large {
  margin-top: 0 !important;
  margin-bottom: 0.75rem !important;
}

/* Adjust title spacing */
#detailModal .modal-header h3 {
  margin-top: 0 !important;
  margin-bottom: 0.5rem !important;
}

/* Adjust subtitle spacing */
#detailModal .modal-header .app-subtitle {
  margin-top: 0 !important;
  margin-bottom: 0.75rem !important;
}

/* Adjust badges spacing */
#detailModal .modal-header .app-badges {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* Override all conflicting styles */
#detailModal:not(.header-minimized) .modal-header {
  padding-top: 0.5rem !important;
}

/* Ensure mini header stays at very top */
#detailModal .modal-header-mini {
  top: 0 !important;
  margin-top: 0 !important;
}

/* ライトモード用の閉じるボタンスタイル */
[data-theme="light"] #detailModal .modal-close,
[data-theme="light"] #detailModal .modal-content .modal-close,
body.lightMode #detailModal .modal-close,
body.lightMode #detailModal .modal-content .modal-close {
  /* Liquid Glass エフェクト */
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.25) 0%, 
    rgba(255, 255, 255, 0.15) 100%) !important;
  backdrop-filter: blur(20px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 
    0 8px 32px rgba(31, 38, 135, 0.15),
    inset 0 2px 4px rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(0, 0, 0, 0.05) !important;
}

/* ライトモード用のホバー時 */
[data-theme="light"] #detailModal .modal-close:hover,
[data-theme="light"] #detailModal .modal-content .modal-close:hover,
body.lightMode #detailModal .modal-close:hover,
body.lightMode #detailModal .modal-content .modal-close:hover {
  background: linear-gradient(135deg, 
    rgba(255, 190, 100, 0.35) 0%, 
    rgba(255, 190, 100, 0.25) 100%) !important;
  border-color: rgba(255, 190, 100, 0.5) !important;
  box-shadow: 
    0 8px 32px rgba(255, 190, 100, 0.25),
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(255, 140, 0, 0.1) !important;
  transform: translateX(-50%) scale(1.1) !important;
}

/* ライトモード用のアイコンカラー */
[data-theme="light"] #detailModal .modal-close svg,
[data-theme="light"] #detailModal .modal-content .modal-close svg,
body.lightMode #detailModal .modal-close svg,
body.lightMode #detailModal .modal-content .modal-close svg {
  stroke: rgba(0, 0, 0, 0.7) !important;
}

/* Mobile specific override */
@media (max-width: 768px) {
  #detailModal .modal-header,
  #detailModal:not(.header-minimized) .modal-header {
    padding-top: 0.5rem !important;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
    padding-bottom: 0.75rem !important;
  }
  
  #detailModal .modal-close,
  #detailModal .modal-content .modal-close {
    width: 48px !important;
    height: 48px !important;
    bottom: 2.5rem !important;
  }
  
  #detailModal .modal-close svg,
  #detailModal .modal-content .modal-close svg {
    width: 20px !important;
    height: 20px !important;
  }
}

/* iOS safe area */
@supports (bottom: env(safe-area-inset-bottom)) {
  #detailModal .modal-content {
    max-height: calc(95vh - env(safe-area-inset-bottom));
  }
}

/* ────────────────────────────────────────────────
   汎用モーダル（非製品用）のスタイル改善
   ──────────────────────────────────────────────── */

/* デフォルトのモーダルオーバーレイ */
.modal-overlay:not(#detailModal) {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active:not(#detailModal) {
  opacity: 1;
  visibility: visible;
}

/* 汎用モーダルコンテンツ */
.modal-overlay:not(#detailModal) .modal-content {
  position: relative;
  background: var(--background, #0E1116);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-large, 20px);
  padding: 3rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: all 0.3s ease;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 400px;
}

/* ライトモード用のモーダルスタイル */
[data-theme="light"] .modal-overlay:not(#detailModal) .modal-content,
body.lightMode .modal-overlay:not(#detailModal) .modal-content {
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.modal-overlay.active:not(#detailModal) .modal-content {
  transform: translateY(0);
}

/* 汎用モーダルの閉じるボタン（下部中央配置） */
.modal-overlay:not(#detailModal) .modal-close {
  /* 表示を強制 */
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  
  /* 位置を下部中央に固定 */
  position: fixed !important;
  bottom: 3.5rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  
  /* 上部・右側の位置設定を無効化 */
  top: auto !important;
  right: auto !important;
  
  /* サイズと形状 */
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  
  /* グラスモーフィズムデザイン */
  background: rgba(0, 0, 0, 0.7) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
  
  /* 中央揃え */
  align-items: center !important;
  justify-content: center !important;
  
  /* インタラクション */
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  
  /* 最前面に配置 */
  z-index: 999999 !important;
}

/* ホバー時 */
.modal-overlay:not(#detailModal) .modal-close:hover {
  background: rgba(255, 190, 100, 0.3) !important;
  border-color: var(--app-yellow, #FFBE64) !important;
  box-shadow: 0 0 20px rgba(255, 190, 100, 0.5) !important;
  transform: translateX(-50%) scale(1.1) !important;
}

/* アクティブ時 */
.modal-overlay:not(#detailModal) .modal-close:active {
  transform: translateX(-50%) scale(0.95) !important;
}

/* アイコンスタイル */
.modal-overlay:not(#detailModal) .modal-close svg {
  width: 24px !important;
  height: 24px !important;
  stroke: rgba(255, 255, 255, 0.9) !important;
  stroke-width: 2.5 !important;
  display: block !important;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .modal-overlay:not(#detailModal) .modal-close {
    width: 48px !important;
    height: 48px !important;
    bottom: 2.5rem !important;
  }
  
  .modal-overlay:not(#detailModal) .modal-close svg {
    width: 20px !important;
    height: 20px !important;
  }
  
  .modal-overlay:not(#detailModal) .modal-content {
    width: 95%;
    padding: 1.5rem;
    margin: 1rem;
  }
}

/* モーダルコンテンツとの干渉を防ぐためのパディング */
.modal-overlay:not(#detailModal) .modal-body {
  padding-bottom: 6rem !important;
}

/* モーダルヘッダー */
.modal-overlay:not(#detailModal) .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--app-yellow, #FFBE64);
  position: relative;
}

.modal-overlay:not(#detailModal) .modal-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100px;
  height: 2px;
  background: linear-gradient(90deg, var(--app-yellow, #FFBE64) 0%, transparent 100%);
}

.modal-overlay:not(#detailModal) .modal-title {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--app-yellow, #FFBE64), var(--app-yellow-light, #FFD599));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 1.5rem 0;
  letter-spacing: 0.02em;
  text-align: center;
}

/* モーダルボディ */
.modal-overlay:not(#detailModal) .modal-body {
  color: var(--text-medium, rgba(255, 255, 255, 0.9));
  line-height: 1.8;
  font-size: 1.05rem;
  padding: 0 1rem;
  text-align: left;
  width: 100%;
}

/* ライトモード用のテキストカラー */
[data-theme="light"] .modal-overlay:not(#detailModal) .modal-body,
body.lightMode .modal-overlay:not(#detailModal) .modal-body {
  color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .modal-overlay:not(#detailModal) .modal-title,
body.lightMode .modal-overlay:not(#detailModal) .modal-title {
  background: linear-gradient(135deg, #FF8C00, #FFA500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .modal-overlay:not(#detailModal) .modal-content {
    padding: 2rem;
    min-height: 350px;
    width: 95%;
  }
  
  .modal-overlay:not(#detailModal) .modal-title {
    font-size: 1.5rem;
  }
  
  .modal-overlay:not(#detailModal) .modal-body {
    font-size: 1rem;
    padding: 0 0.5rem;
  }
}

/* ライトモード用の汎用モーダル閉じるボタン */
[data-theme="light"] .modal-overlay:not(#detailModal) .modal-close,
body.lightMode .modal-overlay:not(#detailModal) .modal-close {
  /* Liquid Glass エフェクト */
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.25) 0%, 
    rgba(255, 255, 255, 0.15) 100%) !important;
  backdrop-filter: blur(20px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 
    0 8px 32px rgba(31, 38, 135, 0.15),
    inset 0 2px 4px rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(0, 0, 0, 0.05) !important;
}

/* ライトモード用のホバー時 */
[data-theme="light"] .modal-overlay:not(#detailModal) .modal-close:hover,
body.lightMode .modal-overlay:not(#detailModal) .modal-close:hover {
  background: linear-gradient(135deg, 
    rgba(255, 190, 100, 0.35) 0%, 
    rgba(255, 190, 100, 0.25) 100%) !important;
  border-color: rgba(255, 190, 100, 0.5) !important;
  box-shadow: 
    0 8px 32px rgba(255, 190, 100, 0.25),
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(255, 140, 0, 0.1) !important;
  transform: translateX(-50%) scale(1.1) !important;
}

/* ライトモード用のアイコンカラー */
[data-theme="light"] .modal-overlay:not(#detailModal) .modal-close svg,
body.lightMode .modal-overlay:not(#detailModal) .modal-close svg {
  stroke: rgba(0, 0, 0, 0.7) !important;
}

/* お問い合わせモーダル専用スタイル */
.contact-email-link {
  position: relative;
}

/* ライトモードでのメールリンクスタイル */
[data-theme="light"] .contact-email-link,
body.lightMode .contact-email-link {
  color: #FF6B00 !important; /* 濃いオレンジ色で視認性を向上 */
  font-weight: 600;
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.08) 0%, rgba(255, 107, 0, 0.05) 100%);
}

[data-theme="light"] .contact-email-link:hover,
body.lightMode .contact-email-link:hover {
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.15) 0%, rgba(255, 107, 0, 0.1) 100%);
  color: #FF5500 !important;
  transform: translateX(2px);
}

/* ライトモードでのボタンスタイル */
[data-theme="light"] .contact-email-button,
body.lightMode .contact-email-button {
  background: linear-gradient(135deg, #FF6B00 0%, #FF8C00 100%) !important;
  box-shadow: 0 4px 16px rgba(255, 107, 0, 0.25) !important;
  font-weight: 600;
}

[data-theme="light"] .contact-email-button:hover,
body.lightMode .contact-email-button:hover {
  background: linear-gradient(135deg, #FF5500 0%, #FF7700 100%) !important;
  box-shadow: 0 6px 20px rgba(255, 107, 0, 0.35) !important;
  transform: translateY(-2px);
}

/* ライトモードでのテキストコントラスト強化 */
[data-theme="light"] .contact-info-modal h4,
body.lightMode .contact-info-modal h4 {
  color: #333333 !important;
  font-weight: 600;
}

[data-theme="light"] .contact-info-modal p,
body.lightMode .contact-info-modal p {
  color: #555555 !important;
}

[data-theme="light"] .modal-overlay:not(#detailModal) .modal-body .contact-info-modal > p:first-child,
body.lightMode .modal-overlay:not(#detailModal) .modal-body .contact-info-modal > p:first-child {
  color: #666666 !important;
}

/* アイコンのコントラスト調整 */
[data-theme="light"] .contact-info-modal div[style*="width: 24px"],
body.lightMode .contact-info-modal div[style*="width: 24px"] {
  opacity: 0.8;
  filter: contrast(1.2);
}

/* ダークモードでのメールボタンスタイル */
.contact-email-button {
  background: var(--app-yellow, #FFBE64) !important;
  color: rgba(0, 0, 0, 0.9) !important;
  font-weight: 600;
}

.contact-email-button:hover {
  background: #FFD599 !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 190, 100, 0.4) !important;
}

/* ダークモードでのメールリンク */
.contact-email-link {
  color: var(--app-yellow, #FFBE64) !important;
}

.contact-email-link:hover {
  color: #FFD599 !important;
  background: rgba(255, 190, 100, 0.1);
}

/* ローディングアニメーション */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ボタンテキストのトランジション */
.contact-email-button .button-text {
  transition: opacity 0.3s ease;
  display: inline-block;
}

/* ローディング状態のボタン */
.contact-email-button[style*="pointer-events: none"] {
  cursor: not-allowed !important;
  opacity: 0.9;
}

/* 成功状態のボタン (緑色) */
.contact-email-button[style*="background: rgb(76, 217, 100)"] {
  background: #4CD964 !important;
  color: white !important;
}

/* ライトモードでの成功状態 */
[data-theme="light"] .contact-email-button[style*="background: rgb(76, 217, 100)"],
body.lightMode .contact-email-button[style*="background: rgb(76, 217, 100)"] {
  background: #34C759 !important;
  color: white !important;
  box-shadow: 0 4px 16px rgba(52, 199, 89, 0.3) !important;
}

/* その他のスタイル（リンク、リスト、フォーム等）は必要に応じて維持 */

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

.modal-overlay.active:not(#detailModal) .modal-content {
  animation: modalFadeIn 0.3s ease-out;
}