/* 全局布局与宽度限制 */
[v-cloak] {
  display: none !important;
}

#app-loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #5f6b76;
  background: #f4f5f7;
  font-size: 14px;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

#app-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d8e2ec;
  border-top-color: #118bee;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

body {
  background-color: #f4f5f7;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 50px;
  background: #118bee;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 50px;
  background: linear-gradient(90deg,#0f7be4,#118bee);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}

/* 固定在头部左侧的返回首页链接（图标 + 文本） */
.app-header .home-link {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  text-decoration: none;
  background: rgba(255,255,255,0.08);
  padding: 6px 10px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.app-header .home-link::before {
  content: '🏠';
  display: inline-block;
  font-size: 16px;
  line-height: 1;
}

.app-header .home-link .sr-only { display: none; }

.app-header .home-link:active,
.app-header .home-link:focus {
  outline: none;
  background: rgba(255,255,255,0.14);
}

/* 在极小屏幕上只显示图标，隐藏文字以节省空间 */
@media (max-width: 420px) {
  .app-header .home-link { padding: 6px; }
  .app-header .home-link span { display: none; }
}

.app-content {
  flex: 1;
  padding: 15px;
  padding-bottom: 70px; /* 为 TabBar 留出高度 */
}

/* 底部 TabBar */
.app-tabbar {
  position: fixed;
  bottom: 0;
  top: auto; /* 取消可能来自 Picnic 的 top:0 覆盖，确保在底部 */
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid #eef0f2;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  box-sizing: border-box;
}

.app-tabbar .tab-item {
  flex: 1 1 auto;
  text-decoration: none;
  color: #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  min-height: 64px; /* 更大的触控目标 */
  box-sizing: border-box;
}

.app-tabbar .tab-item .icon {
  font-size: 20px;
  line-height: 1;
}

.app-tabbar .tab-item .label {
  font-size: 12px;
  margin-top: 2px;
  line-height: 1;
}

.app-tabbar .tab-item.active,
.app-tabbar .tab-item.active .icon,
.app-tabbar .tab-item.active .label {
  color: #118bee;
  font-weight: 600;
}

/* 中间浮动按钮已移除；使用统一的 .tab-item 样式 */

/* 在极小屏幕上隐藏文本，仅保留图标以节省空间 */
@media (max-width: 360px) {
  .app-tabbar .tab-item .label { display: none; }
  .app-tabbar { height: 72px; }
}

/* 让主内容保留更多底部间距，避免被悬浮按钮遮挡 */
@media (max-width: 480px) {
  .app-content { padding-bottom: 92px; }
}

/* 首页面板卡片 */
.dashboard-card {
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
}

/* 快速操作按钮居中（覆盖 Picnic 的布局类） */
.quick-actions {
  display: flex !important;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

/* 更高优先级，覆盖 Picnic 的 .flex.two 对布局的影响 */
.flex.two.quick-actions {
  display: flex !important;
  grid-template-columns: none !important;
}

.quick-actions > div,
.flex.two.quick-actions > div {
  flex: 1 1 0;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: none;
}

.quick-actions .button.block,
.flex.two.quick-actions .button.block {
  width: auto !important; /* 取消 block 的默认全宽行为 */
  min-width: 140px !important;
}

.record-item {
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #f0f0f0;
  cursor: pointer;
}

.text-success { color: #2ecc71; }
.text-error { color: #e74c3c; }
.text-right { text-align: right; }

/* 图像缩略图组件 */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.img-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%;
}

.img-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.detail-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 4px;
}

.delete-btn {
  position: absolute;
  top: -5px;
  right: -5px;
  background: rgba(231, 76, 60, 0.9);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  text-align: center;
  line-height: 18px;
  font-size: 14px;
}

/* css/app.css 补充部分 */

.image-upload-container {
  margin-top: 10px;
}

/* 修饰上传按钮，使其有点击感 */
.button.prestige {
  background-color: #f8f9fa;
  color: #333;
  border: 1px solid #ddd;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px; /* 图标和文字间距 */
}

.button.prestige:hover, .button.prestige:active {
  background-color: #e2e6ea;
  border-color: #adb5bd;
}

.border-dashed {
  border: 2px dashed #e0e0e0;
}

.margin-top-sm {
  margin-top: 8px;
}

/* 确保预览图片中的删除按钮可点击 */
.img-wrapper .delete-btn {
  cursor: pointer;
  z-index: 10; /* 确保在图片之上 */
}

/* 统一卡片样式与文本间距，改善详情页/列表对齐 */
.card {
  background: #ffffff;
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.02) inset;
}

.card h2 {
  margin: 0 0 8px 0;
  font-size: 1.4rem;
}

.card p {
  margin: 6px 0;
  line-height: 1.45;
}

/* 在详情页中，直接使用 .detail-img 时让图片按文档流显示并居中 */
.image-preview-grid .detail-img {
  grid-column: 1 / -1; /* 占满整行，避免网格导致的错位 */
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 6px;
}

/* 更稳健的缩略图网格行为（用于带 .img-wrapper 的缩略图） */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 10px;
  align-items: start;
}

/* 桌面端使用侧栏和宽工作区，移动端继续使用上面的单列布局 */
@media (min-width: 769px) {
  body {
    background: #eef2f6;
  }

  #app {
    max-width: 1440px;
    margin: 0 auto;
    background: #f7f9fb;
    box-shadow: 0 0 24px rgba(31, 45, 61, 0.08);
  }

  .app-header {
    position: sticky;
    height: 64px;
    justify-content: flex-start;
    padding: 0 32px;
    box-sizing: border-box;
  }

  .app-header .brand {
    gap: 14px;
    font-size: 18px;
  }

  .app-header .home-link {
    position: static;
    transform: none;
    padding: 8px 12px;
  }

  .app-content {
    width: min(100% - 280px, 1080px);
    margin: 0 40px 0 240px;
    padding: 32px 0 48px;
    box-sizing: border-box;
  }

  .app-tabbar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: max(calc((100vw - 1440px) / 2), 0px);
    right: auto;
    width: 200px;
    max-width: none;
    height: auto;
    padding: 20px 12px;
    border-top: 0;
    border-right: 1px solid #e4e9ef;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 6px;
    box-sizing: border-box;
  }

  .app-tabbar .tab-item {
    flex: 0 0 52px;
    min-height: 52px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 16px;
    border-radius: 8px;
    cursor: pointer;
  }

  .app-tabbar .tab-item:hover {
    background: #f0f5fa;
    color: #118bee;
  }

  .app-tabbar .tab-item .icon {
    width: 24px;
    text-align: center;
    font-size: 19px;
  }

  .app-tabbar .tab-item .label {
    margin-top: 0;
    font-size: 14px;
  }

  .app-tabbar .tab-item.active {
    background: #e7f3ff;
  }

  .page {
    width: 100%;
  }

  .dashboard-card {
    padding: 24px;
    margin-bottom: 20px;
  }

  .dashboard-card .flex.two {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
  }

  .quick-actions {
    gap: 16px;
    justify-content: flex-start;
    margin-bottom: 28px;
  }

  .quick-actions > div,
  .flex.two.quick-actions > div {
    flex: 0 1 220px;
  }

  .quick-actions .button.block,
  .flex.two.quick-actions .button.block {
    width: 100% !important;
    min-width: 0 !important;
  }

  form {
    max-width: 760px;
  }

  .filter-card {
    padding: 20px;
  }

  .filter-card .flex.two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .record-item {
    padding: 16px 20px;
  }

  .canvas-container {
    max-width: 900px;
    min-height: 420px;
    margin: 0 auto;
  }

  .menu-list {
    max-width: 520px;
  }
}