/* IT支援会社向け顧客管理ツール（CRM） - カスタムCSS */

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* タブナビゲーションの追加スタイル */
.tab-btn {
  transition: all 0.2s ease;
}

.tab-btn.active {
  font-weight: 600;
}

/* カードのホバーエフェクト */
.hover-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

/* ローディングアニメーション */
.loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .5;
  }
}

/* レスポンシブテーブル */
@media (max-width: 768px) {
  .overflow-x-auto {
    font-size: 0.875rem;
  }
}

/* ボタンの追加スタイル */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
}

/* === モバイル最適化 === */

/* タッチフレンドリーなボタンサイズ */
@media (max-width: 768px) {
  button, .btn {
    min-height: 44px; /* Apple推奨のタッチターゲットサイズ */
    min-width: 44px;
    padding: 12px 16px;
  }
  
  /* モバイルでのフォントサイズ調整 */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.125rem; }
  
  /* 入力フィールドの改善 */
  input, textarea, select {
    min-height: 44px;
    font-size: 16px; /* iOS Safariのズーム防止 */
  }
  
  /* カードの間隔調整 */
  .card-mobile {
    margin-bottom: 1rem;
    padding: 1rem;
  }
  
  /* テーブルの横スクロール改善 */
  .table-mobile {
    font-size: 0.75rem;
  }
  
  .table-mobile th,
  .table-mobile td {
    padding: 0.5rem 0.25rem;
    white-space: nowrap;
  }
}

/* モバイルメニューのアニメーション */
#mobile-menu {
  transition: all 0.3s ease-in-out;
}

/* タッチによるホバーエフェクトの調整 */
@media (hover: none) and (pointer: coarse) {
  .hover\:scale-105:hover {
    transform: none;
  }
  
  .hover\:shadow-lg:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }
}

/* ダークモード対応の基礎 */
@media (prefers-color-scheme: dark) {
  /* 将来的なダークモード対応の準備 */
  .bg-white {
    /* background-color: #1f2937; */
  }
}

/* アクセシビリティ向上 */
.focus\:ring-2:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* モバイル時の統計カードアニメーション */
@media (max-width: 768px) {
  .stat-card {
    transition: transform 0.2s ease;
  }
  
  .stat-card:active {
    transform: scale(0.95);
  }
}

/* PWA対応のビューポート調整 */
@supports (padding: max(0px)) {
  .safe-area-inset {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* =============================================================================
   ダークモード対応
   ============================================================================= */

/* ダークモードのルートカラー設定 */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-card: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --border-color: #4b5563;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* ダークモード基本スタイル */
[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="dark"] body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

[data-theme="dark"] .bg-white {
  background-color: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-gray-100 {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .bg-gray-50 {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-700 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-600,
[data-theme="dark"] .text-gray-500 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .border-gray-300,
[data-theme="dark"] .border-gray-200 {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .shadow,
[data-theme="dark"] .shadow-md {
  box-shadow: var(--shadow) !important;
}

[data-theme="dark"] .shadow-lg {
  box-shadow: var(--shadow-lg) !important;
}

/* ダークモード input/select要素 */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
  background-color: var(--bg-card) !important;
  border-color: #3b82f6 !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--text-secondary) !important;
}

/* ダークモードボタン */
[data-theme="dark"] .bg-blue-100 {
  background-color: rgba(59, 130, 246, 0.2) !important;
}

[data-theme="dark"] .bg-green-100 {
  background-color: rgba(34, 197, 94, 0.2) !important;
}

[data-theme="dark"] .bg-red-100 {
  background-color: rgba(239, 68, 68, 0.2) !important;
}

[data-theme="dark"] .bg-yellow-100 {
  background-color: rgba(245, 158, 11, 0.2) !important;
}

[data-theme="dark"] .bg-purple-100 {
  background-color: rgba(168, 85, 247, 0.2) !important;
}

[data-theme="dark"] .bg-orange-100 {
  background-color: rgba(249, 115, 22, 0.2) !important;
}

/* ダークモードテーブル */
[data-theme="dark"] table {
  background-color: var(--bg-card) !important;
}

[data-theme="dark"] thead {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] tbody tr:hover {
  background-color: var(--bg-secondary) !important;
}

/* ダークモード・モバイルメニュー */
[data-theme="dark"] #mobile-menu {
  background-color: var(--bg-card) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .mobile-tab-btn:hover {
  background-color: var(--bg-secondary) !important;
}

/* ダークモード遷移アニメーション */
* {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* ダークモードトグルボタンスタイル */
.theme-toggle {
  position: relative;
  width: 3rem;
  height: 1.5rem;
  background-color: #d1d5db;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.theme-toggle.dark {
  background-color: #3b82f6;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.25rem;
  height: 1.25rem;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle.dark::after {
  transform: translateX(1.5rem);
}

/* ダークモード用アイコン調整 */
[data-theme="dark"] .text-blue-500 {
  color: #60a5fa !important;
}

[data-theme="dark"] .text-green-500 {
  color: #4ade80 !important;
}

[data-theme="dark"] .text-red-500 {
  color: #f87171 !important;
}

[data-theme="dark"] .text-yellow-500 {
  color: #facc15 !important;
}

[data-theme="dark"] .text-purple-500 {
  color: #a78bfa !important;
}

[data-theme="dark"] .text-orange-500 {
  color: #fb923c !important;
}

/* ダークモード スクロールバー */
[data-theme="dark"]::-webkit-scrollbar {
  width: 8px;
}

[data-theme="dark"]::-webkit-scrollbar-track {
  background-color: var(--bg-secondary);
}

[data-theme="dark"]::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 4px;
}

[data-theme="dark"]::-webkit-scrollbar-thumb:hover {
  background-color: #6b7280;
}

/* ダークモード印刷スタイル */
@media print {
  [data-theme="dark"] * {
    background-color: white !important;
    color: black !important;
  }
}