/* =========================================================
   Lumira 日常用品管理 - 共用樣式
   ========================================================= */
:root {
  --color-bg: #FFF9F5;
  --color-surface: #FFFFFF;
  --color-primary: #FF8FA3;
  --color-primary-dark: #F2637B;
  --color-primary-light: #FFE1E7;
  --color-secondary: #B8A9F4;
  --color-secondary-light: #ECE6FF;
  --color-accent: #9AD4E0;
  --color-accent-light: #E1F5F8;
  --color-warn: #F4B65A;
  --color-warn-light: #FFF1DC;
  --color-danger: #F26B6B;
  --color-danger-light: #FDE4E4;
  --color-success: #6FCF97;
  --color-success-light: #E4F8EC;
  --color-text: #3A3238;
  --color-text-soft: #8A7F87;
  --color-border: #F1E7EA;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-soft: 0 8px 24px rgba(180, 140, 150, 0.12);
  --shadow-card: 0 4px 14px rgba(180, 140, 150, 0.10);
  --app-max-width: 480px;
}

html.dark {
  --color-bg: #221B1F;
  --color-surface: #2E262B;
  --color-primary: #FF8FA3;
  --color-primary-dark: #FFA5B6;
  --color-primary-light: #3A2A30;
  --color-secondary: #C6B8FF;
  --color-secondary-light: #33293F;
  --color-accent: #9AD4E0;
  --color-accent-light: #223338;
  --color-warn: #F4B65A;
  --color-warn-light: #3A2F1C;
  --color-danger: #F28B8B;
  --color-danger-light: #3A2323;
  --color-success: #8CE0AF;
  --color-success-light: #1F332A;
  --color-text: #F3EAEE;
  --color-text-soft: #B7A9B1;
  --color-border: #3A2F35;
  --shadow-soft: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-card: 0 4px 14px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Noto Sans TC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

/* Phone-like centered app shell on larger screens */
.app-outer {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, #FBEFEA 0%, #F4EAF7 100%);
}
html.dark .app-outer {
  background: linear-gradient(180deg, #1B1518 0%, #1D1A22 100%);
}

.app-shell {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100vh;
  background: var(--color-bg);
  position: relative;
  box-shadow: var(--shadow-soft);
  padding-bottom: 88px;
}

@media (min-width: 540px) {
  .app-shell { min-height: 100vh; margin: 0 auto; }
}

/* Top bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--color-bg);
  padding: 18px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-bar h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
  border: none;
  cursor: pointer;
  transition: transform .15s ease;
  font-size: 16px;
}
.icon-btn:active { transform: scale(0.92); }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--app-max-width);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--color-text-soft);
  text-decoration: none;
  font-size: 11px;
  flex: 1;
  padding: 4px 0;
  position: relative;
}
.nav-item i { font-size: 19px; }
.nav-item.active { color: var(--color-primary); }
.nav-item .fab-wrap {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-top: -26px;
  box-shadow: 0 6px 16px rgba(255,143,163,0.45);
  font-size: 20px;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 22px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title .see-all {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill-danger { background: var(--color-danger-light); color: var(--color-danger); }
.pill-warn { background: var(--color-warn-light); color: #B5761F; }
html.dark .pill-warn { color: var(--color-warn); }
.pill-success { background: var(--color-success-light); color: #2E9E5B; }
html.dark .pill-success { color: var(--color-success); }
.pill-muted { background: var(--color-border); color: var(--color-text-soft); }
.pill-secondary { background: var(--color-secondary-light); color: var(--color-secondary); }

.stat-card {
  border-radius: var(--radius-md);
  padding: 14px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-num { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: 11px; opacity: .9; margin-top: 2px; }
.stat-card i.bg-icon {
  position: absolute;
  right: -6px;
  bottom: -10px;
  font-size: 48px;
  opacity: .25;
}

.item-card {
  display: flex;
  gap: 12px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: var(--color-text);
  align-items: center;
  cursor: pointer;
}
.item-thumb {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }

.grid-item-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 12px;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.grid-item-thumb {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  overflow: hidden;
}
.grid-item-thumb img { width: 100%; height: 100%; object-fit: cover; }

.chip {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-soft);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
  border: none;
  cursor: pointer;
}
.chip.active {
  background: var(--color-primary);
  color: #fff;
}

.cat-circle {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  margin: 0 auto 6px;
}

input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea, input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--color-primary); }

label.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-soft);
  margin-bottom: 6px;
  display: block;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255,143,163,0.35);
  transition: transform .15s ease;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.btn-danger-outline {
  background: var(--color-danger-light);
  border: none;
  color: var(--color-danger);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.fab {
  position: fixed;
  right: 50%;
  transform: translateX(calc(var(--app-max-width) / 2 - 76px));
  bottom: 96px;
  z-index: 35;
}
@media (max-width: 480px) {
  .fab { transform: none; right: 20px; }
}

.star-rating { display: inline-flex; gap: 2px; }
.star-rating i { color: #E8DEE2; font-size: 14px; }
.star-rating i.filled { color: #F4B65A; }

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #3A3238;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--color-text-soft);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; color: var(--color-border); }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(30,20,25,0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-mask.center { align-items: center; }
.modal-sheet {
  width: 100%;
  max-width: var(--app-max-width);
  background: var(--color-surface);
  border-radius: 24px 24px 0 0;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}
.modal-mask.center .modal-sheet {
  border-radius: 20px;
  max-height: 70vh;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--color-border);
  transition: .2s;
  border-radius: 999px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}
.switch input:checked + .switch-slider { background-color: var(--color-primary); }
.switch input:checked + .switch-slider:before { transform: translateX(20px); }

::-webkit-scrollbar { width: 0; height: 0; }

.scroll-x {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 20px 6px;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

a { color: inherit; }
