/* =====================================================
   スマホ料金比較ツール  style.css
   ----------------------------------------------------
   - 白ベース・清潔感のあるデザイン
   - スマホ優先のレスポンシブ
   - 表は横スクロール可、見出しは sticky に近い見た目
   ===================================================== */

/* ---------- リセット・基本 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  color: #1f2933;
  background: #f5f7fa;
  line-height: 1.6;
  font-size: 15px;
}

/* ---------- ヘッダー ---------- */
.page-header {
  background: linear-gradient(135deg, #ffffff 0%, #eef3f9 100%);
  border-bottom: 1px solid #e4e8ef;
  padding: 24px 20px 20px;
  text-align: center;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: #0b5394;
}

.page-header .subtitle {
  margin: 0;
  color: #52606d;
  font-size: 13px;
}

/* ---------- レイアウト ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ---------- 条件入力カード ---------- */
.control-card {
  background: #ffffff;
  border: 1px solid #e4e8ef;
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(16, 42, 67, 0.04);
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px dashed #e4e8ef;
}
.control-row:last-child {
  border-bottom: none;
}

.controls-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 4px 0;
}
.controls-inline .control-row {
  flex: 0 1 auto;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: none;
}

.control-label {
  font-weight: 600;
  font-size: 14px;
  color: #334155;
}

.control-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: #64748b;
}

.control-hint--sort {
  margin-top: 4px;
  padding: 8px 10px;
  background: #eef3f9;
  border-left: 3px solid #3a86ff;
  border-radius: 4px;
  color: #334155;
}

/* ---------- テキスト入力 / セレクト ---------- */
.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd2d9;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: #1f2933;
  transition: border-color .15s, box-shadow .15s;
}
.text-input:focus {
  outline: none;
  border-color: #3a86ff;
  box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.15);
}

/* ---------- ギガ数入力（数値） ---------- */
.gig-number-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#gigNumber {
  width: 80px;
  padding: 6px 8px;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  color: #0b5394;
  background: #fff;
}
#gigNumber:focus {
  outline: none;
  border-color: #3a86ff;
  box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.15);
}

.gig-unit {
  font-weight: 700;
  font-size: 14px;
  color: #334155;
}

/* ---------- チェックボックス ---------- */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #e4e8ef;
  border-radius: 999px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
  color: #334155;
  user-select: none;
  transition: background .15s, border-color .15s;
}
.checkbox:hover {
  background: #eef3f9;
}
.checkbox input {
  margin: 0;
  accent-color: #3a86ff;
}
.checkbox input:checked + span {
  color: #0b5394;
  font-weight: 600;
}

/* ---------- サマリーバー ---------- */
.summary-bar {
  margin: 16px 0 12px;
  padding: 12px 16px;
  background: #0b5394;
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}
.summary-bar strong {
  font-size: 15px;
  font-weight: 700;
}
.summary-bar .summary-count {
  margin-left: auto;
  background: #fff;
  color: #0b5394;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 700;
}
.summary-bar .summary-chip {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ---------- 結果テーブル ---------- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e4e8ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(16, 42, 67, 0.04);
  /* 表の見出しを固定感のある見た目にするため、コンテナに高さ制限を設けて sticky を活かす */
  max-height: 75vh;
}

.plans-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1080px; /* 狭い画面では横スクロール */
}

.plans-table thead th {
  position: sticky;
  top: 0;
  background: #eef3f9;
  color: #0b5394;
  font-weight: 700;
  text-align: left;
  padding: 12px 10px;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
  z-index: 2;
}

/* ソート可能な列ヘッダ */
.plans-table thead th[data-sort-key] {
  cursor: pointer;
  user-select: none;
  padding-right: 22px;
  position: sticky;
  top: 0;
  transition: background .15s;
}
.plans-table thead th[data-sort-key]:hover {
  background: #dbe4f0;
}
.plans-table thead th[data-sort-key]::after {
  content: "⇅";
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.35;
  color: #0b5394;
}
.plans-table thead th.is-sort-asc::after {
  content: "▲";
  opacity: 1;
}
.plans-table thead th.is-sort-desc::after {
  content: "▼";
  opacity: 1;
}
.plans-table thead th.is-sort-asc,
.plans-table thead th.is-sort-desc {
  background: #dbe4f0;
  color: #0b3b6b;
}

.plans-table tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid #e4e8ef;
  vertical-align: top;
}

