/* ============================================================
   家庭购物清单 · 样式
   ============================================================ */

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --bg: #f9fafb;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-dark: #d1d5db;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

input, select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
  width: 100%;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* 主容器 */
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
  padding-bottom: 80px;
}

/* 欢迎页 */
.welcome {
  padding: 60px 24px;
  text-align: center;
}

.welcome-logo {
  font-size: 64px;
  margin-bottom: 20px;
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}

.welcome-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 40px;
  line-height: 1.6;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.15s;
  min-height: 48px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:active { background: var(--primary-dark); }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-dark);
}
.btn-secondary:active { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-block { width: 100%; }

.btn-sm {
  padding: 8px 14px;
  min-height: 36px;
  font-size: 13px;
}

/* 卡片 */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

/* 顶栏 */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* 成员条 */
.members-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--primary-light);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--primary-dark);
  overflow: hidden;
  white-space: nowrap;
}

.members-avatars {
  display: flex;
  gap: -4px;
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid white;
  margin-left: -6px;
}
.avatar:first-child { margin-left: 0; }

/* 搜索框 */
.search {
  position: relative;
  margin-bottom: 12px;
}

.search input {
  padding-left: 36px;
  padding-right: 32px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 14px;
}

/* 分类筛选 */
.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }

.chip {
  padding: 6px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.15s;
}

.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* 添加项 */
.add-item {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-input {
  flex: 1;
  padding: 10px 12px;
}

.add-qty {
  width: 60px;
  text-align: center;
  padding: 10px 8px;
}

.add-category {
  width: 100px;
  padding: 10px 8px;
  font-size: 13px;
}

.add-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 分类组 */
.section {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.section-count {
  color: var(--text-light);
  font-size: 12px;
  font-weight: 500;
}

/* 项目列表 */
.item-list {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: none; }

.item-check {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--border-dark);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  color: transparent;
}

.item-check.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
}

.item.done .item-name {
  text-decoration: line-through;
  color: var(--text-light);
}

.item-meta {
  display: flex;
  gap: 8px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.item-note {
  color: var(--warning);
}

.item-actions {
  display: flex;
  gap: 4px;
}

.item-del {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.item-del:active {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* 底部按钮 */
.footer-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex;
  gap: 8px;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s;
}

.modal-content {
  background: var(--card);
  width: 100%;
  max-width: 640px;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  padding-bottom: 32px;
  animation: slideUp 0.2s;
  max-height: 85vh;
  overflow-y: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
}

/* 邀请链接 */
.invite-link {
  background: var(--bg);
  padding: 12px;
  border-radius: 10px;
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
  margin: 12px 0;
  border: 1px solid var(--border);
}

/* 操作日志 */
.log-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-time {
  color: var(--text-light);
  font-size: 12px;
  margin-right: 8px;
}
.log-actor {
  color: var(--primary-dark);
  font-weight: 600;
  margin-right: 6px;
}

/* 空态 */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-desc {
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 200;
  animation: fadeIn 0.2s;
  max-width: 90%;
}

/* 加载状态 */
.loading {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

/* 响应式桌面 */
@media (min-width: 768px) {
  .app { padding: 32px 24px; }
  .modal-content {
    border-radius: 20px;
    margin: auto;
    padding: 28px;
  }
  .modal { align-items: center; }
}
