/* ===================================
   ダークモード対策CSS
   端末のダークモード設定に影響されないライトテーマ固定
   =================================== */

/* ===================================
   ルート要素のカラースキーム固定
   =================================== */
:root {
  color-scheme: only light !important;
  
  /* 背景色と文字色を明示的に指定 */
  --bg-primary: #ffffff !important;
  --bg-secondary: #f8f9fa !important;
  --bg-card: #ffffff !important;
  
  /* 文字色も明示的に指定 */
  --text-primary: #1a1a1a !important;
  --text-secondary: #495057 !important;
  --text-muted: #6c757d !important;
  --text-light: #f8f9fa !important;
  --text-dark: #212529 !important;
}

/* ===================================
   HTML/Body要素の基本設定
   =================================== */
html {
  color-scheme: only light !important;
  background-color: #ffffff !important;
  color: #1a1a1a !important;
}

body {
  background-color: #ffffff !important;
  color: #1a1a1a !important;
}

/* フッターは常に暗い背景と白文字 */
.footer {
  background-color: #1a2332 !important;
}

.footer,
.footer p,
.footer span,
.footer div,
.footer .copyright,
.footer .footer-links,
.footer .footer-links a {
  color: #ffffff !important;
}

.footer .footer-links a:hover {
  color: #ddd !important;
  text-decoration: underline;
}

/* ===================================
   ダークモード設定を無視
   =================================== */
