/* CSS is how you can add style to your website, such as colors, fonts, and positioning of your
   HTML content. To learn how to do something, just try searching Google for questions like
   "how to change link color." */

/*
body {
  background-color: white;
  color: black;
  font-family: Verdana;
}
*/

:root {
  --primary: #2c3e50;
  --accent-calc: #e74c3c;
  --accent-edit: #3498db;
  --result-bg: #27ae60;
  --bg: #f0f3f5;
}

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: #333;
  margin: 0;
  padding-bottom: 120px;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 15px;
}

#configSection {
  background: white;
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  transition: 0.3s;
}

.is-viewing-result #configSection {
  opacity: 0.5;
  pointer-events: none;
  transform: scale(0.98);
}

.base-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.base-inputs label {
  display: block;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 5px;
  color: #555;
}

.base-inputs input {
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
  outline: none;
  transition: 0.2s;
}

.base-inputs input:focus {
  border-color: var(--accent-edit);
}

#recipeSection {
  background: white;
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.recipe-item {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 40px;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 最初のレシピ行にある削除ボタン (btn-del) を非表示にする */
#recipeList .recipe-item:first-child .btn-del {
    display: none;
}

.custom-select-container {
  position: relative;
}

.custom-select-trigger {
  background: #fff;
  border: 2px solid #ddd;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-options {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.custom-options.show {
  display: block;
}

.custom-option-item {
  padding: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-option-item:hover {
  background: #f1f3f5;
}

.custom-added {
  color: var(--accent-edit);
  font-weight: bold;
}

.delete-custom-tag {
  font-size: 0.75rem;
  background: #e74c3c;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.input-group {
  display: flex;
  border: 2px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.item-val {
  width: 60%;
  border: none;
  padding: 10px;
  font-size: 1rem;
  outline: none;
  text-align: right;
}

.item-unit {
  width: 40%;
  border: none;
  background: #eef1f4;
  padding: 10px 5px;
  font-size: 0.9rem;
  font-weight: bold;
  outline: none;
  cursor: pointer;
}

.btn-del {
  background: #f8d7da;
  color: #721c24;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ドロップダウン展開時にレシピ下部が隠れないよう隙間を作る */
#recipeList.is-dropdown-open {
  padding-bottom: 120px;
  transition: padding 0.2s;
}

.btn-main {
  width: 80%;
  max-width: 300px;
  padding: 15px;
  font-size: 1.3rem;
  font-weight: bold;
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  transition: 0.2s;
}

.btn-main.calc { background: var(--accent-calc); }
.btn-main.edit { background: var(--accent-edit); }

.btn-main:active {
  transform: scale(0.97);
}

.btn-sub {
  background: #eef1f4;
  color: var(--primary);
  border: 2px solid #ccc;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.85rem;
}

.result-card {
  background: var(--result-bg);
  border-radius: 12px;
  margin-bottom: 10px;
  color: white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* トグルスイッチのスタイル */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc; transition: .3s;
}
.slider:before {
  position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px;
  background-color: white; transition: .3s;
}
input:checked + .slider { background-color: var(--result-bg); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* ヘルプポップアップ */
.header-title {
  position: relative;
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
  padding: 0 10px;
  margin-bottom: 20px;
}

.help-trigger {
    position: absolute;
    right: 10px;
    bottom: 5px;
    font-size: 0.8rem;
    color: var(--accent-edit);
    cursor: help;
    text-decoration: underline;
    -webkit-tap-highlight-color: transparent; 
}

.help-popup {
    display: none;
    position: absolute;
    top: 150%;
    right: 0;
    width: 280px;
    background: #fff;
    color: #333;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    z-index: 10001;
    text-align: left;
    border: 2px solid var(--accent-edit);
}

@media (hover: hover) {
    .help-trigger:hover .help-popup {
        display: block !important;
    }
}

/* モーダル基本スタイル */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 20000;
  justify-content: center;
  align-items: center;
  padding: 15px;
  box-sizing: border-box;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  animation: modalUp 0.25s ease-out;
}

@keyframes modalUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.select-wrapper {
  position: relative;
}
.select-wrapper::after {
  content: "▼";
  font-size: 0.75rem;
  color: #777;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}