/* 应用主框架样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  background: #fff;
}

:root {
  --h5-app-height: 100vh;
}

@supports (height: 100dvh) {
  :root {
    --h5-app-height: 100dvh;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  color: #333;
  overflow: hidden;
  min-height: var(--h5-app-height);
  height: var(--h5-app-height);
}

/* 平板/PC 响应式：居中容器 */
.app-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: var(--h5-app-height);
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  padding-bottom: 0;
}

@media (min-width: 768px) {
  body {
    background: #d0d0d0;
  }
  .app-wrapper {
    max-width: 768px;
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
  }
}

@media (min-width: 1024px) {
  .app-wrapper {
    max-width: 430px;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 16px;
    margin-bottom: 16px;
    height: calc(var(--h5-app-height) - 32px);
    padding-bottom: 0;
  }
  .app-header {
    border-radius: 12px 12px 0 0;
  }
}

/* 顶部导航栏 */
.app-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #fff;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-left {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1002;
}

.header-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1002;
}

.header-center {
  position: absolute;
  left: 10px;
  right: 102px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* Exit按钮 */
.exit-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}

.exit-btn .arrow {
  font-size: 20px;
  line-height: 1;
}

.shell-back-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.96);
  color: #333;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
}

.shell-back-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.has-shell-back .shell-back-btn {
  display: flex;
}

body.has-shell-back .header-center {
  left: 64px;
}

/* 片区选择器 */
.district-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  padding: 4px 6px;
  background: transparent;
  border-radius: 0;
  cursor: pointer;
  font-weight: 800;
  font-size: 21px;
  line-height: 1;
  color: #121212;
  letter-spacing: 0;
  white-space: nowrap;
}

.district-selector #currentDistrict {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.district-pin-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  color: #12bdae;
}

.district-pin-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.district-selector .dropdown-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: #111;
}

.district-selector .dropdown-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.district-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 160px;
  display: none;
  overflow: hidden;
  z-index: 1001;
}

.district-menu.show {
  display: block;
}

.district-item {
  padding: 12px 16px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: background 0.2s;
}

.district-item:hover,
.district-item.active {
  background: #f0f0f0;
}

/* 下拉菜单分隔线 */
.district-menu-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}

/* 返回城市选择选项 */
.district-item.district-return {
  color: #666;
  font-style: italic;
}

.district-item.district-return:hover {
  background: #f5f5f5;
  color: #333;
}

/* 页面标题 */
.page-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

/* 语言选择器 */
.lang-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #e8f5f3;
  border-radius: 16px;
  cursor: pointer;
  color: #3CBAA8;
  font-size: 14px;
  font-weight: 500;
  float: right;
  direction: ltr;
  max-width: 112px;
  white-space: nowrap;
}

.lang-selector .dropdown-arrow {
  font-size: 10px;
}

.lang-current {
  unicode-bidi: plaintext;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 120px;
  display: none;
  overflow: hidden;
  z-index: 1001;
}

.lang-menu.show {
  display: block;
}

.lang-item {
  padding: 10px 14px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: background 0.2s;
  direction: ltr;
  text-align: center;
  unicode-bidi: plaintext;
}

.lang-item:hover {
  background: #f0f0f0;
}

/* 主体内容区域 */
.app-main {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  bottom: calc(60px + env(safe-area-inset-bottom, 0));
  overflow: hidden;
  background: #fff;
}

body.app-page-discover .home-cart-fab-parent {
  display: none;
}

body.app-page-my .app-header {
  display: none;
}

body.app-page-my .app-main {
  top: 0;
}

body.app-page-my .home-cart-fab-parent {
  display: none;
}

body.app-page-community .app-header {
  display: none;
}

body.app-page-community .app-main {
  top: 0;
}

body.app-page-community .home-cart-fab-parent {
  display: none;
}

.app-main iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #fff;
}

/* 底部导航栏 */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: #fff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 -8px 22px rgba(35, 51, 63, 0.08);
  overflow: visible;
}

@supports (-webkit-touch-callout: none) {
  body.h5-input-focused .app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
  }

  body.h5-input-focused .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }
}

/* 平板/PC 响应式：底部导航栏居中 */
@media (min-width: 768px) {
  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 768px;
  }
}

@media (min-width: 1024px) {
  .bottom-nav {
    max-width: 430px;
    border-radius: 0 0 12px 12px;
    bottom: 0;
  }
}

/* 导航项 */
.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex: 1;
  height: 60px;
  cursor: pointer;
  transition: all 0.3s ease;
}

/* 图标容器 */
.nav-icon-wrapper {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  margin-bottom: 2px;
}

