/* =============================================================================
 *  components.css  ——  Bento 卡片 / 进度条 / 按钮 / 弹窗 / Toast / 横条
 * ============================================================================= */

/* ========== Bento 网格（首页） ========== */
.bento {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gutter);
}
@media (min-width: 700px) {
  .bento { grid-template-columns: repeat(6, 1fr); }
}
@media (min-width: 1000px) {
  .bento { grid-template-columns: repeat(12, 1fr); }
}

.bento-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 192px;
  position: relative;
  transition: box-shadow .2s ease, transform .2s ease;
}
.bento-card.clickable { cursor: pointer; }
.bento-card.clickable:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
@media (min-width: 1000px) {
  .bento-card { min-height: 208px; }
}

.bento-card .card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.bento-card .card-title {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-h2); font-weight: var(--fw-h2);
  color: var(--color-text);
}
.bento-card .card-title .material-symbols-outlined {
  color: var(--color-primary);
  font-size: 22px;
  font-variation-settings: 'FILL' 1;
}
.bento-card .card-aside { color: var(--color-text-2); font-size: var(--fs-label); }
.bento-card .card-body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.bento-card .card-foot { margin-top: auto; }

/* Bento 桌面端跨列 */
@media (min-width: 1000px) {
  .col-8 { grid-column: span 8; }
  .col-4 { grid-column: span 4; }
  .col-3 { grid-column: span 3; }
  .col-6 { grid-column: span 6; }
}
@media (min-width: 700px) and (max-width: 999px) {
  .col-8 { grid-column: span 6; }
  .col-4 { grid-column: span 3; }
  .col-3 { grid-column: span 3; }
  .col-6 { grid-column: span 6; }
}

/* ========== 进度条（横条/胶囊，F-06/F-15 共用样式） ========== */
.bar {
  width: 100%;
  height: 12px;
  background: var(--color-heat-empty);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}
.bar.sm { height: 8px; }
.bar.lg { height: 16px; }
.bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width .4s ease;
}
.bar-fill.carbs   { background: var(--color-macro-carbs); }
.bar-fill.protein { background: var(--color-macro-protein); }
.bar-fill.fat     { background: var(--color-macro-fat); }
.bar-fill.success { background: var(--color-success); }

/* 进度条上下行（标签 + 数值） */
.bar-row { display: flex; justify-content: space-between; align-items: baseline; }
.bar-row .label { font-size: var(--fs-label); color: var(--color-text); font-weight: var(--fw-label); }
.bar-row .val   { font-size: var(--fs-unit); color: var(--color-text-2); }

/* 胶囊药丸（数据卡标题旁小标签） */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
  font-size: var(--fs-mini); font-weight: 600;
}
.pill.success { background: color-mix(in srgb, var(--color-success) 20%, transparent); color: var(--color-success); }
.pill.muted   { background: var(--color-divider); color: var(--color-text-2); }

/* ========== 7 日迷你柱状图（睡眠卡专用） ========== */
.mini-bars {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 4px; height: 56px;
}
.mini-bar {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 0;
}
.mini-bar .num-mini {
  font-size: 9px; color: var(--color-text-2);
  font-weight: 600;
}
.mini-bar .col {
  width: 100%; max-width: 18px;
  background: var(--color-heat-empty);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: background .2s ease;
}
.mini-bar .col.acc { background: var(--color-primary); }
.mini-bar .col.green { background: var(--color-success); }
.mini-bar .lbl {
  font-size: 9px; color: var(--color-text-2);
  margin-top: 2px;
}
.mini-bar.today .lbl { color: var(--color-primary); font-weight: 700; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-label); font-weight: 600;
  background: var(--color-card-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  transition: background-color .15s ease, color .15s ease, transform .1s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--color-divider); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--color-primary); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--color-primary-deep); }
.btn.ghost { background: transparent; border-color: var(--color-border); }
.btn.full  { width: 100%; }

/* 段控件（按钮组，图表上方切换 7/14/30 天之类） */
.seg {
  display: inline-flex;
  background: var(--color-divider);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0; background: transparent;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-unit); font-weight: 600;
  color: var(--color-text-2);
  transition: background .15s ease, color .15s ease;
  cursor: pointer;
}
.seg button.on {
  background: var(--color-card);
  color: var(--color-text);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* ========== 弹窗（底部抽屉 sheet） ========== */
.sheet-mask {
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: flex-end; justify-content: center;
}
.sheet-mask.open { display: flex; }
.sheet {
  background: var(--color-card);
  width: 100%; max-width: 560px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: sheet-up .25s ease;
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.sheet h2 { font-size: var(--fs-h2); font-weight: var(--fw-h2); margin-bottom: 4px; }
.sheet .sheet-desc { font-size: var(--fs-label); color: var(--color-text-2); margin-bottom: 16px; }
.sheet-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--color-divider); }
.sheet-section h3 { font-size: var(--fs-label); font-weight: 700; margin-bottom: 10px; color: var(--color-text); }

/* ========== 表单 ========== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: var(--fs-label); font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
.field input,
.field select {
  width: 100%;
  background: var(--color-input-bg);
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: var(--fs-body);
  outline: none;
  transition: border-color .15s ease;
}
.field input:focus,
.field select:focus { border-color: var(--color-primary); }
.field .tip { font-size: var(--fs-unit); color: var(--color-text-2); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; padding: 11px; font-size: var(--fs-label); }
.sheet-result { font-size: var(--fs-label); margin-top: 10px; min-height: 18px; }

/* ========== Toast ========== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: var(--color-text); color: var(--color-card);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-label);
  box-shadow: var(--shadow-pop);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--color-danger); color: #fff; }
.toast.ok  { background: var(--color-success); color: #fff; }

/* ========== 提示条（首页顶部连接状态/空数据） ========== */
.notice {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: var(--fs-label);
  margin-bottom: var(--space-4);
}
.notice.info { background: color-mix(in srgb, var(--color-primary) 12%, transparent); color: var(--color-primary-deep); }
.notice.warn { background: color-mix(in srgb, var(--color-warning) 15%, transparent); color: var(--color-warning); }
.notice.err  { background: color-mix(in srgb, var(--color-danger) 12%, transparent); color: var(--color-danger); }
.notice .material-symbols-outlined { font-size: 20px; }
.notice .dismiss { margin-left: auto; cursor: pointer; opacity: .6; }
.notice .dismiss:hover { opacity: 1; }

/* ========== 分割子卡（卡内分组） ========== */
.subgrid { display: grid; gap: 10px; }
.subgrid.two { grid-template-columns: 1fr 1fr; }
.subgrid .sep { width: 1px; background: var(--color-border); align-self: stretch; }
