/* ===== 全局变量 ===== */
:root {
  --bg: #eef5ff;
  --bg-card: rgba(255,255,255,0.92);
  --bg-hover: #e7effd;
  --input-bg: rgba(255,255,255,0.96);
  --border: #cad8f0;
  --text: #263453;
  --text-dim: #5e6c8a;
  --text-muted: #62708b;
  --accent: #5068bd;
  --accent-hover: #4057a8;
  --accent-2: #6b65b2;
  --accent-dim: rgba(80,104,189,0.13);
  --gold: #d6a13e;
  --green: #3f9884;
  --heart: #d96391;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 26px rgba(65,83,137,0.12);
  --shadow-hover: 0 12px 34px rgba(80,104,189,0.2);
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(181,221,255,0.72), transparent 34%),
    radial-gradient(circle at 92% 6%, rgba(220,205,255,0.64), transparent 30%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

::selection { background: rgba(97,120,207,0.24); color: var(--text); }

/* ===== 顶部导航 ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(249,252,255,0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(65,83,137,0.07);
}

.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 20px;
}

.logo { display: flex; align-items: center; gap: 8px; }
.logo-image {
  width: 40px; height: 40px; object-fit: cover;
  border: 1px solid var(--border); border-radius: 10px;
}
.logo-text {
  font-size: 20px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.stats-bar { flex: 1; display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 14px; }
.stat-num { color: var(--accent); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 10px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
  box-shadow: 0 5px 14px rgba(80,104,189,0.24);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #8073c9); transform: translateY(-1px); }

.btn-login {
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.btn-login:hover { background: var(--accent-dim); }

/* 已登录用户 chip */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; border-radius: 30px;
  background: var(--bg-hover); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition);
}
.user-chip:hover { border-color: var(--accent); background: var(--accent-dim); }

.user-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: var(--bg); flex-shrink: 0;
}
.user-avatar-sm[src=""], .user-avatar-sm:not([src]) { display: none; }
.user-avatar-sm.no-avatar {
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--accent-dim);
}

.user-nickname-sm { font-size: 14px; font-weight: 500; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 筛选栏 ===== */
.filter-bar { background: rgba(255,255,255,0.7); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); padding: 12px 0; }
.filter-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.search-box {
  flex: 1; min-width: 200px; display: flex; flex-direction: column;
  align-items: flex-start; gap: 6px;
}

.search-input {
  width: 100%;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 14px;
  color: var(--text); font-size: 14px; transition: var(--transition);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.search-help-button {
  background: transparent; border: 0; padding: 0 6px;
  color: var(--text-dim); font: inherit; font-size: 12px;
  cursor: pointer; transition: var(--transition);
}
.search-help-button:hover, .search-help-button:focus-visible { color: var(--accent-hover); }
.search-help-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.sort-buttons { display: flex; gap: 6px; }
.btn-sort {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px;
  cursor: pointer; transition: var(--transition);
}
.btn-sort:hover { border-color: var(--accent); color: var(--text); }
.btn-sort.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ===== 美食卡片 ===== */
.main-content { max-width: 1200px; margin: 0 auto; padding: 24px; }
.food-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

.food-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: var(--transition); cursor: pointer; box-shadow: var(--shadow);
}
.food-card:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.food-card-image { width: 100%; height: 220px; object-fit: cover; background: var(--bg-hover); display: block; }
.food-card-image-placeholder {
  width: 100%; height: 220px; display: flex; align-items: center; justify-content: center;
  font-size: 60px; background: var(--bg-hover);
}

.food-card-body { padding: 16px; }

.food-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.food-card-name { font-size: 17px; font-weight: 600; line-height: 1.3; }
.food-card-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; color: var(--text-dim); }
.food-card-price { color: var(--accent); font-weight: 600; }
.food-card-price::before { content: "人均 ¥"; font-weight: 400; color: var(--text-dim); }

