/* ============================================================
   style.css - 邻里和信息交换平台样式
   配色：主色 #FF6B35（活力橙），辅色 #004E89（深蓝）
   ============================================================ */

/* ========== 重置与基础 ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  border: none;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  -webkit-appearance: none;
}

/* ========== 布局容器 ========== */
#app {
  max-width: 750px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: #f5f5f5;
}

/* ========== 页面视图 ========== */
.view {
  display: none;
  padding-bottom: 70px; /* 为底部导航留空间 */
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* ========== 顶部导航栏 ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #FF6B35;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.header-title {
  font-size: 1.125rem;
  font-weight: 600;
  white-space: nowrap;
}

.header-back {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.header-back:active {
  background: rgba(255, 255, 255, 0.3);
}

.header-action {
  font-size: 0.875rem;
  padding: 4px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.header-action:active {
  background: rgba(255, 255, 255, 0.3);
}

/* ========== 首页搜索栏 ========== */
.search-bar {
  padding: 10px 16px;
  background: #FF6B35;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 20px;
  padding: 8px 14px;
  gap: 8px;
}

.search-icon {
  color: #999;
  font-size: 1rem;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  color: #333;
  line-height: 1.4;
}

.search-input::placeholder {
  color: #bbb;
}

.search-clear {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ddd;
  color: #fff;
  font-size: 0.7rem;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-clear.visible {
  display: flex;
}

/* ========== 分类标签 ========== */
.category-tabs {
  display: flex;
  overflow-x: auto;
  padding: 10px 16px;
  gap: 8px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 16px;
  background: #f0f0f0;
  color: #666;
  font-size: 0.8125rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.category-tab.active {
  background: #FF6B35;
  color: #fff;
}

.category-tab:active {
  opacity: 0.8;
}

/* ========== 类型切换 ========== */
.type-tabs {
  display: flex;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.type-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 0.9375rem;
  color: #999;
  position: relative;
  transition: color 0.2s;
}

.type-tab.active {
  color: #FF6B35;
  font-weight: 600;
}

.type-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: #FF6B35;
}

/* ========== 物品卡片列表 ========== */
.item-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.item-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.item-card-body {
  display: flex;
  padding: 12px;
  gap: 12px;
}

.item-card-image {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f0f0f0;
}

.item-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.item-card-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card-desc {
  font-size: 0.8125rem;
  color: #999;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
}

.item-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.item-card-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.6875rem;
  font-weight: 500;
}

.item-card-type.exchange {
  background: rgba(255, 107, 53, 0.1);
  color: #FF6B35;
}

.item-card-type.request {
  background: rgba(0, 78, 137, 0.1);
  color: #004E89;
}

.item-card-time {
  font-size: 0.75rem;
  color: #bbb;
}

.item-card-category {
  font-size: 0.6875rem;
  color: #999;
  margin-top: 4px;
}

/* ========== 需求卡片（无图样式） ========== */
.item-card-no-image .item-card-body {
  flex-direction: column;
  gap: 6px;
}

.item-card-no-image .item-card-title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-card-no-image .item-card-desc {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #ccc;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 0.9375rem;
  color: #999;
}

/* ========== 详情页 ========== */
.detail-carousel {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #000;
}

.carousel-track {
  display: flex;
  transition: transform 0.3s ease;
}

.carousel-slide {
  min-width: 100%;
  height: 300px;
  object-fit: contain;
  background: #000;
}

.carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.4);
  transition: all 0.3s;
}

.carousel-dot.active {
  background: #fff;
  width: 16px;
}

.detail-content {
  padding: 16px;
  background: #fff;
}

.detail-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.detail-type-badge.exchange {
  background: rgba(255, 107, 53, 0.1);
  color: #FF6B35;
}

.detail-type-badge.request {
  background: rgba(0, 78, 137, 0.1);
  color: #004E89;
}

.detail-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.detail-category {
  font-size: 0.8125rem;
  color: #999;
  margin-bottom: 12px;
}

.detail-desc {
  font-size: 0.9375rem;
  color: #555;
  line-height: 1.7;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.detail-wanted {
  background: #FFF8F4;
  border-left: 3px solid #FF6B35;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 16px;
}

.detail-wanted-label {
  font-size: 0.75rem;
  color: #FF6B35;
  font-weight: 500;
  margin-bottom: 4px;
}

.detail-wanted-text {
  font-size: 0.875rem;
  color: #666;
}

.detail-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid #f0f0f0;
  margin-top: 8px;
}

.detail-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #004E89;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.detail-user-name {
  font-size: 0.875rem;
  color: #333;
}

.detail-user-time {
  font-size: 0.75rem;
  color: #bbb;
}

