/* ========== 排出品目テーブル（PC表示） ========== */
.item-result-wrapper {
  width: 100%;
  overflow-x: auto;
}

#item_result {
  min-width: 700px;
  width: auto;
  border-collapse: collapse;
  background-color: white;
  border: 1px solid #e0e0e0;
  margin: 0 auto;
}

#item_result thead tr {
  background-color: #e8f5e9;
  border-bottom: 2px solid #66bb6a;
}

#item_result th {
  padding: 1em;
  font-size: 0.875em;
  font-weight: 600;
  color: #222;
  background-color: #ecf9d9;
  text-align: center;
  width: auto;
}
#item_result th.name_hd,
#item_result th.a_ticket_hd,
#item_result th.a_ticket_hd {
  text-align: right;
}
#item_result th.name_hd{
  width: 10em;
}
#item_result th.dummy_hd{
  display: none;
}

#item_result td {
  padding: 1em;
  font-size: 0.875em;
  color: #222;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

#item_result td.sp_cart_plus_btn {
  display: none;
}

#item_result td.right {
  text-align: right;
}

#item_result .itemresultcolor {
  background-color: #ffffff;
}
#item_result .itemresultcolor:hover {
  background-color: #fffef5;
}

/*選択中*/
#item_result .itemresultcolor.selected {
  background-color: #fff9e6;
}
/*受付不可*/
#item_result .itemresultcolor.unavailable {
  background-color: #ffe8e6;
}
#item_result .itemresultcolor.unavailable .edit-area {
  display: none;
}

/* data-label属性は非表示（PC） */
#item_result td::before {
  display: none;
}

/* 品目名とボタンを含むtd全体 */
#item_result td[data-label="品目名"] {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

/* 品目名と詳細リンクのラッパー */
.item-name-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1em;
}

/* 品目名エリア */
.item-name {
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}

/* 詳細リンクエリア */
.always-area {
  flex-shrink: 0;
}

/* アクションボタンエリア */
.item-actions {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

/* 各エリア */
.initial-area,
.edit-area {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}

.initial-area.pc_cart_plus_btn {
  display: block;
}

/* 確定ボタン */
.btn-confirm {
  padding: 0.6em 3em;
  background-color: #136740;
  color: white;
  border: none;
  border-radius: 0.3rem;
  font-size: 0.875em;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s;
}

.btn-confirm:hover {
  background-color: #e67e1a;
}

/* マイナス・プラスボタン */
.btn-minus,
.btn-plus,
button.btn-minus,
button.btn-plus {
  width: 2.2em;
  height: 2.2em;
  background-color: #f2f2f2;
  border: none;
  border-radius: 50%;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: initial;
  padding: 0;
  color: #222;
}

.btn-minus:hover,
.btn-plus:hover {
  background-color: #136740;
  color: white;
}

/* 数量表示 */
.quantity {
  font-weight: 600;
  font-size: 1.1em;
  min-width: 2em;
  text-align: center;
}

/* 詳細リンク */
.link-detail,
button.link-detail {
  color: #2196f3;
  font-size: 0.875em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  background-color: initial;
  border: none;
  padding: 0;
  min-width: initial;
}

.link-detail:hover {
  opacity: 0.8;
}

.link-detail svg {
  flex-shrink: 0;
}

#item_result .itemresultcolor.unavailable td span {
  color: #fb4e18;
  font-weight: 700;
}

#item_result .itemresultcolor.unavailable td .link-detail span {
  color: #2196f3;
  font-weight: 400;
}

/* ========== スマホ表示（768px以下） ========== */
@media (max-width: 768px) {
  /* テーブルをカードレイアウトに変更 */
  #item_result {
    border: none;
    width: 100%;
    min-width: auto;
  }

  /* ヘッダーを非表示 */
  #item_result thead {
    display: none;
  }

  /* tbodyをグリッドに */
  #item_result tbody {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
  }

  #item_result tr.item-result-header {
    display: none;
  }

  /* 各行をカードに */
  #item_result tr {
    display: flex;
    flex-direction: column;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }
  

  #item_result th.dummy_hd{
    display: none;
  }


  /* tdを縦並びに */
  #item_result td {
    display: block;
    padding: 0;
    border: none;
    text-align: left !important;
  }

  #item_result td.sp_cart_plus_btn {
    display: block;
  }
  .initial-area.pc_cart_plus_btn {
    display: none;
  }

  /* 品目名のtd */
  #item_result td[data-label="品目名"] {
    display: flex;
    flex-direction: column;
    gap: 0.8em;
    margin-bottom: 1em;
    order: 1;
  }

  /* 品目名と詳細のラッパー */
  .item-name-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5em;
    font-size: 1.25em;
  }

  /* その他のtd（単価、A券、B券） */
  #item_result td:not(:first-child) {
    order: 4;
    display: flex;
    justify-content: center;
    padding: 0.3em 0;
    font-size: 0.875em;
    order: 5;
  }
  #item_result td[data-label]::before {
    content: attr(data-label);
    margin-right: 5em; /* ← ここで 3文字分の空き */
    display: inline-block; /* margin-right を効かせるために必要 */
    font-weight: bold; /* 任意。見出し感を出したい場合 */
  }

  /* data-label属性を表示 */
  #item_result td:not(:first-child)::before {
    content: attr(data-label) ":";
    display: inline-block;
    color: #666;
    font-weight: 500;
  }
  #item_result td:last-child::before {
    content: "";
  }

  /* 単価を大きく表示 */
  #item_result td[data-label="単価"] {
    font-size: 1.5em;
    font-weight: 700;
    color: #136740;
    margin-bottom: 0.5em;
    order: 2;
  }
  #item_result .itemresultcolor.unavailable td[data-label="単価"] {
    color: #fb4e18;
  }

  #item_result td[data-label="単価"]::before {
    display: none;
  }

  /* 品目名 */
  .item-name {
    font-size: 0.875em;
    flex: 1;
    overflow: hidden; /* 溢れた部分を隠す */
    text-overflow: ellipsis; /* 溢れた部分を「...」にする */
    white-space: nowrap;
    width: 10em;
  }

  /* 詳細エリア（スマホ） */
  .always-area {
    flex-shrink: 0;
  }

  /* アクションエリア */
  .item-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    order: 6;
  }

  /* 確定ボタン（スマホ） */
  .btn-confirm {
    width: 100%;
  }

  /* 編集エリアを横並びに */
  .edit-area {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }
  .unavailable .edit-area {
    display: none;
  }
}

/* 極小スマホ（510px以下）は1カラムに */
@media (max-width: 510px) {
  #item_result tbody {
    grid-template-columns: 1fr;
  }
}
