/* ============================================================
 * 全局样式 style.css
 * 风格：简约白色居家风
 * 适配：手机 + 电脑（移动优先，最大宽度限制电脑端）
 * ============================================================ */

/* ---------- 一、基础重置 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* 去掉移动端点击高亮 */
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  color: #333;
  background: #f5f6f8; /* 浅灰背景，衬托白色卡片 */
  line-height: 1.5;
  /* 跟随系统深色模式时仍保持居家白底，此处不做深色适配 */
}

a { color: #4caf50; text-decoration: none; }
a:active { opacity: 0.7; }

input, button, select {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
}

/* ---------- 二、顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: #2e7d32;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #666;
}

/* 文字按钮（修改 / 返回 等） */
.link-btn {
  background: none;
  color: #4caf50;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
}
.link-btn:active { opacity: 0.6; }

/* ---------- 三、Tab 切换栏 ---------- */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 52px; /* 顶部栏高度，让 tab 紧贴顶栏下方 */
  z-index: 40;
}
.tab {
  flex: 1;
  padding: 12px 0;
  background: none;
  color: #888;
  font-size: 15px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab.active {
  color: #4caf50;
  border-bottom-color: #4caf50;
  font-weight: 600;
}

/* ---------- 四、内容容器 ---------- */
.content {
  max-width: 720px;     /* 电脑端最大宽度，居中显示 */
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px; /* 给底部悬浮按钮留空间 */
}

/* Tab 面板：默认隐藏，active 才显示 */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 五、分类区块与食材列表 ---------- */
.category-block {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.category-title {
  font-size: 15px;
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 10px;
  padding-left: 8px;
  border-left: 3px solid #4caf50;
}

.goods-list { display: flex; flex-direction: column; }

.goods-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.goods-item:last-child { border-bottom: none; }

.goods-info { display: flex; align-items: baseline; gap: 4px; }
.goods-name { font-size: 15px; color: #333; }
.goods-unit { font-size: 12px; color: #999; }

/* ---------- 六、数量选择控件 ---------- */
.qty-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f0f7f0;
  color: #4caf50;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.qty-btn:active { background: #d6ecd6; }
.qty-input {
  width: 52px;
  height: 32px;
  text-align: center;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  color: #333;
  /* 隐藏 number 输入框的上下箭头 */
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---------- 七、底部悬浮提交栏 ---------- */
.submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
  z-index: 30;
}
.submit-bar .btn-primary {
  width: 100%;
  max-width: 688px; /* 配合 content 最大宽度 */
  margin: 0 auto;
  display: block;
}

/* ---------- 八、按钮通用样式 ---------- */
.btn-primary {
  background: #4caf50;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:active { background: #43a047; }

.btn-danger {
  background: #fff;
  color: #e53935;
  border: 1px solid #e53935;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.btn-danger:active { background: #fdecea; }

.btn-danger-sm {
  background: #fdecea;
  color: #e53935;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.btn-danger-sm:active { background: #f9d6d4; }

/* ---------- 九、空状态 ---------- */
.empty {
  text-align: center;
  color: #aaa;
  padding: 40px 16px;
  font-size: 14px;
}

/* ---------- 十、我的清单卡片 ---------- */
.order-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}
.order-name { font-size: 16px; font-weight: 600; color: #333; }
.order-time { font-size: 12px; color: #999; }
.order-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}
.oi-name { color: #555; }
.oi-qty { color: #4caf50; font-weight: 600; }

/* ---------- 十一、汇总区 ---------- */
.summary-meta {
  display: flex;
  justify-content: space-between;
  background: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #666;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.summary-item .summary-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.summary-qty {
  font-size: 16px;
  font-weight: 700;
  color: #e53935; /* 汇总数量用红色突出，方便照单买菜 */
}
.summary-buyers {
  font-size: 11px;
  color: #999;
  max-width: 140px;
  text-align: right;
  word-break: break-all;
}

/* ---------- 十二、底部 footer ---------- */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: #bbb;
}
.footer a { color: #ccc; }

/* ---------- 十三、弹窗（昵称 / 口令门） ---------- */
.modal {
  display: none; /* 默认隐藏 */
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal.show {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.modal-box h3 {
  font-size: 18px;
  color: #333;
  margin-bottom: 6px;
}
.modal-tip {
  font-size: 12px;
  color: #999;
  margin-bottom: 16px;
}
.modal-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 14px;
}
.modal-box .btn-primary { width: 100%; }

/* ---------- 十四、管理员页面专用 ---------- */
.gate-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px 20px;
  max-width: 340px;
  margin: 40px auto;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.gate-box h3 { font-size: 18px; margin-bottom: 6px; }
.gate-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 15px;
  margin: 12px 0;
}
.gate-box .btn-primary { width: 100%; }

.admin-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.admin-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 12px;
  padding-left: 8px;
  border-left: 3px solid #4caf50;
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.form-input {
  flex: 1 1 120px;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  min-width: 0;
}
.add-form .btn-primary {
  flex: 0 0 auto;
  padding: 10px 18px;
}

.admin-goods-item .btn-danger-sm { margin-left: 8px; }

.danger-zone {
  border: 1px dashed #e53935;
}
.admin-logout {
  text-align: center;
  margin: 24px 0;
}

/* ---------- 十五、Toast 提示 ---------- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translate(-50%, -20px);
  background: #333;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast-success { background: #4caf50; }
.toast-error { background: #e53935; }
.toast-info { background: #333; }

/* ---------- 十六、响应式：电脑端微调 ---------- */
@media (min-width: 768px) {
  body { font-size: 16px; }
  .topbar-title { font-size: 20px; }
  .content { padding: 20px 16px; }
  .category-block { padding: 18px 22px; }
  .qty-btn { width: 32px; height: 32px; }
  .qty-input { width: 60px; height: 34px; }
  /* 电脑端去掉 input 默认聚焦虚线，统一用边框色 */
  .form-input:focus, .modal-box input:focus, .gate-box input:focus {
    border-color: #4caf50;
  }
}
