/* =====================================================
   共通リセット・CSS変数
===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* =====================================================
   警告ダイアログ（AI生成前）
===================================================== */
.warn-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.warn-dialog {
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px 22px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.35);
  text-align: center;
}
.warn-header {
  font-size: 20px;
  font-weight: 900;
  color: #B13546;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}
.warn-time {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 10px;
  line-height: 1.6;
}
.warn-caution {
  font-size: 13px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.8;
  margin-bottom: 22px;
}
.warn-highlight {
  color: #C0392B;
  font-size: 26px;
}
.warn-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.warn-btn-cancel {
  flex: 1;
  padding: 11px;
  border: 2px solid #ccc;
  border-radius: 8px;
  background: #fff;
  color: #555;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.warn-btn-ok {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: #B13546;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.warn-btn-cancel:hover { background: #f5f5f5; }
.warn-btn-ok:hover     { opacity: .85; }

:root {
  --bg:          #F08080;
  --header-red:  #B13546;
  --kcal-red:    #C06060;
  --border:      #F5A0A0;
  --btn-yellow:  #F8B400;
  --btn-blue:    #1E90FF;
  --btn-gray:    #A05050;
  --btn-green:   #3CB371;
  --text-dark:   #333333;
  --text-gray:   #666666;
  --white:       #FFFFFF;
}

body {
  background: var(--bg);
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  color: var(--text-dark);
  min-height: 100vh;
}

/* =====================================================
   共通ボタン
===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }

.btn-yellow { background: var(--btn-yellow); color: #1A1A1A; }
.btn-gray   { background: var(--btn-gray);   color: var(--white); }
.btn-blue   { background: var(--btn-blue);   color: var(--white); }
.btn-green  { background: var(--btn-green);  color: var(--white); }
.btn-white  { background: var(--white);      color: var(--header-red); border: 2px solid var(--header-red); }

/* =====================================================
   共通ヘッダー
===================================================== */
.app-header {
  display: flex;
  align-items: center;
  padding: 14px 28px;
  gap: 12px;
}

.logo-icon {
  width: 52px;
  height: 52px;
  background: var(--btn-blue);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { display: block; }

.app-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.03em;
}

/* =====================================================
   入力画面
===================================================== */
.input-main {
  display: flex;
  justify-content: center;
  padding: 24px 20px 60px;
}

.input-card {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 14px;
  padding: 32px 36px;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.input-card h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--white);
  text-align: center;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-group > label {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  gap: 6px;
}

.optional {
  font-size: 11px;
  font-weight: 400;
  background: rgba(255,255,255,0.25);
  color: var(--white);
  padding: 1px 7px;
  border-radius: 10px;
}

.form-group input[type="date"],
.form-group textarea,
.form-group select {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 7px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.15s;
}
.form-group input[type="date"]:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--btn-blue);
  background: var(--white);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* アレルゲンチェックボックス */
.allergen-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.allergen-grid label {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.85);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  transition: background 0.15s;
}
.allergen-grid label:hover { background: var(--white); }
.allergen-grid input[type="checkbox"] { accent-color: var(--header-red); }

/* 営業開始曜日セレクタ */
.day-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.day-radio {
  cursor: pointer;
  display: block;
}

.day-radio input[type="radio"] { display: none; }

.day-radio span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.7);
  border: 2px solid transparent;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  transition: all 0.15s;
}

.day-radio:hover span { background: rgba(255,255,255,0.9); }

.day-radio input[type="radio"]:checked + span {
  background: var(--btn-blue);
  border-color: var(--btn-blue);
  color: var(--white);
  box-shadow: 0 0 0 3px rgba(30,144,255,0.3);
}

/* 曜日跨ぎ被り制御 */
.overlap-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overlap-option {
  display: flex;
  align-items: stretch;
  cursor: pointer;
}

.overlap-option input[type="radio"] {
  display: none;
}

.overlap-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: rgba(255,255,255,0.7);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  transition: all 0.15s;
}

.overlap-option input[type="radio"]:checked + .overlap-card {
  background: var(--white);
  border-color: var(--btn-blue);
  box-shadow: 0 0 0 1px var(--btn-blue);
}

