/* 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; /* 全体のフォントサイズを小さく */
}

.company-search-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; }

/* 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; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #6b7280; }
#companySearchInput {
  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;
}
#companySearchInput: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; /* 数値を揃えて見やすく */
}
.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-category {
  background: #f3f4f6;
  color: #374151;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-block;
}
.card-buyer {
  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) {
  .company-search-container { padding: 16px; }
  .header h1 { font-size: 1.6rem; }
  
  /* スマホではテーブルを非表示、カードを表示 */
  .table-container {
    display: none;
  }
  .card-container {
    display: block;
  }
  
  .search-section { padding: 14px; }
  
  /* スマホでの入力問題を解決 */
  #companySearchInput {
    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) {
  .company-search-container {
    padding: 12px;
  }
  
  .search-section {
    padding: 12px;
  }
  
  /* より小さなスマホ用のカードスタイル */
  .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;
  }
}