.plans-table tbody tr:nth-child(even) {
  background: #fafbfc;
}
.plans-table tbody tr:hover {
  background: #eef3f9;
}

/* 料金を目立たせる */
.plans-table .col-price,
.plans-table td.price {
  white-space: nowrap;
}
.plans-table td.price {
  font-size: 16px;
  font-weight: 700;
  color: #e63946;
}
.plans-table td.price .price-unit {
  font-size: 11px;
  color: #64748b;
  margin-left: 2px;
  font-weight: 500;
}

/* 備考列はやや広めに */
.plans-table .col-notes,
.plans-table td.notes {
  min-width: 180px;
  color: #52606d;
}

/* 通話料列：複数行の条件を読みやすく */
.plans-table .col-call,
.plans-table td.call-charge {
  min-width: 200px;
  font-size: 12px;
  line-height: 1.5;
  color: #334155;
}

/* ブランド列：バッジが改行されないよう幅を確保 */
.plans-table .col-brand,
.plans-table td.col-brand {
  min-width: 130px;
}
.plans-table td.col-brand .parent-carrier {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge--unlimited {
  background: #fde68a;
  color: #92400e;
  border: 1px solid #fbbf24;
}
.badge--major {
  background: #dbeafe;
  color: #1e40af;
}
.badge--sub {
  background: #dcfce7;
  color: #166534;
}
.badge--mvno {
  background: #ede9fe;
  color: #5b21b6;
}

/* ---------- 0件メッセージ ---------- */
.empty-message {
  margin: 24px 0;
  padding: 24px;
  text-align: center;
  color: #64748b;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
}

/* ---------- 通信速度の目安セクション ---------- */
.speed-reference {
  margin-top: 20px;
}

.speed-details {
  background: #fff;
  border: 1px solid #e4e8ef;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(16, 42, 67, 0.04);
  overflow: hidden;
}

.speed-details > summary {
  cursor: pointer;
  padding: 14px 18px;
  background: #eef3f9;
  color: #0b5394;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  user-select: none;
}
.speed-details > summary::-webkit-details-marker { display: none; }
.speed-details > summary::before {
  content: "▶";
  font-size: 11px;
  margin-right: 8px;
  transition: transform .2s;
  color: #0b5394;
}
.speed-details[open] > summary::before {
  transform: rotate(90deg);
}
.speed-summary-title {
  font-size: 15px;
  flex: 1;
}
.speed-summary-hint {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
}

.speed-note {
  margin: 14px 18px 0;
  padding: 10px 12px;
  background: #fff8e1;
  border-left: 3px solid #fbbf24;
  border-radius: 4px;
  font-size: 12px;
  color: #52606d;
}

.speed-section-title {
  margin: 18px 18px 8px;
  font-size: 14px;
  color: #0b5394;
  border-left: 4px solid #3a86ff;
  padding-left: 8px;
}

.speed-table-wrap {
  margin: 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.speed-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 640px;
}

.speed-table thead th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
}

.speed-table tbody td {
  padding: 10px;
  border-bottom: 1px solid #e4e8ef;
  vertical-align: top;
  line-height: 1.5;
}

.speed-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.speed-table small {
  color: #64748b;
  font-weight: 400;
}

.speed-table--usage {
  min-width: 360px;
}

.speed-tips {
  padding-bottom: 18px;
}

.speed-tips-list {
  margin: 0 18px;
  padding-left: 20px;
  font-size: 13px;
  color: #334155;
}
.speed-tips-list li {
  margin-bottom: 6px;
}

@media (min-width: 640px) {
  .speed-table { font-size: 13px; }
  .speed-summary-title { font-size: 16px; }
}

/* ---------- フッター ---------- */
.page-footer {
  text-align: center;
  padding: 16px;
  color: #64748b;
}

/* =====================================================
   レスポンシブ（スマホ以外で見やすく広げる）
   ===================================================== */
@media (min-width: 640px) {
  body {
    font-size: 16px;
  }
  .page-header h1 {
    font-size: 26px;
  }
  .control-row {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  .control-label {
    flex: 0 0 auto;
  }
  .controls-inline .control-label {
    flex: 0 0 auto;
  }
  .plans-table {
    font-size: 14px;
  }
}

@media (min-width: 960px) {
  .container {
    padding: 28px 24px 64px;
  }
  .plans-table thead th {
    padding: 14px 12px;
  }
  .plans-table tbody td {
    padding: 14px 12px;
  }
}