.overlap-option:hover .overlap-card {
  background: rgba(255,255,255,0.9);
}

.overlap-level {
  font-size: 13px;
  font-weight: 700;
  color: var(--header-red);
  min-width: 36px;
  flex-shrink: 0;
}

.overlap-option input[type="radio"]:checked + .overlap-card .overlap-level {
  color: var(--btn-blue);
}

.overlap-desc {
  font-size: 12px;
  color: var(--text-dark);
  line-height: 1.5;
}

.overlap-desc small {
  color: var(--text-gray);
  font-size: 11px;
}

/* ファイルアップロード */
.file-upload-area {
  background: rgba(255,255,255,0.7);
  border: 2px dashed rgba(255,255,255,0.6);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}
.file-upload-area:hover { background: rgba(255,255,255,0.85); }
.file-upload-area p { font-size: 13px; color: var(--text-gray); }
.file-upload-area .file-note { font-size: 11px; margin-top: 4px; }

.file-selected {
  font-size: 12px;
  color: var(--white);
  font-weight: 700;
  min-height: 18px;
}

/* 営業日数自動検出ノート */
.days-auto-note {
  background: rgba(255,255,255,0.15);
  border-left: 3px solid rgba(255,255,255,0.6);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  line-height: 1.6;
}

/* 生成ボタン */
.btn-generate {
  width: 100%;
  padding: 14px;
  background: var(--btn-blue);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: opacity 0.15s;
}
.btn-generate:hover { opacity: 0.88; }
.btn-generate:disabled {
  background: #999;
  cursor: not-allowed;
  opacity: 1;
}

/* =====================================================
   結果画面
===================================================== */
.result-page { padding-bottom: 48px; }

/* 結果ヘッダー */
.result-header {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  gap: 12px;
}

.result-header .header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.result-header .header-center {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.result-header .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

/* ボウルキャラ */
.bowl-char {
  width: 100px;
  height: 100px;
}

/* テーブルエリア */
.table-wrap {
  padding: 0 24px;
  overflow-x: auto;
}

.kondate-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1.5px solid var(--border);
  font-size: 12px;
  table-layout: fixed;
}

.kondate-table th,
.kondate-table td {
  border: 1px solid var(--border);
  vertical-align: top;
}

/* 左上コーナー */
.kondate-table .corner {
  background: var(--header-red);
  width: 110px;
}

/* 曜日ヘッダー */
.kondate-table .day-header {
  background: var(--header-red);
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  padding: 12px 8px;
}

/* 行ヘッダー（カテゴリ名） */
.kondate-table .row-header {
  background: var(--header-red);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  padding: 8px 4px;
  width: 110px;
}

/* データセル */
.kondate-table .menu-cell {
  background: var(--white);
  padding: 8px 10px;
  min-width: 160px;
  cursor: pointer;
  transition: background 0.1s;
}
.kondate-table .menu-cell:hover {
  background: #FFF5F5;
}
.kondate-table .menu-cell.selected {
  background: #EEF6FF !important;
  outline: 2px solid #1E90FF;
  outline-offset: -2px;
}
.kondate-table .menu-cell.selected::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #1E90FF;
}
/* セルにposition:relativeを付与（✓マーク配置用） */
.kondate-table td.menu-cell { position: relative; }

.dish-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 4px;
  line-height: 1.3;
}

.ingredients {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 5px;
}

.ingredients span {
  font-size: 10px;
  color: var(--text-gray);
  line-height: 1.4;
}

.kcal-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--kcal-red);
}

/* カロリー合計行 */
.kondate-table .kcal-total-header {
  background: #E87070;
  font-size: 10px;
}
.kondate-table .kcal-total-cell {
  background: #FFF5F5;
  text-align: right;
  vertical-align: middle;
  padding: 6px 10px;
}
.kcal-total-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--kcal-red);
}