.nav-icon {
  width: 26px;
  height: 26px;
  color: #8f8b85;
  transition: all 0.3s ease;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

/* 文字 */
.nav-text {
  font-size: 11px;
  color: #8f8b85;
  font-weight: 600;
  transition: all 0.3s ease;
}

/* 选中状态 - 凹陷效果 */
.nav-item.active .nav-icon-wrapper {
  background: transparent;
  box-shadow: none;
  transform: none;
  width: 34px;
  height: 34px;
}

.nav-item.active .nav-icon {
  color: #12bdae;
  filter: none;
}

.nav-item.active .nav-text {
  color: #12bdae;
  font-weight: 700;
}

.nav-item-primary .nav-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: transparent;
  box-shadow: 0 4px 12px rgba(18, 189, 174, 0.35);
  margin-top: -14px;
  margin-bottom: -4px;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.nav-item-primary {
  z-index: 10;
}

.nav-item-primary.active .nav-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: transparent;
  box-shadow: 0 4px 12px rgba(18, 189, 174, 0.35);
  transform: none;
  margin-top: -14px;
  margin-bottom: -4px;
}

.nav-item-primary .nav-icon-my-default {
  display: none;
}

.nav-item-primary .nav-icon-my-active {
  display: block;
  width: 52px !important;
  height: 52px !important;
  border-radius: 18px;
  overflow: hidden;
  background: #55beb2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.nav-item-primary .nav-icon-my-active img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 18px;
  background: #55beb2;
}

.nav-item-primary .nav-text {
  color: #12bdae;
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
}

/* 悬停效果 */
.nav-item:hover .nav-icon-wrapper {
  background: rgba(18, 189, 174, 0.08);
}

.nav-item.active:hover .nav-icon-wrapper {
  background: transparent;
}

.nav-item-primary:hover .nav-icon-wrapper,
.nav-item-primary.active:hover .nav-icon-wrapper {
  background: transparent;
}

.home-cart-fab-parent {
  position: absolute;
  right: 20px;
  bottom: calc(64px + env(safe-area-inset-bottom, 0));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #11c2b1;
  color: #fff;
  z-index: 1002;
  box-shadow: 0 7px 18px rgba(18, 189, 174, 0.32);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.home-cart-fab-parent svg {
  width: 28px;
  height: 28px;
}

.home-cart-badge-parent {
  position: absolute;
  top: -2px;
  right: -1px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ff5a69;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
}

/* 响应式适配 */
@media (max-width: 375px) {
  .header-center {
    right: 96px;
  }

  .district-selector {
    gap: 4px;
    font-size: 19px;
    padding: 4px;
  }

  .district-pin-icon {
    width: 24px;
    height: 24px;
  }

  .district-selector .dropdown-arrow {
    width: 18px;
    height: 18px;
  }
}

/* 父页面分享层（手机必须在顶层点击才能唤起系统分享） */
.parent-share-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20000;
  align-items: flex-end;
  justify-content: center;
}
.parent-share-panel.show {
  display: flex;
}
.parent-share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.parent-share-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 500px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 0));
  animation: parentShareSlideUp 0.25s ease-out;
}
@keyframes parentShareSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.parent-share-title {
  font-size: 17px;
  font-weight: 600;
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 6px;
}
.parent-share-subtitle {
  font-size: 13px;
  color: #999;
  text-align: center;
  margin-bottom: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parent-share-hint {
  font-size: 12px;
  color: #996600;
  background: #fff8e6;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  line-height: 1.45;
  text-align: center;
  display: none;
}
.parent-share-hint.show {
  display: block;
}
.parent-share-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}
.parent-share-btn.primary {
  background: #3CBAA8;
  color: #fff;
  font-weight: 600;
}
.parent-share-btn.secondary {
  background: #f0f9f7;
  color: #3CBAA8;
}
.parent-share-btn.ghost {
  background: #f5f5f5;
  color: #666;
}

html[dir="rtl"] body,
html[dir="rtl"] .app-wrapper,
html[dir="rtl"] .app-header,
html[dir="rtl"] .app-main,
html[dir="rtl"] .bottom-nav {
  direction: ltr;
}

html[dir="rtl"] .header-left {
  left: 16px;
  right: auto;
}

html[dir="rtl"] .header-right {
  right: 16px;
  left: auto;
}

html[dir="rtl"] .lang-selector {
  float: right;
  direction: ltr;
}

html[dir="rtl"] .lang-menu {
  right: 0;
  left: auto;
  direction: ltr;
}

html[dir="rtl"] .district-selector {
  flex-direction: row;
  direction: rtl;
}

html[dir="rtl"] .page-title,
html[dir="rtl"] .nav-text,
html[dir="rtl"] .district-menu {
  direction: rtl;
}

html[dir="rtl"] .bottom-nav {
  left: 0;
  right: 0;
  width: 100%;
  transform: none;
}

html[dir="rtl"] .nav-item {
  direction: rtl;
}

@media (min-width: 768px) {
  html[dir="rtl"] .bottom-nav {
    left: 0;
    right: 0;
    transform: none;
  }
}
