/* fitness 追蹤 Web App — 手機優先、藍綠漸層 #0e9b8e / #2b7fb8、無 emoji */

* {
  box-sizing: border-box;
}

:root {
  --brand-teal: #0e9b8e;
  --brand-blue: #2b7fb8;
  --brand-gradient: linear-gradient(135deg, var(--brand-teal), var(--brand-blue));
  --bg: #f4f7f8;
  --card-bg: #ffffff;
  --text-main: #1b2733;
  --text-sub: #5c6b76;
  --border: #dde4e7;
  --danger: #c94b4b;
  --danger-bg: #fbeaea;
  --success: #1f9d61;
  --success-bg: #e8f7ef;
  --radius: 14px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  width: 100%;
}

/* ---------- 選人畫面 ---------- */
#screen-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gradient);
  padding: 24px;
}

.picker-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-title {
  color: #fff;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 12px;
}

.picker-btn {
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--brand-blue);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

.picker-btn:active {
  transform: scale(0.98);
}

/* ---------- PIN 畫面 ---------- */
#screen-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gradient);
  padding: 24px;
}

.pin-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pin-user-label {
  color: #fff;
  text-align: center;
  font-size: 1.1rem;
  margin: -8px 0 4px;
}

.pin-input {
  width: 100%;
  min-height: 56px;
  border-radius: var(--radius);
  border: none;
  padding: 0 16px;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.3em;
}

.pin-error {
  color: #fff;
  background: rgba(201, 75, 75, 0.85);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  font-size: 0.9rem;
  margin: 0;
}

/* ---------- 共用按鈕 ---------- */
.btn-primary {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--brand-gradient);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 0.95rem;
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
  padding: 0 4px;
}

/* ---------- 今日頁 ---------- */
#screen-today {
  padding-bottom: 48px;
}

.top-bar {
  background: var(--brand-gradient);
  color: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar-user {
  font-size: 1.1rem;
  font-weight: 700;
  margin-right: 10px;
}

.top-bar-date {
  font-size: 0.9rem;
  opacity: 0.9;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  margin: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-main);
}

/* 今日合計卡片 */
.summary-card {
  background: #ffffff;
  border: 1px solid var(--border);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg);
}

.summary-label {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.summary-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.gap-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  width: fit-content;
}

.gap-badge.gap-ok {
  color: var(--success);
  background: var(--success-bg);
}

.gap-badge.gap-over {
  color: var(--danger);
  background: var(--danger-bg);
}

/* 一鍵套餐 */
.combo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.combo-btn {
  flex: 1 1 calc(50% - 8px);
  min-height: 52px;
  border: 1px solid var(--brand-teal);
  border-radius: 10px;
  background: #fff;
  color: var(--brand-teal);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
}

.combo-btn:active {
  background: var(--brand-teal);
  color: #fff;
}

/* 表單共用 */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: flex;
  gap: 8px;
}

.field-third {
  flex: 1;
}

.field-label {
  font-size: 0.85rem;
  color: var(--text-sub);
  font-weight: 600;
}

.field-input {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 1rem;
  background: #fff;
  color: var(--text-main);
  width: 100%;
}

.field-input:focus {
  outline: 2px solid var(--brand-teal);
  outline-offset: 1px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 1rem;
}

.checkbox-field input[type="checkbox"] {
  width: 22px;
  height: 22px;
}

.calc-preview {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.9rem;
  color: var(--text-sub);
}

.hint-text {
  font-size: 0.85rem;
  color: var(--brand-blue);
  background: #eaf3fa;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
}

/* 今日已加入清單 */
.entry-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.9rem;
}

.entry-item-main {
  font-weight: 600;
}

.entry-item-sub {
  color: var(--text-sub);
  font-size: 0.8rem;
}

.entry-item-status {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
}

.entry-item-status.pending {
  background: #fff4e0;
  color: #a06a10;
}

/* toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ---------- 手機收斂（整體版面縮緊） ---------- */
html, body {
  font-size: 15px;
  line-height: 1.4;
}

.card {
  margin: 8px 10px;
  padding: 12px;
  border-radius: 10px;
}

.card-title {
  margin-bottom: 8px;
  font-size: 1rem;
}

.form-grid {
  gap: 8px;
}

.field {
  gap: 4px;
}

.field-input {
  min-height: 44px;
  padding: 0 10px;
  font-size: 0.95rem;
}

.btn-primary,
.btn-secondary {
  min-height: 44px;
  font-size: 1rem;
}

.picker-btn {
  min-height: 52px;
  font-size: 1.1rem;
}

.summary-value {
  font-size: 1.15rem;
}

.summary-item {
  min-width: 0;
  padding: 8px;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* ---------- 爆框修正（overflow） ---------- */
.field-row {
  gap: 6px;
  min-width: 0;
}

.field-third {
  flex: 1 1 0;
  min-width: 0;
}

.field-input {
  max-width: 100%;
}

.entry-item {
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
}

.entry-item > div {
  min-width: 0;
  flex: 1;
}

.entry-item-main,
.entry-item-sub {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.entry-item-status {
  flex: 0 0 auto;
}

.gap-badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.calc-preview {
  overflow-wrap: anywhere;
}

/* ---------- 今日清單刪除鈕 ---------- */
.entry-delete-btn {
  flex: 0 0 auto;
  min-width: 40px;
  min-height: 36px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

.entry-delete-btn:active {
  background: var(--danger-bg);
}

@media (min-width: 600px) {
  .card {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }
  .top-bar > div:first-child,
  .top-bar {
    max-width: 560px;
  }
  .top-bar {
    margin: 0 auto;
  }
}