.food-card-address { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.food-card-address svg { flex-shrink: 0; }

.food-card-desc {
  font-size: 14px; color: var(--text-dim); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 10px;
}

.food-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.food-tag { background: var(--accent-dim); color: var(--accent); padding: 3px 10px; border-radius: 20px; font-size: 12px; }

/* 发布者信息 */
.food-card-user { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.food-card-user-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.food-card-user-avatar[src=""], .food-card-user-avatar:not([src]) { display: none; }
.food-card-user-name { font-size: 12px; color: var(--text-dim); }

.food-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.food-card-footer-left { display: flex; align-items: center; gap: 10px; }
.food-card-date { font-size: 12px; color: var(--text-muted); }
.food-card-footer-right { display: flex; align-items: center; gap: 6px; }

/* 收藏按钮 */
.btn-favorite {
  position: relative; background: transparent; border: none; cursor: pointer;
  font-size: 20px; padding: 7px 12px 5px 6px; border-radius: 6px;
  transition: var(--transition); line-height: 1;
}
.btn-favorite:hover { background: rgba(226,85,85,0.1); transform: scale(1.2); }
.btn-favorite .heart { color: var(--text-muted); }
.btn-favorite.active .heart { color: var(--heart); }
.favorite-count {
  position: absolute; top: 0; right: 0; min-width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-hover); color: var(--text-muted);
  font-size: 10px; font-weight: 700; line-height: 1;
}
.btn-favorite.active .favorite-count { border-color: var(--heart); background: var(--heart); color: #fff; }
.btn-favorite.active { animation: heartBeat 0.4s ease; }

@keyframes heartBeat { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

.btn-delete {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 4px;
  transition: var(--transition);
}
.btn-delete:hover { color: #f44336; background: rgba(244,67,54,0.1); }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.empty-emoji { font-size: 64px; margin-bottom: 16px; }
.empty-state p { margin-bottom: 20px; font-size: 16px; }

/* ===== 弹窗通用 ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(38,52,83,0.38); backdrop-filter: blur(7px);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }

.btn-close {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 4px;
  transition: var(--transition);
}
.btn-close:hover { color: var(--text); background: var(--bg-hover); }

/* 搜索帮助 */
.modal-search-help { max-width: 520px; }
.search-help-body { padding: 22px 20px 20px; }
.search-help-line {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px; padding: 12px 14px;
  color: var(--text-dim); background: var(--accent-dim);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.search-prefix {
  flex: 0 0 28px; width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); background: rgba(255,255,255,0.72);
  border: 1px solid var(--border); border-radius: 8px;
  font-weight: 700; font-size: 16px;
}
.search-help-line code {
  padding: 2px 5px; color: var(--accent-hover);
  background: rgba(255,255,255,0.72); border-radius: 4px;
  font-family: inherit; font-weight: 600;
}
.search-help-actions { margin-top: 20px; }

/* ===== 表单 ===== */
#foodForm { padding: 20px; }

.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  height: 200px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition); margin-bottom: 20px; overflow: hidden; position: relative;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--accent-dim); }

.upload-placeholder { text-align: center; color: var(--text-dim); }
.upload-hint { font-size: 12px; color: var(--text-muted); }

.image-preview { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); object-fit: contain; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.required { color: #f44336; }

.form-group input, .form-group textarea {
  width: 100%; background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text);
  font-size: 14px; font-family: inherit; transition: var(--transition);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-group textarea { resize: vertical; }

/* 表单按钮 */
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }
.btn-cancel {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 10px 20px; border-radius: var(--radius-sm); font-size: 15px; cursor: pointer;
  transition: var(--transition);
}
.btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }
.btn-submit {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff;
  padding: 10px 24px; border-radius: var(--radius-sm); font-size: 15px;
  font-weight: 600; cursor: pointer; transition: var(--transition);
  box-shadow: 0 5px 14px rgba(80,104,189,0.22);
}
.btn-submit:hover { background: linear-gradient(135deg, var(--accent-hover), #8073c9); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 登录弹窗 ===== */
.modal-login { max-width: 400px; }
.login-body { padding: 20px; }
.login-hint { text-align: center; font-size: 14px; color: var(--text-dim); margin-bottom: 20px; }

.avatar-picker { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.avatar-preview {
  width: 80px; height: 80px; border-radius: 50%;
  border: 2px dashed var(--border); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; flex-shrink: 0; transition: var(--transition);
}
.avatar-preview:hover { border-color: var(--accent); }
.avatar-placeholder { font-size: 28px; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-tip { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ===== 验证弹窗 ===== */
.modal-verify { max-width: 420px; }
.verify-body { padding: 24px 20px; }
.verify-question { font-size: 16px; line-height: 1.6; text-align: center; margin-bottom: 16px; color: var(--text); }
.verify-hint { font-size: 13px; color: var(--text-dim); }
.verify-error { color: #f44336; font-size: 14px; text-align: center; margin-bottom: 12px; }
.modal-verify .form-group input { text-align: center; font-size: 20px; letter-spacing: 4px; }

/* ===== 我的账号弹窗 ===== */
.modal-account { max-width: 680px; }
.account-body { padding: 0; }

.account-profile {
  display: flex; align-items: center; gap: 16px;
  padding: 24px 20px 16px; border-bottom: 1px solid var(--border);
}
.account-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover; background: var(--bg-hover); flex-shrink: 0;
}
.account-avatar[src=""], .account-avatar:not([src]) { display: none; }
.account-name { font-size: 20px; font-weight: 600; }

.account-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.tab-btn {
  flex: 1; background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); padding: 14px; font-size: 15px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.tab-btn:hover { color: var(--text); background: var(--bg-hover); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.account-content { padding: 16px; min-height: 200px; max-height: 50vh; overflow-y: auto; }

.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.account-grid .food-card { cursor: pointer; }
.account-grid .food-card-image { height: 150px; }
.account-grid .food-card-body { padding: 12px; }
.account-grid .food-card-name { font-size: 15px; }
.account-empty { text-align: center; padding: 40px; color: var(--text-dim); font-size: 15px; }

/* ===== 店铺详情 ===== */
.modal-food-detail { max-width: 680px; position: relative; overflow-y: auto; }
.detail-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  color: #fff; background: rgba(24,34,61,0.58); backdrop-filter: blur(6px);
}
.detail-close:hover { color: #fff; background: rgba(24,34,61,0.78); }
.detail-image {
  width: 100%; max-height: 52vh; min-height: 260px;
  display: block; object-fit: contain; background: var(--bg-hover); cursor: zoom-in;
}
.detail-image-placeholder {
  height: 280px; align-items: center; justify-content: center;
  color: var(--text-muted); background: var(--bg-hover);
}
.detail-body { padding: 22px 24px 18px; }
.detail-name { color: var(--text); font-size: 24px; line-height: 1.35; }
.detail-price { margin-top: 8px; color: var(--accent); font-size: 16px; font-weight: 600; }
.detail-address { margin-top: 8px; color: var(--text-dim); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.detail-section-title { margin-top: 22px; color: var(--text); font-size: 14px; font-weight: 600; }
.detail-description { margin-top: 8px; color: var(--text-dim); font-size: 15px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-tag { margin-left: 8px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.detail-actions { display: flex; justify-content: flex-end; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.detail-favorite { font-size: 28px; padding: 10px 14px 7px 8px; }
.detail-favorite .favorite-count { top: -1px; right: -1px; min-width: 18px; height: 18px; font-size: 11px; }

/* ===== 图片大图 ===== */
.lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(24,34,61,0.94); z-index: 300;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 40px;
}
.lightbox img { max-width: 90%; max-height: 90%; border-radius: var(--radius); object-fit: contain; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--accent); color: var(--text);
  padding: 12px 24px; border-radius: var(--radius-sm); font-size: 14px;
  z-index: 400; box-shadow: var(--shadow); animation: toastIn 0.3s ease;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: #f44336; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== 加载动画 ===== */
.loading { text-align: center; padding: 60px; color: var(--text-dim); font-size: 16px; }
.loading::after {
  content: ''; display: block; width: 30px; height: 30px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; margin: 16px auto 0; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 底部 ===== */
.footer { text-align: center; padding: 24px 20px; border-top: 1px solid var(--border); margin-top: 40px; }
.footer-text { font-size: 13px; color: var(--text-dim); letter-spacing: 0.5px; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; gap: 10px; }
  .stats-bar { order: 3; width: 100%; justify-content: center; font-size: 12px; }
  .food-grid { grid-template-columns: 1fr; }
  .filter-inner { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
  .sort-buttons { justify-content: center; flex-wrap: wrap; }
  .avatar-picker { flex-direction: column; text-align: center; }
  .header-right { gap: 8px; }
  .user-nickname-sm { max-width: 60px; }
}
@media (max-width: 520px) {
  .header-inner { padding: 12px 16px; justify-content: center; }
  .logo { width: 100%; justify-content: center; }
  .stats-bar { order: 2; }
  .header-right { order: 3; width: 100%; min-width: 0; }
  .header-right .btn-primary, .header-right .btn-login { flex: 1 1 0; min-width: 0; padding-left: 10px; padding-right: 10px; }
  .header-right .user-chip { flex: 1; min-width: 0; justify-content: center; }
  .filter-inner { padding: 0 16px; }
  .sort-buttons { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn-sort { width: 100%; }
  .main-content { padding: 16px; }
  .logo-text { font-size: 18px; }
  .account-grid { grid-template-columns: 1fr; }
  .detail-image { min-height: 210px; }
  .detail-body { padding: 18px; }
  .detail-name { font-size: 21px; }
}