/* スケルトンローディング */
.skeleton {
  background: linear-gradient(90deg, #f0a0a0 25%, #f5b5b5 50%, #f0a0a0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-cell {
  height: 80px;
  border-radius: 4px;
}

/* フッター */
.result-footer {
  display: flex;
  justify-content: center;
  padding: 28px 0 16px;
}

.btn-back {
  padding: 12px 40px;
  font-size: 15px;
}

/* =====================================================
   印刷用スタイル
===================================================== */
@media print {
  body { background: white; }

  .result-header .header-right,
  .result-header .header-center,
  .result-footer,
  .btn-yellow,
  .btn-gray,
  .btn-blue { display: none !important; }

  .table-wrap { padding: 0; }

  .kondate-table {
    font-size: 10px;
    width: 100%;
  }

  .print-date {
    display: block !important;
    text-align: right;
    font-size: 11px;
    color: #666;
    padding: 4px 0;
  }
}

.print-date { display: none; }

/* =====================================================
   トースト通知
===================================================== */
#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =====================================================
   モバイル専用要素（デスクトップでは非表示）
===================================================== */
.hamburger-btn  { display: none; }
.day-tabs       { display: none; }
.mobile-overlay { display: none; }
#mobile-stack   { display: none; }

/* モバイルメニュー：デスクトップでは画面外に格納 */
.mobile-menu {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
  background: #1e1e1e;
  padding: 12px 16px 20px;
  transform: translateY(-110%);
  transition: transform 0.3s ease;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55);
  display: none;
}

/* =====================================================
   スマートフォン対応 (max-width: 767px)
===================================================== */
@media (max-width: 767px) {
  /* ── ヘッダー ── */
  .result-header {
    padding: 10px 14px;
    gap: 0;
  }
  .result-header .header-center { display: none !important; }
  .result-header .header-right  { display: none !important; }
  .result-header .header-left   { flex: 1; min-width: 0; }

  .app-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── ハンバーガーボタン ── */
  .hamburger-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 8px;
    font-size: 20px;
    color: white;
    cursor: pointer;
    font-family: inherit;
    margin-left: 8px;
  }

  /* ── 曜日タブ・デスクトップ用テーブル：モバイルでは非表示 ── */
  .day-tabs  { display: none !important; }
  .table-wrap { display: none !important; }

  /* ── モバイル縦積みビュー ── */
  #mobile-stack {
    display: block;
    padding: 12px 12px 0;
  }

  .ms-day {
    background: #fff;
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }

  .ms-day-header {
    background: #B13546;
    color: #fff;
    font-size: 16px;
    font-weight: 900;
    padding: 9px 14px;
    letter-spacing: 0.03em;
  }

  .ms-row {
    display: flex;
    align-items: flex-start;
    border-bottom: 1px solid #f0e0e0;
    padding: 8px 12px;
    gap: 10px;
  }
  .ms-row:last-of-type { border-bottom: none; }

  .ms-cat {
    flex-shrink: 0;
    width: 76px;
    font-size: 11px;
    font-weight: 700;
    color: #B13546;
    padding-top: 2px;
    line-height: 1.4;
  }

  .ms-content { flex: 1; min-width: 0; }

  .ms-dish {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 3px;
    line-height: 1.3;
  }

  .ms-ingrs {
    font-size: 11px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 2px;
  }

  .ms-kcal {
    font-size: 10px;
    color: #C06060;
    font-weight: 700;
  }

  .ms-total {
    background: #fdf0f0;
    text-align: right;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #B13546;
    border-top: 2px solid #f0c0c0;
  }

  /* ── モバイルメニュードロワー ── */
  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 299;
  }
  .mobile-overlay.open { display: block; }

  .mobile-menu {
    display: block;       /* translateY で画面外 → open で戻す */
  }
  .mobile-menu.open { transform: translateY(0); }

  .mobile-menu-close {
    display: block;
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
  }

  .mobile-menu-inner {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 4px;
  }

  .mobile-menu .btn {
    width: 100%;
    padding: 13px;
    font-size: 14px;
  }

  /* ── フッター ── */
  .result-footer { padding: 20px 0 12px; }
  .btn-back { font-size: 14px; padding: 11px 32px; }
}

/* ── 横向き（landscape）追加調整 ── */
@media (max-width: 767px) and (orientation: landscape) {
  .mobile-menu-inner {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .mobile-menu .btn {
    flex: 1;
    min-width: calc(50% - 5px);
    padding: 10px;
    font-size: 13px;
  }
  .day-tab {
    padding: 8px 4px;
    font-size: 13px;
  }
}