@media (prefers-color-scheme: dark) {
  :root {
    /* 背景色と文字色をライトモードに強制 */
    --bg-primary: #ffffff !important;
    --bg-secondary: #f8f9fa !important;
    --bg-card: #ffffff !important;
    
    /* 文字色も強制的にライトモード用に */
    --text-primary: #1a1a1a !important;
    --text-secondary: #495057 !important;
    --text-muted: #6c757d !important;
    --text-light: #f8f9fa !important;
    --text-dark: #212529 !important;
  }
  
  html, body {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  /* すべての要素の背景を明示的に設定 */
  * {
    color-scheme: only light !important;
  }
  
  /* カード要素 */
  .card, .office-card, .type-card {
    background-color: #ffffff !important;
    border-color: #dee2e6 !important;
    color: #1a1a1a !important;
  }
  
  /* ヘッダー・フッター */
  .header {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  /* フッターは暗い背景のままで文字は白 */
  .footer {
    background-color: #1a2332 !important;
  }
  
  .footer,
  .footer *,
  .footer .copyright,
  .footer .footer-links,
  .footer .footer-links a {
    color: #ffffff !important;
  }
  
  .footer .footer-links a:hover {
    color: #ccc !important;
  }
  
  /* ナビゲーション */
  .nav, .nav-menu {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  .nav-link {
    color: #1a1a1a !important;
  }
  
  /* フォーム要素 */
  input, select, textarea {
    background-color: #ffffff !important;
    border-color: #ced4da !important;
    color: #1a1a1a !important;
  }
  
  /* テーブル */
  table, th, td {
    background-color: #ffffff !important;
    border-color: #dee2e6 !important;
    color: #1a1a1a !important;
  }
  
  /* セクション背景と文字色 */
  .hero, .diagnosis-section, .types-section, .offices-section, .faq-section {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  .emergency-alert {
    background-color: #fff3cd !important;
    color: #856404 !important;
  }
  
  /* FAQ */
  .faq-item {
    background-color: #ffffff !important;
    border-color: #dee2e6 !important;
    color: #1a1a1a !important;
  }
  
  .faq-question {
    background-color: #f8f9fa !important;
    color: #1a1a1a !important;
  }
  
  .faq-answer {
    background-color: #ffffff !important;
    color: #495057 !important;
  }
  
  /* Legal pages */
  .legal-footer {
    background-color: #f8f9fa !important;
    color: #1a1a1a !important;
  }
  
  .legal-header {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  /* モバイルメニューオーバーレイ */
  .nav-overlay {
    background-color: rgba(0, 0, 0, 0.5) !important;
  }
  
  /* 影の調整 */
  .card, .office-card, .type-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  }
}

/* ===================================
   フォーム要素のダークモード対策
   =================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-color: #ffffff !important;
}

/* Safariのフォーム要素対策 */
@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    -webkit-opacity: 1 !important;
  }
}

/* ===================================
   スクロールバーのスタイル（Webkit）
   =================================== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1 !important;
}

::-webkit-scrollbar-thumb {
  background: #888 !important;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555 !important;
}

/* ===================================
   選択テキストの背景色と文字色
   =================================== */
::selection {
  background-color: #0052cc !important;
  color: #ffffff !important;
}

::-moz-selection {
  background-color: #0052cc !important;
  color: #ffffff !important;
}

/* ===================================
   モバイル専用ダークモード対策
   =================================== */
@media (max-width: 768px) {
  /* すべてのテキスト要素に文字色を強制 */
  p, span, div, a, li, h1, h2, h3, h4, h5, h6, 
  label, button, td, th {
    color: #1a1a1a !important;
  }
  
  /* ボタンのテキスト色 */
  .btn-primary, .btn-success, .btn-danger {
    color: #ffffff !important;
  }
  
  /* リンクの色 */
  a:not(.btn) {
    color: #0052cc !important;
  }
  
  /* フッターは例外的に白文字を維持 */
  .footer {
    background-color: #1a2332 !important;
  }
  
  .footer,
  .footer p,
  .footer span,
  .footer div,
  .footer .copyright,
  .footer .footer-links,
  .footer .footer-links a,
  .footer .footer-bottom,
  .footer .footer-bottom * {
    color: #ffffff !important;
  }
  
  /* 見出しの文字色を確実に設定 */
  .card-title, .section-title {
    color: #1a1a1a !important;
  }
  
  /* モバイルナビメニュー */
  .nav-menu.active {
    background-color: #ffffff !important;
  }
  
  .nav-menu.active .nav-link {
    color: #1a1a1a !important;
  }
}

/* ===================================
   法的ページ専用ダークモード対策
   =================================== */
.legal-page {
  background-color: #ffffff !important;
  color: #1a1a1a !important;
}

@media (prefers-color-scheme: dark) {
  /* 法的ページの変数を上書き */
  .legal-page {
    --legal-text-primary: #1a1a1a !important;
    --legal-text-secondary: #374151 !important;
    --legal-text-muted: #6b7280 !important;
    --legal-bg-primary: #ffffff !important;
    --legal-bg-secondary: #f9fafb !important;
    --legal-bg-card: #ffffff !important;
    --legal-gray-900: #111827 !important;
    --legal-gray-700: #374151 !important;
    --legal-gray-500: #6b7280 !important;
  }
  
  /* 法的ページの要素 */
  .legal-page body {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  .legal-header {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  .legal-nav {
    background-color: #ffffff !important;
  }
  
  .legal-logo {
    color: #1a1a1a !important;
  }
  
  .legal-content {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  .legal-section {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
  }
  
  .legal-card {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
    border-color: #e5e7eb !important;
  }
  
  /* 法的ページのテキスト要素を強制 */
  .legal-page p,
  .legal-page span,
  .legal-page div,
  .legal-page li,
  .legal-page h1,
  .legal-page h2,
  .legal-page h3,
  .legal-page h4,
  .legal-page h5,
  .legal-page h6 {
    color: #1a1a1a !important;
  }
  
  /* 法的ページのリンク */
  .legal-page a:not(.btn) {
    color: #2563eb !important;
  }
  
  /* 法的ページのフッター（暗い背景） */
  .legal-page .legal-footer {
    background-color: #111827 !important;
  }
  
  .legal-page .legal-footer,
  .legal-page .legal-footer * {
    color: #ffffff !important;
  }
  
  /* テーブル要素 */
  .legal-page table,
  .legal-page th,
  .legal-page td {
    background-color: #ffffff !important;
    border-color: #e5e7eb !important;
    color: #1a1a1a !important;
  }
  
  /* リスト要素 */
  .legal-page ul,
  .legal-page ol {
    color: #1a1a1a !important;
  }
  
  /* 引用ブロック */
  .legal-page blockquote {
    background-color: rgba(37, 99, 235, 0.05) !important;
    border-left-color: #2563eb !important;
    color: #1a1a1a !important;
  }
}

/* モバイル用法的ページ追加対策 */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  .legal-page,
  .legal-page * {
    background-color: #ffffff !important;
  }
  
  .legal-page .legal-footer,
  .legal-page .legal-footer * {
    background-color: #111827 !important;
    color: #ffffff !important;
  }
  
  /* すべてのテキスト要素の文字色を確実に設定 */
  .legal-page p,
  .legal-page span,
  .legal-page div:not(.legal-footer),
  .legal-page li,
  .legal-page h1,
  .legal-page h2,
  .legal-page h3,
  .legal-page h4,
  .legal-page h5,
  .legal-page h6,
  .legal-page td,
  .legal-page th,
  .legal-page label {
    color: #1a1a1a !important;
  }
}