/* 底部操作栏 */
.detail-actions {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: 10px 16px;
  display: flex;
  gap: 10px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.btn-contact {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: center;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-contact:active {
  opacity: 0.8;
}

.btn-contact.wechat {
  background: #07C160;
  color: #fff;
}

.btn-contact.phone {
  background: #004E89;
  color: #fff;
}

.btn-report {
  width: 48px;
  height: 44px;
  border-radius: 10px;
  background: #f5f5f5;
  color: #999;
  font-size: 0.6875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
}

.btn-report:active {
  background: #eee;
}

.btn-report-icon {
  font-size: 1rem;
}

/* ========== 发布页 ========== */
.publish-type-switch {
  display: flex;
  background: #fff;
  margin: 12px 16px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.publish-type-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 0.9375rem;
  color: #666;
  background: #fff;
  transition: all 0.2s;
  border: none;
}

.publish-type-btn.active {
  background: #FF6B35;
  color: #fff;
  font-weight: 500;
}

.publish-type-btn:active {
  opacity: 0.9;
}

.publish-form {
  padding: 0 16px 16px;
}

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

.form-label {
  display: block;
  font-size: 0.875rem;
  color: #555;
  margin-bottom: 6px;
  font-weight: 500;
}

.form-label .required {
  color: #FF6B35;
  margin-left: 2px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 0.9375rem;
  color: #333;
  background: #fff;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: #FF6B35;
}

.form-input::placeholder {
  color: #bbb;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 0.9375rem;
  color: #333;
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-select:focus {
  border-color: #FF6B35;
}

/* 图片上传区域 */
.image-upload-area {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-upload-item {
  width: 90px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.image-upload-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-upload-add {
  width: 90px;
  height: 90px;
  border: 2px dashed #ddd;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 0.75rem;
  gap: 4px;
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.2s;
}

.image-upload-add:active {
  border-color: #FF6B35;
}

.image-upload-add-icon {
  font-size: 1.5rem;
  line-height: 1;
}

/* 联系方式选择 */
.contact-type-switch {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.contact-type-btn {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  text-align: center;
  font-size: 0.8125rem;
  color: #666;
  background: #fff;
  transition: all 0.2s;
}

.contact-type-btn.active {
  border-color: #FF6B35;
  color: #FF6B35;
  background: #FFF8F4;
}

.contact-type-btn:active {
  opacity: 0.8;
}

/* 提交按钮 */
.btn-submit {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: #FF6B35;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 10px;
  transition: opacity 0.2s;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.btn-submit:active {
  opacity: 0.85;
}

.btn-submit:disabled {
  background: #ddd;
  box-shadow: none;
  cursor: not-allowed;
}

/* ========== 我的页面 ========== */
.profile-header {
  background: linear-gradient(135deg, #FF6B35, #FF8F65);
  padding: 30px 20px 24px;
  color: #fff;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.profile-name {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-desc {
  font-size: 0.8125rem;
  opacity: 0.8;
}

.profile-edit-btn {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.75rem;
  margin-top: 8px;
}

.profile-edit-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

.profile-stats {
  display: flex;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
}

.profile-stat {
  flex: 1;
  text-align: center;
}

.profile-stat-num {
  font-size: 1.25rem;
  font-weight: 600;
  color: #FF6B35;
}

.profile-stat-label {
  font-size: 0.75rem;
  color: #999;
  margin-top: 2px;
}

/* 我的物品列表 */
.my-section-title {
  padding: 14px 16px 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #333;
  background: #fff;
}

.my-item-card {
  display: flex;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #f5f5f5;
  gap: 12px;
  align-items: center;
}

.my-item-image {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f0f0f0;
}

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

.my-item-title {
  font-size: 0.9375rem;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-item-meta {
  font-size: 0.75rem;
  color: #bbb;
  margin-top: 4px;
}

.my-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.my-item-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.my-item-btn.edit {
  background: #e8f4ff;
  color: #004E89;
}

.my-item-btn.delete {
  background: #fff0f0;
  color: #e74c3c;
}

.my-item-btn:active {
  opacity: 0.7;
}

/* 用户身份设置弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 360px;
  padding: 24px;
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 20px;
  color: #333;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #999;
}

/* ========== 底部导航 ========== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 750px;
  margin: 0 auto;
  background: #fff;
  display: flex;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  color: #999;
  font-size: 0.6875rem;
  gap: 2px;
  transition: color 0.2s;
  background: none;
  border: none;
}

.tab-item.active {
  color: #FF6B35;
}

.tab-item:active {
  opacity: 0.7;
}

.tab-item-icon {
  font-size: 1.375rem;
  line-height: 1;
}

.tab-item-label {
  font-size: 0.6875rem;
}

/* 发布按钮特殊样式 */
.tab-item.publish-tab .tab-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FF6B35;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-top: -18px;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.35);
}

.tab-item.publish-tab.active .tab-item-icon {
  background: #FF6B35;
  color: #fff;
}

/* ========== Toast ========== */
#toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
}

.toast-item {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.875rem;
  text-align: center;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s ease;
  margin-bottom: 8px;
}

.toast-item.toast-show {
  opacity: 1;
  transform: scale(1);
}

.toast-item.toast-hide {
  opacity: 0;
  transform: scale(0.8);
}

/* ========== 下拉刷新提示 ========== */
.pull-refresh-tip {
  text-align: center;
  padding: 10px;
  color: #bbb;
  font-size: 0.8125rem;
  display: none;
}

.pull-refresh-tip.visible {
  display: block;
}

/* ========== 编辑页特有 ========== */
.edit-header-save {
  font-size: 0.9375rem;
  color: #FF6B35;
  font-weight: 600;
  padding: 4px 8px;
  background: none;
}

/* ========== 安全区域适配 ========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .tab-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .view {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
}

/* ========== 微信内置浏览器兼容 ========== */
body {
  -webkit-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-user-select: auto;
  user-select: auto;
}

/* ========== 动画 ========== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.view.active {
  animation: fadeIn 0.2s ease;
}
