/* ================= 基础变量 ================= */
:root {
  --wechat-green: #07c160;
  --text-primary: #191919;
  --border-color: #ededed;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ================= 基础布局 (移动端优先) ================= */
body {
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
} 
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background-color: #fff;
}

/* ================= 顶部导航 ================= */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.btn-cancel {
  font-size: 16px;
  color: #333;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: -8px;
}

.btn-publish {
  background-color: var(--wechat-green);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-publish:active {
  opacity: 0.7;
}

.btn-publish:disabled {
  background-color: #e0e0e0;
  color: #a0a0a0;
  cursor: not-allowed;
}

/* ================= 内容区与输入框 ================= */
.main-content {
  flex: 1;
  background-color: #fff;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.textarea-wrapper {
  margin-bottom: 16px;
}

.publish-textarea {
  width: 100%;
  min-height: 100px;
  border: none;
  outline: none;
  resize: none;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-primary);
  background: transparent;
  font-family: inherit;
  overflow: hidden;
}

.publish-textarea::placeholder {
  color: #b2b2b2;
}

/* ================= 图片网格 (核心修复拖拽拉伸) ================= */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.image-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1; /* 强制锁死正方形，防止拖拽时被拉长 */
  border-radius: 8px;
  overflow: hidden;
  background-color: #f0f0f0;
  transition:
    transform 0.2s,
    opacity 0.2s,
    box-shadow 0.2s;
}

.image-item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.btn-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.btn-delete::after {
  content: "";
  position: absolute;
  top: -12px;
  right: -12px;
  bottom: -12px;
  left: -12px;
}

.btn-delete:active {
  background: rgba(0, 0, 0, 0.8);
}

/* ================= 拖拽状态防变形修复 ================= */
.sortable-chosen .btn-delete,
.sortable-ghost .btn-delete {
  opacity: 0;
  pointer-events: none;
}

.sortable-ghost {
  opacity: 0.4;
  border: 1px dashed var(--wechat-green);
  background-color: #f0fdf4;
}

/* 拖拽时挂载到 body 上的克隆体 */
.sortable-fallback {
  position: absolute !important;
  z-index: 99999 !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
  opacity: 0.9 !important;
  pointer-events: none !important;
  transform: scale(1.05);
}

.sortable-chosen {
  z-index: 10;
}

/* ================= 上传按钮 ================= */
.upload-btn {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background-color: #f7f7f7;
  border: 1px dashed #d9d9d9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.upload-btn:active {
  background-color: #eee;
}

.upload-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 2px;
  background-color: #b2b2b2;
  transform: translate(-50%, -50%);
}

.upload-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 30px;
  background-color: #b2b2b2;
  transform: translate(-50%, -50%);
}

#fileInput,
#cameraInput {
  display: none;
}

/* ================= 选项列表 ================= */
.options-list {
  margin-top: 24px;
  border-top: 1px solid var(--border-color);
}

.option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.option-item:active {
  background-color: #f9f9f9;
}

.option-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #333;
}

.option-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.option-text {
  font-size: 16px;
  color: #333;
}

.option-value {
  font-size: 15px;
  color: #999;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 60%;
}

.option-value span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.option-arrow {
  font-size: 14px;
  color: #ccc;
  flex-shrink: 0;
}

/* ================= 底部弹窗层级修正 ================= */
.sheet-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;
}

.sheet-mask.active {
  opacity: 1;
  visibility: visible;
}

.sheet-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #fff;
  border-radius: 16px 16px 0 0;
  z-index: 10000;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  padding-bottom: var(--safe-bottom);
}

.sheet-panel.active {
  transform: translateY(0);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sheet-title {
  font-size: 16px;
  font-weight: 500;
}

.sheet-btn {
  font-size: 15px;
  color: var(--wechat-green);
  cursor: pointer;
  padding: 4px;
}

.sheet-close {
  font-size: 20px;
  color: #999;
  cursor: pointer;
  padding: 4px;
}

/* ================= 苹果风格 Action Sheet 面板 ================= */
.action-sheet-group {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
}

.action-item {
  padding: 16px;
  text-align: center;
  font-size: 17px;
  color: #333;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  background-color: #fff;
}

.action-item:active {
  background-color: #f2f2f7;
}

.action-item.selected {
  color: var(--wechat-green);
  font-weight: 500;
}

.action-item:last-child {
  border-bottom: none;
}

.action-cancel {
  padding: 16px;
  text-align: center;
  font-size: 17px;
  color: #333;
  background-color: #fff;
  border-radius: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: var(--safe-bottom);
}

.action-cancel:active {
  background-color: #f2f2f7;
}

/* ================= 位置/话题列表 ================= */
.picker-search-wrapper {
  padding: 12px 16px;
  background-color: #f7f7f7;
}

.picker-search-inner {
  display: flex;
  align-items: center;
  background-color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
}

.picker-search-inner i {
  color: #b2b2b2;
  margin-right: 8px;
}

.picker-search-inner input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 15px;
  background: transparent;
}

.picker-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 300px;
  position: relative;
}

