/**
 * style.css — OpsLoadout カスタムスタイル
 *
 * このファイルは、Tailwind CSSで提供されない
 * カスタムコンポーネントとユーティリティを定義します。
 *
 * アーキテクチャ:
 * - Tailwind CSS (CDN) をベースとして使用
 * - カスタムコンポーネントで不足部分を補完
 * - レスポンシブデザイン（モバイルファースト）
 * - アクセシビリティ対応（focus-visible、ARIA）
 *
 * セクション構成:
 * 1. Global Styles (Scrollbar, Transitions, Focus, Body)
 * 2. Layout Components (Header, Main, Footer)
 * 3. Controls Section (Filters, Buttons, Inputs)
 * 4. Form Components (Input, Select, Checkbox)
 * 5. Button Components (Primary, Secondary, Danger)
 * 6. Badge Components (Warning, Danger)
 * 7. Modal Components (Backdrop, Content, Header)
 * 8. Item Table (Responsive Grid Layout)
 * 9. Saved Checklists Section
 * 10. Print Styles
 *
 * デザイン原則:
 * - モバイルファースト: 小さい画面から設計
 * - プログレッシブエンハンスメント: 基本機能から拡張
 * - アクセシビリティ: キーボード・スクリーンリーダー対応
 * - パフォーマンス: トランジション最小化、GPU加速
 */

/* ============================================================
   1. Global Styles (グローバルスタイル)
   ============================================================ */

/* Scrollbar styling - カスタムスクロールバー（WebKit） */
.scrollbar-thin::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

/* Smooth transitions */
* {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus visible for better accessibility */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Remove default focus for mouse users */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Better text rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background-color: #f9fafb;
  color: #1f2937;
  min-height: 100vh;
}

/* ============================================================
   2. Layout Components (レイアウトコンポーネント)
   ============================================================
   アプリケーション全体のレイアウト構造を定義
   - Header: アプリケーションヘッダー
   - Main: メインコンテンツエリア
   - Footer: フッター
   - Checklist Section: チェックリスト表示エリア
*/

.app-header {
  background-color: white;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

@media (min-width: 768px) {
  .app-header {
    padding: 1rem 1.5rem;
  }
}

.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #1f2937;
  letter-spacing: -0.025em;
}

@media (min-width: 768px) {
  .app-title {
    font-size: 1.875rem;
  }
}

.app-subtitle {
  font-size: 0.75rem;
  color: #6b7280;
  margin: 0;
  line-height: 1.4;
}

@media (min-width: 768px) {
  .app-subtitle {
    font-size: 0.8125rem;
  }
}

/* ============================================================
   3. Controls Section (コントロールセクション)
   ============================================================
   フィルタリング、検索、カテゴリー選択などのコントロール要素
   - Category Buttons: カテゴリーフィルターボタン
   - Search Input: 検索入力欄
   - Checkbox Filters: チェックボックスフィルター
*/

.controls-section {
  background-color: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.75rem 1rem;
}

.controls-container {
  max-width: 80rem;
  margin: 0 auto;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.controls-row:last-child {
  margin-bottom: 0;
}

.control-group {
  flex: 1;
  min-width: 200px;
}

.control-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.category-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.control-group-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: #4b5563;
  cursor: pointer;
}

/* Main Content */
.main-content {
  max-width: 80rem;
  margin: 0 auto;
  padding: 1rem;
}

.checklist-section {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  padding: 1rem;
  margin-bottom: 1rem;
}

.checklist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checklist-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1f2937;
}

