/* Calorie Vision Scanner Modal Styling */

.calorie-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18, 16, 14, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.calorie-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.calorie-modal-container {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e5ded4);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 48px -12px rgba(27, 22, 18, 0.25);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.calorie-modal-overlay.active .calorie-modal-container {
  transform: translateY(0) scale(1);
}

.calorie-modal-header {
  padding: 18px 22px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border, #eee7df);
}

.calorie-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text, #272320);
  display: flex;
  align-items: center;
  gap: 8px;
}

.calorie-modal-header p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted, #867b71);
}

.calorie-modal-close {
  background: var(--surface-soft, #f7f3ee);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--muted, #72685d);
  transition: background 0.15s;
}

.calorie-modal-close:hover {
  background: var(--border, #e5ded4);
  color: var(--text, #111);
}

.calorie-modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Upload & Viewfinder Box */
.calorie-viewfinder {
  position: relative;
  width: 100%;
  height: 220px;
  background: var(--surface-soft, #f8f5f0);
  border: 2px dashed var(--border, #d8cfc4);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.calorie-viewfinder:hover {
  border-color: var(--plum, #734f68);
  background: #fbf9f6;
}

.calorie-viewfinder.is-dragover {
  border-color: #16a34a !important;
  background: rgba(22, 163, 74, 0.08) !important;
  transform: scale(1.015);
}

.calorie-drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(22, 163, 74, 0.12);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.calorie-drop-overlay span {
  background: #16a34a;
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.calorie-viewfinder.is-dragover .calorie-drop-overlay {
  opacity: 1;
}

.calorie-viewfinder.has-image {
  border-style: solid;
  border-color: var(--border, #e5ded4);
  background: #000;
}

.calorie-viewfinder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.calorie-viewfinder.has-image img {
  display: block;
}

.calorie-viewfinder-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted, #82766b);
  pointer-events: none;
}

.calorie-viewfinder-placeholder .cam-icon {
  font-size: 38px;
}

.calorie-viewfinder-placeholder strong {
  font-size: 14px;
  color: var(--text, #2d2621);
}

.calorie-viewfinder.has-image .calorie-viewfinder-placeholder {
  display: none;
}

/* Scanning Laser Animation */
.calorie-scanner-laser {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #22c55e, #3b82f6, transparent);
  box-shadow: 0 0 12px 2px rgba(34, 197, 94, 0.7);
  display: none;
}

.is-scanning .calorie-scanner-laser {
  display: block;
  animation: scanLaser 1.8s ease-in-out infinite alternate;
}

@keyframes scanLaser {
  0% { top: 4%; }
  100% { top: 94%; }
}

/* Hint Input */
.calorie-hint-wrap {
  display: flex;
  gap: 10px;
}

.calorie-hint-wrap input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border, #d9d1c7);
  border-radius: 10px;
  font-size: 13px;
  background: var(--surface, #fff);
  color: var(--text, #222);
}

.calorie-hint-wrap input:focus {
  outline: none;
  border-color: var(--plum, #734f68);
}

.btn-scan-action {
  padding: 10px 20px;
  background: var(--plum, #734f68);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-scan-action:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-scan-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Fast Preset Pills */
.calorie-quick-presets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calorie-quick-presets small {
  font-size: 12px;
  color: var(--muted, #867b71);
}

.calorie-preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.calorie-preset-pill {
  padding: 6px 12px;
  background: var(--surface-soft, #f7f3ee);
  border: 1px solid var(--border, #e6ded4);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text, #332d28);
}

.calorie-preset-pill:hover {
  border-color: var(--plum, #734f68);
  background: #fbf7f3;
  color: var(--plum, #734f68);
}

/* Result Card */
.calorie-result-card {
  display: none;
  flex-direction: column;
  gap: 14px;
  background: var(--surface-soft, #faf7f2);
  border: 1px solid var(--border, #e8dfd5);
  border-radius: 14px;
  padding: 16px;
  animation: fadeInResult 0.3s ease;
}

.calorie-result-card.active {
  display: flex;
}

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

.calorie-result-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calorie-result-summary h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #201c19);
}

.calorie-total-badge {
  background: #eef8f1;
  color: #1e7e34;
  border: 1px solid #c2e9ca;
  font-size: 17px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 12px;
}

/* Macro Bar */
.calorie-macro-bar {
  display: flex;
  gap: 8px;
}

.calorie-macro-pill {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #eee5db);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.calorie-macro-pill span {
  font-size: 11px;
  color: var(--muted, #7c7267);
}

.calorie-macro-pill strong {
  font-size: 13.5px;
  color: var(--text, #27221e);
  margin-top: 2px;
}

/* Item Breakdown */
.calorie-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calorie-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface, #fff);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #eee5db);
  font-size: 13px;
}

.calorie-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calorie-item-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calorie-item-slider-wrap input[type="range"] {
  width: 90px;
  accent-color: var(--plum, #734f68);
}

.calorie-item-slider-wrap small {
  min-width: 42px;
  text-align: right;
  font-weight: 600;
  color: var(--muted, #554d45);
}

.calorie-advice-box {
  background: #fdfaf5;
  border-left: 3px solid #d97706;
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  color: #78350f;
  line-height: 1.45;
}

.calorie-modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border, #eee7df);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--surface-soft, #faf7f2);
}

.btn-fill-calorie {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-fill-calorie:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* 来源选择按钮组（现场拍照 vs 相册选择） */
.calorie-action-buttons-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-source-cam,
.btn-source-gallery {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.18s ease;
  text-align: left;
}

.btn-source-cam {
  background: rgba(91, 130, 102, 0.08);
  border: 1.5px solid rgba(91, 130, 102, 0.35);
  color: #274c33;
}

.btn-source-cam:hover {
  background: rgba(91, 130, 102, 0.14);
  border-color: rgba(91, 130, 102, 0.55);
}

.btn-source-gallery {
  background: rgba(196, 104, 73, 0.08);
  border: 1.5px solid rgba(196, 104, 73, 0.35);
  color: #7b3821;
}

.btn-source-gallery:hover {
  background: rgba(196, 104, 73, 0.14);
  border-color: rgba(196, 104, 73, 0.55);
}

.btn-source-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.btn-source-text {
  display: flex;
  flex-direction: column;
}

.btn-source-text strong {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
}

.btn-source-text small {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
  font-weight: 400;
}

.calorie-action-buttons-row button:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* 重新拍照/选图的浮动胶囊 */
.calorie-repick-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(18, 16, 14, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  z-index: 5;
  display: none;
  transition: all 0.15s ease;
}

.calorie-viewfinder.has-image .calorie-repick-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.calorie-repick-pill:hover {
  background: rgba(18, 16, 14, 0.88);
}

@media (max-width: 600px) {
  .calorie-modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important; /* 手机端抽屉式贴底，单手触控更协调 */
  }
  .calorie-modal-container {
    max-height: 90vh !important;
    border-radius: 22px 22px 0 0 !important;
    width: 100% !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25) !important;
  }
  .calorie-modal-header {
    padding: 14px 16px 12px !important;
  }
  .calorie-modal-header h3 {
    font-size: 15.5px !important;
  }
  .calorie-modal-body {
    padding: 12px 16px !important;
    gap: 12px !important;
  }
  .calorie-viewfinder {
    height: 160px !important;
    border-radius: 12px !important;
  }
  .calorie-viewfinder-placeholder .cam-icon {
    font-size: 28px !important;
  }
  .calorie-viewfinder-placeholder strong {
    font-size: 13px !important;
  }
  .calorie-action-buttons-row {
    gap: 8px !important;
  }
  .btn-source-cam,
  .btn-source-gallery {
    padding: 10px 8px !important;
    border-radius: 12px !important;
    gap: 6px !important;
  }
  .btn-source-icon {
    font-size: 18px !important;
  }
  .btn-source-text strong {
    font-size: 13px !important;
  }
  .btn-source-text small {
    display: none !important; /* 手机窄屏隐藏次要说明，保持单行清晰利落 */
  }
  .calorie-hint-wrap {
    gap: 6px !important;
  }
  .calorie-hint-wrap input {
    font-size: 12.5px !important;
    padding: 8px 10px !important;
  }
  .btn-scan-action {
    padding: 8px 14px !important;
    font-size: 12.5px !important;
    white-space: nowrap !important;
  }
  .calorie-preset-pills {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 2px 2px 6px !important;
    gap: 6px !important;
  }
  .calorie-preset-pill {
    flex-shrink: 0 !important;
    font-size: 11.5px !important;
    padding: 5px 10px !important;
  }
  .calorie-modal-footer {
    padding: 12px 16px !important;
    gap: 8px !important;
  }
  .btn-fill-calorie {
    padding: 9px 16px !important;
    font-size: 13px !important;
  }
}
