/* style.css — KFC saver (Improved UI/UX) */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&family=Roboto:wght@700&display=swap');

:root {
  --primary-color: #e4002b;
  --primary-dark: #c80025;
  --bg-color: #f7f7f7;
  --surface-color: #ffffff;
  --text-color: #333333;
  --text-muted-color: #666666;
  --border-color: #eeeeee;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --font-family: 'Noto Sans JP', sans-serif;
  --font-family-accent: 'Roboto', sans-serif;
}

/* === Base & Typography === */
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: var(--font-family-accent);
  color: var(--primary-color);
  margin: 0 0 1rem 0;
}

h2 { font-size: 1.5rem; }

/* === Layout === */
.site-header {
  background: var(--surface-color);
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.logo-img {
  max-width: 180px;
  height: auto;
}

main {
  width: 90%;
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 10px;
  display: grid;
  gap: 2rem;
}

/* === Card Style === */
.card {
  background: var(--surface-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: box-shadow 0.3s ease;
}
.card:hover {
  box-shadow: var(--shadow-hover);
}

/* === Input Form === */
.input-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.form-main-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.8rem;
  align-items: center;
}
.input-qty {
  width: 70px;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.65rem;
  font-size: 1rem;
  box-sizing: border-box; /* ← この1行を追加 */
}
.options-group {
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem 0.75rem;
  border-radius: var(--radius);
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.options-group legend {
  padding: 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted-color);
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary-color);
}

/* === Buttons === */
.button-primary, .button-secondary {
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.button-primary {
  background: var(--primary-color);
  color: white;
}
.button-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.button-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.button-large {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

/* === Tom Select Customization === */
.ts-wrapper .ts-control {
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  padding: 0.65rem 1rem;
}
.ts-wrapper.focus .ts-control {
  box-shadow: 0 0 0 3px rgba(228, 0, 43, 0.2);
  border-color: var(--primary-color);
}

/* ▼▼▼ 以下を追記 ▼▼▼ */
.ts-dropdown {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20; /* 他の要素より手前に表示 */
}
/* ▲▲▲ ここまで ▲▲▲ */

/* === Selected Items List === */
.selected-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.8rem;
}
.selected-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: var(--surface-color);
  border-radius: var(--radius);
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
  animation: fadeInUp 0.5s ease both;
}
.selected-list li.fade-out {
    animation: fadeOut 0.4s ease forwards;
}
.list-item-name { font-weight: 700; }
.list-item-qty {
    background-color: var(--bg-color);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 700;
    color: var(--primary-color);
    margin-left: 0.5rem;
}
.delete-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px;
  color: #aaa;
  transition: color 0.2s;
}
.delete-btn:hover { color: var(--primary-color); }

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted-color);
  background: transparent !important;
  box-shadow: none !important;
  border: 2px dashed var(--border-color);
}

/* === Result Area === */
.result-card {
    padding: 2rem;
    text-align: center;
    animation: fadeInUp 0.5s ease;
}
.result-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
.result-card .total-price-label {
    font-size: 1rem;
    color: var(--text-muted-color);
}
.result-card .bundle-list {
    list-style: none;
    padding: 0;
    margin-top: 1.5rem;
    text-align: left;
    display: grid;
    gap: 0.75rem;
}
.result-card .bundle-list li {
    background: var(--bg-color);
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
}
.bundle-name { font-weight: 700; }
.bundle-subtotal { color: var(--primary-color); font-weight: 700; }

/* === Animations === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); height: 0; padding: 0; margin: 0; border: none; }
}

/* === Bag & Spinner === */
.bag-area {
  position: fixed; right: 2rem; bottom: 2rem;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary-color); color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-hover); z-index: 50;
  cursor: pointer; transition: all 0.3s ease;
}
.bag-area:hover { transform: scale(1.1); }

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 200; animation: fadeIn 0.3s ease;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--surface-color);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  width: 90%; max-width: 480px; padding: 2rem;
  position: relative; max-height: 85vh; overflow-y: auto;
  animation: slideInUp 0.4s ease;
}
.modal-close-btn {
  position: absolute; top: 1rem; right: 1rem;
  background: transparent; border: none; font-size: 1.5rem;
  cursor: pointer; color: var(--text-muted-color); transition: color .2s;
}
.modal-close-btn:hover { color: var(--text-color); }
.modal-section h2 { margin-top: 0; margin-bottom: 1.5rem; }
#modalItemsList, #modalResultContent ul {
  list-style: none; padding: 0; margin-bottom: 1.5rem;
  display: grid; gap: 0.5rem;
}
#modalItemsList li, #modalResultContent li {
  padding: 0.5rem; border-bottom: 1px solid var(--border-color);
}
.button-secondary {
  background: var(--bg-color); color: var(--text-color); border: 1px solid var(--border-color);
}
.button-secondary:hover { background: #e9e9e9; border-color: #ddd; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* === Toast Notifications === */
.toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 9999;
  display: grid; gap: 0.5rem;
}
.toast {
  background-color: var(--text-color); color: white;
  padding: 0.8rem 1.2rem; border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  animation: toastInRight 0.5s ease;
  font-size: 0.95rem;
}
.toast.success { background-color: #28a745; }
.toast.error { background-color: var(--primary-dark); }
@keyframes toastInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === Responsive Tweaks === */
@media (max-width: 600px) {
  main { width: 100%; margin: 1rem auto; padding: 0; }
  .card { border-radius: 0; box-shadow: none; border-bottom: 1px solid var(--border-color); }
  .selected-items-section {
    padding: 0 1rem; /* 左右に1rem(約16px)の余白を追加 */
  }
  .card:hover { box-shadow: none; }
  .form-main-row { grid-template-columns: 1fr; }
  .input-qty { width: 100%; }
  .action-area { padding: 0 1rem; }
  .bag-area { right: 1rem; bottom: 1rem; }
}

/* === Bag & Spinner === */
.spinner {
  display: none; /* ← 普段は非表示 */
  position: fixed;
  inset: 0;
  backdrop-filter: blur(4px); /* ← 背景を少しぼかす */
  background: rgba(255,255,255,.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

/* スピナーの円のスタイルとアニメーション */
.spinner::after {
  content: '';
  width: 64px;
  height: 64px;
  border: 8px solid #e5e7eb;
  border-top-color: var(--primary-color); /* ← メインカラー */
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === Dynamic Text Logo === */
@keyframes slide-in-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.text-logo {
  font-size: clamp(2.2rem, 8vw, 4rem); /* 新フォントに合わせて少し調整 */
  display: flex;
  justify-content: center;
  align-items: baseline; /* ベースラインを揃える */
  cursor: default;
}

.text-logo .char {
  display: inline-block;
  font-family: 'Oswald', sans-serif; /* ★「KFC」のフォントをOswaldに */
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1; /* 行の高さを調整 */
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  animation: slide-in-up 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  animation-delay: calc(var(--i) * 0.06s);
}

.text-logo .char.space {
  width: 0.4em; /* 空白の幅を調整 */
}

.text-logo .char.saver {
  font-family: 'Poppins', sans-serif; /* ★「Saver」のフォントをPoppinsに */
  color: #333;
  font-weight: 600; /* 少し太めのウェイトを指定 */
  transform: translateY(0.05em); /* ★ Oswaldとの見た目の位置を微調整 */
}

/* ホバー時のインタラクション */
.text-logo:hover .char {
  transform: translateY(-8px) scale(1.05); /* 少し調整 */
}

/* スマートフォン用の調整 */
@media (max-width: 600px) {
  .text-logo:hover .char {
    transform: none; /* スマホではホバーエフェクトを無効化 */
  }
}