.item-count {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

/* Item Detail Accordion */
.item-detail-accordion {
  margin-top: 1rem;
  padding: 1rem;
  background-color: #f9fafb;
  border-radius: 0.375rem;
  border: 1px solid #e5e7eb;
}

.item-detail-accordion.hidden {
  display: none;
}

/* Footer Bar */
.footer-bar {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-bar-left {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.footer-info {
  font-size: 0.875rem;
  color: #6b7280;
}

.footer-bar-right {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

/* ============================================================
   4. Button Components (ボタンコンポーネント)
   ============================================================
   汎用ボタンスタイル
   - btn-primary: 主要アクション（保存、確定など）
   - btn-secondary: 副次アクション（キャンセル、編集など）
   - btn-danger: 危険な操作（削除など）
   - btn-sm: 小サイズボタン
*/

.btn {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn-primary {
  background-color: #2563eb;
  color: white;
}

.btn-primary:hover {
  background-color: #1d4ed8;
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid #d1d5db;
  color: #374151;
}

.btn-secondary:hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
}

.btn-danger {
  background-color: transparent;
  color: #dc2626;
  border: none;
  padding: 0.5rem;
}

.btn-danger:hover {
  background-color: #fef2f2;
  color: #b91c1c;
}

.btn-full {
  width: 100%;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.btn-flex {
  flex: 1;
}

@media (min-width: 640px) {
  .btn-flex {
    flex: initial;
  }
}

/* ============================================================
   5. Form Components (フォームコンポーネント)
   ============================================================
   入力フォーム要素
   - form-input: テキスト入力フィールド
   - form-select: セレクトボックス
   - form-checkbox: チェックボックス
   - Focus States: フォーカス時のスタイル（アクセシビリティ）
*/

.form-input {
  width: 100%;
  border: 1px solid #d1d5db;
  padding: 0.5rem;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: inherit;
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  ring: 2px;
  ring-color: #3b82f6;
  border-color: transparent;
  box-shadow: 0 0 0 2px #3b82f6;
}

.form-select {
  width: 100%;
  border: 1px solid #d1d5db;
  padding: 0.5rem;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: inherit;
  background-color: white;
  transition: all 0.2s;
}

.form-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6;
  border-color: transparent;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.form-checkbox {
  cursor: pointer;
  transition: all 0.2s;
}

.form-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6;
}

/* ============================================================
   6. Badge Components (バッジコンポーネント)
   ============================================================
   アイテムの属性表示用バッジ
   - badge-warning: 軍民両用フラグ（黄色）
   - badge-danger: 危険物フラグ（赤色）
*/

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.0625rem 0.375rem;
  font-size: 0.625rem;
  border-radius: 9999px;
  font-weight: 500;
  line-height: 1.2;
}

.badge-warning {
  background-color: #fef3c7;
  color: #78350f;
}

.badge-danger {
  background-color: #fecaca;
  color: #7f1d1d;
}

.badge svg {
  width: 0.625rem;
  height: 0.625rem;
}

/* ============================================================
   7. Modal Components (モーダルコンポーネント)
   ============================================================
   モーダルダイアログシステム
   - modal-backdrop: モーダル背景オーバーレイ（fixed inset-0）
   - modal-content: モーダルコンテンツ本体
   - modal-header: モーダルヘッダー
   - active クラスで表示切り替え（display: flex）
*/

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 1rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-content {
  background-color: white;
  width: 100%;
  max-width: 42rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

@media (min-width: 768px) {
  .modal-content {
    padding: 1.5rem;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
  padding: 0.25rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  transition: background-color 0.2s;
}

.btn-close:hover {
  background-color: #f3f4f6;
  color: #1f2937;
}

/* Saved List */
.saved-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.saved-list li {
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.15s;
}

.saved-list li:hover {
  background-color: #f9fafb;
}

.saved-list-info {
  flex: 1;
  min-width: 0;
}

.saved-list-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: #1f2937;
  margin-bottom: 0.125rem;
}

.saved-list-date {
  font-size: 0.75rem;
  color: #6b7280;
}

.saved-list-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ============================================================
   8. Item Table (アイテムテーブル)
   ============================================================
   レスポンシブグリッドレイアウト
   - デスクトップ: 7カラムグリッド（checkbox, name, category, weight, qty, badge, actions）
   - モバイル: フレックスボックスで縦積み
   - トランジション: hover時の背景色変更
   - Performance: Event Delegation（親要素でイベント処理）
*/

.item-table {
  width: 100%;
  font-size: 0.8125rem;
}

.item-table-header {
  display: none;
  grid-template-columns: 2rem 1fr 8rem 4rem 4rem 7rem 6rem;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

@media (min-width: 768px) {
  .item-table-header {
    display: grid;
  }
}

.item-table-row {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.15s;
  gap: 0.375rem;
}

@media (min-width: 768px) {
  .item-table-row {
    display: grid;
    grid-template-columns: 2rem 1fr 8rem 4rem 4rem 7rem 6rem;
    gap: 0.5rem;
    align-items: center;
    padding: 0.375rem 0.75rem;
  }
}

.item-table-row:hover {
  background-color: #f9fafb;
}

.item-table-row .col-check {
  display: flex;
  align-items: center;
}

.item-table-row .col-name {
  font-weight: 500;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-table-row .col-category {
  color: #6b7280;
  font-size: 0.75rem;
}

.item-table-row .col-weight,
.item-table-row .col-qty {
  font-size: 0.75rem;
  color: #4b5563;
}

.item-table-row .col-badge {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.item-table-row .col-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

/* Mobile layout adjustments */
@media (max-width: 767px) {
  .item-table-row {
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
  }

  .item-table-row .col-check {
    position: absolute;
    margin-top: 0.25rem;
  }

  .item-table-row .col-name {
    margin-left: 2rem;
  }

  .item-table-row .col-category,
  .item-table-row .col-weight,
  .item-table-row .col-qty {
    display: inline-block;
    margin-right: 0.75rem;
  }

  .item-table-row .col-actions {
    margin-top: 0.25rem;
  }
}

/* Action buttons */
.action-btn-icon {
  padding: 0.25rem;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-btn-icon:hover {
  background-color: #f3f4f6;
  color: #1f2937;
}

.action-btn-icon svg {
  width: 1rem;
  height: 1rem;
}

.action-btn-icon.danger:hover {
  background-color: #fef2f2;
  color: #dc2626;
}

/* ============================================================
   9. Filter & Empty State (フィルターと空状態)
   ============================================================ */

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.filter-item:hover {
  background-color: #f9fafb;
}

.filter-item label {
  cursor: pointer;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}

.empty-state svg {
  margin: 0 auto 0.5rem;
  height: 3rem;
  width: 3rem;
  color: #d1d5db;
}

.empty-state p {
  font-size: 0.875rem;
  color: #6b7280;
}

/* Section Headers */
.section-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .section-header {
    flex-direction: row;
    align-items: center;
  }
}

.section-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

@media (min-width: 640px) {
  .section-controls {
    width: auto;
  }
}

/* Category Filter Buttons */
.category-filter-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid #d1d5db;
  background-color: white;
  color: #6b7280;
  font-size: 0.6875rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  line-height: 1.2;
}

.category-filter-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  background-color: #eff6ff;
}

.category-filter-btn.active {
  background-color: #2563eb;
  color: white;
  border-color: #2563eb;
}

.category-filter-btn.active:hover {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
}

/* Footer */
.app-footer {
  margin-top: 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
}

.app-footer-content {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 1rem;
  text-align: center;
}

.app-footer-text {
  font-size: 0.875rem;
  color: #4b5563;
}

.app-footer-link {
  color: #2563eb;
  transition: color 0.2s;
}

.app-footer-link:hover {
  color: #1e40af;
  text-decoration: underline;
}

/* ============================================================
   10. Saved Checklists Section (保存済みチェックリストセクション)
   ============================================================
   ローカルストレージから読み込んだチェックリストの一覧表示
   - inline版: メインページ下部に表示
   - modal版: モーダルダイアログ内に表示
   - active状態: 現在読み込み中のチェックリストをハイライト
*/

.saved-checklists-section {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  padding: 1rem;
  margin-top: 1rem;
}

.saved-checklists-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.saved-list-inline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.saved-list-inline li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  transition: all 0.15s;
  gap: 0.75rem;
}

.saved-list-inline li:last-child {
  margin-bottom: 0;
}

.saved-list-inline li:hover {
  background-color: #f9fafb;
  border-color: #d1d5db;
}

.saved-list-inline li.active {
  background-color: #eff6ff;
  border-color: #3b82f6;
}

.saved-list-inline-info {
  flex: 1;
  min-width: 0;
}

.saved-list-inline-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-list-inline-date {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.125rem;
}

.saved-list-inline-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.saved-list-inline-actions button {
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.15s;
}

.saved-list-inline-actions .load-btn {
  color: #2563eb;
}

.saved-list-inline-actions .load-btn:hover {
  background-color: #eff6ff;
  color: #1d4ed8;
}

.saved-list-inline-actions .delete-btn {
  color: #dc2626;
}

.saved-list-inline-actions .delete-btn:hover {
  background-color: #fef2f2;
  color: #b91c1c;
}

.empty-state-inline {
  text-align: center;
  padding: 1.5rem 1rem;
}

.empty-state-inline.hidden {
  display: none;
}

/* ============================================================
   11. Print Styles (印刷スタイル)
   ============================================================
   印刷時の最適化
   - ナビゲーション、ボタンを非表示
   - レイアウトを1カラムに変更
*/

@media print {
  header, nav, aside, footer {
    display: none !important;
  }

  main {
    grid-template-columns: 1fr !important;
  }

  button {
    display: none !important;
  }
}