.picker-item {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.picker-item:active {
  background-color: #f9f9f9;
}

.picker-item i.fa-map-marker-alt {
  font-size: 18px;
  color: #999;
  margin-right: 12px;
  flex-shrink: 0;
}

.picker-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.picker-item-name {
  font-size: 16px;
  color: #333;
}

.picker-item-address {
  font-size: 13px;
  color: #999;
}

.picker-item-check {
  color: var(--wechat-green);
  font-size: 16px;
  display: none;
}

.picker-item.selected .picker-item-check {
  display: block;
}

.picker-item.is-current-loc {
  background-color: #f8fdf9;
}

.picker-item.is-current-loc .picker-item-name {
  color: var(--wechat-green);
  font-weight: 500;
}

/* ================= 🌟 核心修复：加载状态样式优化 ================= */
#loadingText {
  display: none;
  /* 使用绝对定位，始终居中于列表容器 */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #86868b;
  font-size: 14px;
  text-align: center;
  white-space: nowrap;
}

#loadingText i {
  display: inline-block;
  animation: spin 1s linear infinite;
  margin-right: 6px;
  vertical-align: -1px; /* 让图标与文字完美垂直居中对齐 */
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* 话题样式 */
.topic-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.topic-item:active {
  background-color: #f9f9f9;
}

.topic-avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background-color: #e6f7ff;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1890ff;
  font-size: 20px;
  font-weight: bold;
}

.topic-name {
  flex: 1;
  font-size: 16px;
  color: #333;
}

.topic-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.2s;
}

.topic-item.selected .topic-checkbox {
  background-color: var(--wechat-green);
  border-color: var(--wechat-green);
  color: #fff;
}

/* ================= 拖拽把手 ================= */
.drag-handle-wrapper {
  width: 100%;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  touch-action: none;
}
.drag-handle-wrapper:active {
  cursor: grabbing;
}
.drag-handle {
  width: 36px;
  height: 5px;
  background-color: #d1d1d6;
  border-radius: 3px;
}

/* ================= 底部悬浮栏 ================= */
.bottom-publish-bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 99;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  padding: 12px 16px;
  bottom: calc(56px + var(--safe-bottom));
  transition:
    transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
    bottom 0.3s;
}

body.hide-global-nav .bottom-publish-bar {
  bottom: 0;
  padding-bottom: calc(12px + var(--safe-bottom));
}

body.keyboard-open .ios-mobile-bottom-nav {
  display: none !important;
}

body.keyboard-open .bottom-publish-bar {
  padding-bottom: 12px;
  bottom: 0;
  transform: translateZ(0);
}

.bottom-publish-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
}

.pub-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border-radius: 23px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: #1f2329;
  transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.03),
    inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

.pub-btn:active {
  transform: scale(0.94);
}

.icon-box {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  color: #fff;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-qa {
  background: linear-gradient(180deg, #eafcf5 0%, #d9f5ea 100%);
}
.btn-qa .icon-box {
  background: #18b777;
}
.btn-answer {
  background: linear-gradient(180deg, #f0f5ff 0%, #e0ebff 100%);
}
.btn-answer .icon-box {
  background: #3b82f6;
}
.btn-article {
  background: linear-gradient(180deg, #fffaf2 0%, #ffefd9 100%);
}
.btn-article .icon-box {
  background: #f59e0b;
}

/* ================= 打卡动效与粒子 ================= */
#checkinParticles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
}

.checkin-particle {
  position: absolute;
  will-change: transform, opacity;
}

.checkin-float-text {
  position: absolute;
  color: #07c160;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 6px rgba(7, 193, 96, 0.3);
  animation: floatUp 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes checkinPop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35) rotate(10deg);
  }
  70% {
    transform: scale(0.9) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.checkin-pop {
  animation: checkinPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -20px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80px) scale(1);
  }
}

/* ================= PC 端适配 ================= */
@media (min-width: 768px) {
  body {
    background-color: #f0f2f5;
    align-items: center;
    justify-content: center;
  }
.bottom-publish-bar{
    display:none;
}
  .app-wrapper {
    max-width: 640px;
    height: auto;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 20px;
  }

  .nav-bar {
    border-radius: 12px 12px 0 0;
    padding: 16px 24px;
  }

  .main-content {
    padding: 24px;
    max-height: calc(90vh - 60px);
  }

  .image-grid {
    gap: 12px;
  }
  .option-item:hover {
    background-color: #f9f9f9;
  }
  .image-item .btn-delete {
    opacity: 0;
    transition: opacity 0.2s;
  }
  .image-item:hover .btn-delete {
    opacity: 1;
  }

  .sheet-panel {
    top: 50%;
    left: 50%;
    bottom: auto;
    width: 500px;
    border-radius: 12px;
    transform: translate(-50%, -45%) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding-bottom: 0;
  }

  .sheet-panel.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
  }

  .action-sheet-group,
  .action-cancel {
    border-radius: 12px;
  }
  ::-webkit-scrollbar {
    width: 6px;
  }
  ::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* ================= 深色模式适配 ================= */
@media (prefers-color-scheme: dark) {
  .bottom-publish-bar {
    background: rgba(28, 28, 30, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }
  .pub-btn {
    color: #ffffff;
    box-shadow: none;
  }
  .btn-qa {
    background: rgba(24, 183, 119, 0.15);
  }
  .btn-answer {
    background: rgba(59, 130, 246, 0.15);
  }
  .btn-article {
    background: rgba(245, 158, 11, 0.15);
  }
  .drag-handle {
    background-color: #48484a;
  }
}
