/* ==========================================================
   案件一覧ページ - デザイン完全準拠版
   iPhone / iPad / PC 全レスポンシブ対応
   ========================================================== */

/* 共通設定 */
:root {
  --primary-blue: #2B7DE9;
  --bg-gray: #F5F6F8;
  --border-gray: #DADCE0;
  --text-primary: #212121;
  --text-secondary: #5F6368;
  --status-green: #4CAF50;
  --status-yellow: #FFC107;
  --status-gray: #78909C;
  --repair-icon-bg: #E3F2FD;
  --delivery-icon-bg: #ECEFF1;
}

/* 案件ページ全体 */
.projects-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-gray);
}

/* フィルタヘッダー（固定） */
.projects-filter-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  padding: 16px;
  border-bottom: 1px solid var(--border-gray);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 日付フィルタボタン行 */
.date-filter-buttons-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.date-filter-buttons-row::-webkit-scrollbar {
  display: none;
}

.date-filter-btn {
  flex: 1;
  min-width: 85px;
  height: 36px;
  background: #F1F3F4;
  border: 1px solid var(--border-gray);
  border-radius: 18px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-filter-btn:first-child {
  background: white;
}

.date-filter-btn.active {
  background: #E8EAED;
  border-color: #9E9E9E;
}

/* 検索バー */
.search-bar-container {
  position: relative;
  display: flex;
  align-items: center;
  background: #F1F3F4;
  border-radius: 22px;
  height: 44px;
  padding: 0 16px;
}

.search-icon {
  font-size: 16px;
  margin-right: 8px;
  color: #757575;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  padding: 0;
}

.search-input::placeholder {
  color: #9E9E9E;
}

.search-clear-btn {
  background: none;
  border: none;
  font-size: 14px;
  color: #9E9E9E;
  cursor: pointer;
  padding: 4px;
  margin-left: 8px;
}

/* カテゴリトグル */
.category-toggle-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-toggle-row::-webkit-scrollbar {
  display: none;
}

.category-toggle-btn {
  flex: 1;
  min-width: 160px;
  height: 40px;
  background: #D7B899;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.category-toggle-btn.active {
  background: var(--primary-blue);
  color: white;
}

.category-badge {
  display: inline-block;
  min-width: 18px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* ステータスチップ */
.status-chips-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.status-chips-container::-webkit-scrollbar {
  display: none;
}

.status-chip {
  flex-shrink: 0;
  height: 32px;
  padding: 0 16px;
  background: white;
  border: 1px solid var(--border-gray);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.status-chip.active {
  background: #F1F3F4;
  border-color: #9E9E9E;
}

/* カードリストコンテナ */
.projects-list-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

/* ===================================================================
   iPhone デザイン（max-width: 767px）
   カード横3分割レイアウト: 左アイコン | 中央テキスト | 右ボタン
   =================================================================== */
@media (max-width: 767px) {
  #projects-cards-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .project-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    border-radius: 12px;
    padding: 0;
    height: 120px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    gap: 0;
    overflow: hidden;
  }

  /* 左側：アイコンエリア（60px幅固定） */
  .project-card-icon-wrapper {
    width: 60px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .project-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }

  .project-card-icon.repair {
    background: var(--repair-icon-bg);
    color: var(--primary-blue);
  }

  .project-card-icon.delivery {
    background: var(--delivery-icon-bg);
    color: var(--status-gray);
  }

  /* 中央：テキストエリア（flex） */
  .project-card-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 8px;
    min-width: 0;
  }

  .project-card-customer {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .project-card-detail {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .project-card-date {
    font-size: 13px;
    color: var(--text-secondary);
  }

  /* 右側：ボタンエリア（80px幅固定） */
  .project-card-button-wrapper {
    width: 80px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding-right: 16px;
  }

  .project-card-status-btn {
    width: 72px;
    height: 32px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
  }

  .project-card-status-btn.status-received {
    background: var(--primary-blue);
  }

  .project-card-status-btn.status-in_progress {
    background: var(--status-gray);
  }

  .project-card-status-btn.status-completed {
    background: var(--status-green);
  }

  /* iPad/PC用要素は非表示 */
  .project-card-product,
  .project-card-symptom,
  .project-card-status-badge,
  .confirm-button-tablet-desktop {
    display: none !important;
  }
}

/* ===================================================================
   iPad デザイン（768px〜1024px）
   カード2カラムグリッド、縦レイアウト
   =================================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
  .projects-filter-header {
    padding: 20px;
  }

  .date-filter-btn {
    min-width: 120px;
    height: 40px;
  }

  .search-bar-container {
    max-width: 600px;
    height: 48px;
    margin: 0 auto;
  }

  .projects-list-container {
    padding: 20px;
  }

  #projects-cards-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .project-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    padding: 20px;
    min-height: 180px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    gap: 12px;
  }

  /* アイコン（左上） */
  .project-card-icon-wrapper {
    display: block;
  }

  .project-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }

  .project-card-icon.repair {
    background: var(--repair-icon-bg);
    color: var(--primary-blue);
  }

  .project-card-icon.delivery {
    background: var(--delivery-icon-bg);
    color: var(--status-gray);
  }

  /* テキスト */
  .project-card-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .project-card-customer {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
  }

  .project-card-product {
    font-size: 14px;
    color: var(--text-secondary);
    display: block;
  }

  .project-card-symptom {
    font-size: 14px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .project-card-date {
    font-size: 14px;
    color: var(--text-secondary);
  }

  /* 右上ステータスバッジ */
  .project-card-status-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 6px 14px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    display: block;
  }

  .project-card-status-badge.status-completed {
    background: var(--status-green);
  }

  .project-card-status-badge.status-scheduled {
    background: var(--status-yellow);
  }

  .project-card-status-badge.status-in_progress {
    background: var(--primary-blue);
  }

  .project-card-status-badge.status-received {
    background: #9E9E9E;
  }

  /* iPhone用要素は非表示 */
  .project-card-button-wrapper,
  .project-card-status-btn,
  .project-card-detail {
    display: none !important;
  }

  /* 確定ボタン（ヘッダー右） */
  .confirm-button-tablet-desktop {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 101;
    width: 120px;
    height: 44px;
    background: #FF9800;
    color: white;
    border: none;
    border-radius: 22px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
    transition: all 0.2s;
    display: block;
  }

  .confirm-button-tablet-desktop:hover {
    background: #F57C00;
  }
}

/* ===================================================================
   PC デザイン（1025px以上）
   TODO: 左サイドバー + テーブル表示（将来実装）
   現在はiPadと同様のカードグリッド
   =================================================================== */
@media (min-width: 1025px) {
  .projects-filter-header {
    padding: 24px;
  }

  .date-filter-btn {
    min-width: 180px;
    height: 40px;
  }

  .search-bar-container {
    max-width: 800px;
    height: 52px;
    margin: 0 auto;
  }

  .projects-list-container {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
  }

  #projects-cards-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .project-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    padding: 24px;
    min-height: 180px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    gap: 14px;
  }

  .project-card-icon-wrapper {
    display: block;
  }

  .project-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }

  .project-card-icon.repair {
    background: var(--repair-icon-bg);
    color: var(--primary-blue);
  }

  .project-card-icon.delivery {
    background: var(--delivery-icon-bg);
    color: var(--status-gray);
  }

  .project-card-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .project-card-customer {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
  }

  .project-card-product {
    font-size: 15px;
    color: var(--text-secondary);
    display: block;
  }

  .project-card-symptom {
    font-size: 15px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .project-card-date {
    font-size: 15px;
    color: var(--text-secondary);
  }

  .project-card-status-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    display: block;
  }

  .project-card-status-badge.status-completed {
    background: var(--status-green);
  }

  .project-card-status-badge.status-scheduled {
    background: var(--status-yellow);
  }

  .project-card-status-badge.status-in_progress {
    background: var(--primary-blue);
  }

  .project-card-status-badge.status-received {
    background: #9E9E9E;
  }

  .project-card-button-wrapper,
  .project-card-status-btn,
  .project-card-detail {
    display: none !important;
  }

  .confirm-button-tablet-desktop {
    position: fixed;
    top: 84px;
    right: 24px;
    z-index: 101;
    width: 140px;
    height: 48px;
    background: #FF9800;
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
    transition: all 0.2s;
    display: block;
  }

  .confirm-button-tablet-desktop:hover {
    background: #F57C00;
  }
}

/* ===================================================================
   共通：ローディング & 空状態
   =================================================================== */
.loading-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: #9E9E9E;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #E0E0E0;
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-state p,
.empty-state p {
  font-size: 14px;
  margin-top: 8px;
}
