﻿/* Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Base */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f6f7f9;
  color: #111827; /* neutral-900 */
  line-height: 1.6;
  min-height: 100vh;
  font-size: 14px; /* 全体のフォントサイズを小さく */
}

.dish-db-container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Header */
.header { text-align: center; margin-bottom: 28px; color: #111827; }
.header h1 { font-size: 2rem; margin-bottom: 8px; font-weight: 700; letter-spacing: .2px; }
.header h1 i { margin-right: 10px; color: #3b82f6; }
.subtitle { font-size: .95rem; color: #6b7280; font-weight: 400; }

/* Brand Section */
.brand-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.brand-section h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 16px;
  text-align: center;
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

        .brand-block {
          background: #f8fafc;
          border: 2px solid #e2e8f0;
          border-radius: 8px;
          padding: 8px;
          text-align: center;
          cursor: pointer;
          transition: all 0.2s ease;
          position: relative;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          min-height: 80px;
        }

        .brand-block:hover {
          background: #e2e8f0;
          border-color: #3b82f6;
          transform: translateY(-2px);
          box-shadow: 0 4px 8px rgba(0,0,0,.1);
        }

        .brand-block.active {
          background: #3b82f6;
          border-color: #2563eb;
          color: white;
        }

        .brand-logo {
          width: 40px;
          height: 40px;
          object-fit: contain;
          margin-bottom: 4px;
          filter: grayscale(0.3);
          transition: filter 0.2s ease;
        }

.brand-logo--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f5f5f5;
  color: #555;
  font-weight: 600;
  font-size: 1rem;
}


        .brand-block:hover .brand-logo {
          filter: grayscale(0);
        }

        .brand-block.active .brand-logo {
          filter: grayscale(0) brightness(1.2);
        }

        .brand-name {
          font-size: 0.7rem;
          font-weight: 600;
          color: #374151;
          margin-bottom: 2px;
          line-height: 1.2;
        }

        .brand-block.active .brand-name {
          color: white;
        }

        .brand-count {
          font-size: 0.6rem;
          color: #6b7280;
          font-weight: 500;
        }

        .brand-block.active .brand-count {
          color: rgba(255,255,255,0.8);
        }

/* Search */
.search-section {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 18px 18px 14px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.search-container { 
  position: relative; 
  display: flex;
  gap: 8px;
  align-items: center;
}
.brand-select {
  min-width: 180px;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: #374151;
  cursor: pointer;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.brand-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.search-input-container {
  position: relative;
  flex: 1;
}
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #6b7280; z-index: 1; }
#searchInput {
  width: 100%; padding: 12px 44px 12px 38px; border: 1px solid #e5e7eb; border-radius: 10px;
  font-size: 1rem; outline: none; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#searchInput:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.clear-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, border-color .15s ease;
}
.clear-btn:hover { background: #e5e7eb; }
.search-stats { display: flex; justify-content: space-between; align-items: center; color: #6b7280; font-size: .9rem; margin-top: 8px; }

/* Table - PC表示 */
.table-container {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow-x: auto; /* 横スクロールを許可 */
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
  background: #f9fafb; color: #374151; padding: 12px 14px; text-align: left; font-weight: 600;
  border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 1;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; overflow-wrap: anywhere; }

/* 価格カラムは折り返さず、右寄せにする */
.data-table th[data-field="price"],
.data-table td[data-field="price"] {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  text-align: right;
  font-variant-numeric: tabular-nums; /* 数値を揃えて見やすく */
}

/* 状態ランクカラムのスタイル */
.data-table th[data-field="condition_rank"],
.data-table td[data-field="condition_rank"] {
  text-align: center;
  font-weight: 600;
}

.data-table td[data-field="condition_rank"] {
  background: #f0f9ff;
  color: #0369a1;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

/* 画像カラムのスタイル */
.data-table th[data-field="image"],
.data-table td[data-field="image"] {
  text-align: center;
  width: 80px;
  padding: 8px;
}

.product-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.no-image {
  width: 60px;
  height: 60px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #6b7280;
  text-align: center;
  line-height: 1.2;
}

.card-product-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.sortable { cursor: pointer; user-select: none; }
.sortable .sort-icon { margin-left: 8px; color: #9ca3af; }
.data-row { transition: background-color .15s ease; }
.data-row:hover { background: #f9fafb; }

/* Card - スマホ表示 */
.card-container {
  display: none; /* デフォルトでは非表示 */
}
.data-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  transition: box-shadow .15s ease, transform .15s ease;
}
.data-card:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,.1);
  transform: translateY(-1px);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.card-title {
  font-size: 0.85rem !important; /* 強制的に小さく */
  font-weight: 600; /* 太字は維持 */
  color: #111827;
  margin: 0;
  line-height: 1.4;
}
.card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: #059669;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.card-details {
  display: grid;
  gap: 8px;
}
.card-detail {
  display: flex;
  align-items: center;
  font-size: 0.85rem; /* 商品名と同じサイズ */
}
.card-detail-label {
  font-weight: 500;
  color: #6b7280;
  min-width: 60px;
  margin-right: 8px;
}
.card-detail-value {
  color: #374151;
  flex: 1;
}
.card-brand {
  background: #f3f4f6;
  color: #374151;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-block;
}
.card-condition {
  background: #dbeafe;
  color: #1e40af;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-block;
}

/* Empty state */
.no-results { text-align: center; padding: 60px 20px; color: #6b7280; }
.no-results i { font-size: 3rem; color: #d1d5db; margin-bottom: 12px; }
.no-results h3 { font-size: 1.25rem; margin-bottom: 6px; color: #374151; }
.no-results p { font-size: .95rem; color: #6b7280; }

/* Footer */
.footer { text-align: center; margin-top: 28px; color: #6b7280; font-size: .85rem; }

/* Loading */
.loading { opacity: .6; pointer-events: none; position: relative; }
.loading::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 2px solid #3b82f6; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Highlight */
.highlight { background: #fef3c7; padding: 2px 4px; border-radius: 3px; font-weight: 600; }

/* Scrollbar */
.table-container::-webkit-scrollbar { height: 8px; }
.table-container::-webkit-scrollbar-track { background: #f3f4f6; border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Responsive */
@media (max-width: 768px) {
  .dish-db-container { padding: 16px; }
  .header h1 { font-size: 1.6rem; }
  
          /* ブランドグリッドの調整 */
          .brand-grid {
            grid-template-columns: repeat(4, 1fr);
            gap: 8px;
          }
          
          .brand-block {
            padding: 6px;
            min-height: 70px;
          }
          
          .brand-logo {
            width: 30px;
            height: 30px;
          }
          
          .brand-name {
            font-size: 0.6rem;
          }
          
          .brand-count {
            font-size: 0.5rem;
          }
          
          /* スマホでの検索コンテナ調整 */
          .search-container {
            flex-direction: column;
            gap: 8px;
          }
          
          .brand-select {
            min-width: auto;
            width: 100%;
          }
  
  /* スマホではテーブルを非表示、カードを表示 */
  .table-container {
    display: none;
  }
  .card-container {
    display: block;
  }
  
  .search-section { padding: 14px; }
  
  /* スマホでの入力問題を解決 */
  #searchInput {
    font-size: 16px; /* iOSでズームを防ぐ */
  }
  
  /* カードのスマホ用スタイル */
  .data-card {
    padding: 14px;
    margin-bottom: 10px;
  }
  .card-title {
    font-size: 0.5rem !important; /* スマホではさらに小さく */
  }
  .card-price {
    font-size: 1rem;
  }
  .card-detail {
    font-size: 0.8rem; /* スマホでは小さく */
  }
  .card-detail-label {
    min-width: 50px;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .dish-db-container {
    padding: 12px;
  }
  
  .search-section {
    padding: 12px;
  }
  
          /* ブランドグリッドの調整 */
          .brand-grid {
            grid-template-columns: repeat(3, 1fr);
            gap: 6px;
          }
          
          .brand-block {
            padding: 4px;
            min-height: 60px;
          }
          
          .brand-logo {
            width: 25px;
            height: 25px;
          }
          
          .brand-name {
            font-size: 0.5rem;
          }
          
          .brand-count {
            font-size: 0.45rem;
          }
  
  /* より小さなスマホ用のカードスタイル */
  .data-card {
    padding: 12px;
    margin-bottom: 8px;
  }
  .card-header {
    margin-bottom: 10px;
  }
  .card-title {
    font-size: 0.75rem !important; /* 小さなスマホではさらに小さく */
  }
  .card-price {
    font-size: 0.9rem;
  }
  .card-details {
    gap: 6px;
  }
  .card-detail {
    font-size: 0.75rem; /* 小さなスマホではさらに小さく */
  }
  .card-detail-label {
    min-width: 45px;
    font-size: 0.7rem;
  }
}

