/* ============================================================
   智航统一布局样式 · 所有页面共用
   - 头部:fixed 顶部,logo + 标题 + 头像
   - 尾部:fixed 底部,5 tab(messages 支持红点)
   - 中部 .content 区:上下留白避开 header/tabbar
   - 登录对话框 / 头像下拉菜单 / 通知红点
   ============================================================ */

/* 外层容器 · 移动端居中 · 480px 最大宽 */
.app-wrapper {
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-bg);
}

/* ── 顶部固定头部 ── */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 56px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 1000;
}
.app-header-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}
.app-header-title {
  height: 28px;
  object-fit: contain;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
/* 页面标题文字 · 传 title 参数时替代 site-title 图 */
.app-header-page-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  z-index: 1001;
}
.app-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── 内容区 · 上下留白避开 fixed 条 ── */
.app-content {
  padding-top: 56px;
  padding-bottom: 80px;
  background: var(--color-bg);
  min-height: 100vh;
}

/* ── 底部固定导航 ── */
.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 64px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
}
.app-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  position: relative;
}
.app-tab-item img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  transition: opacity 0.15s ease;
}
.app-tab-item:active img {
  opacity: 0.6;
}

/* active tab · 顶部红色短横指示条 */
.app-tab-item.active::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-primary, #DC2626);
  animation: tabIndicatorIn 0.2s ease-out;
}
@keyframes tabIndicatorIn {
  from { width: 0; opacity: 0; }
  to   { width: 24px; opacity: 1; }
}

/* ── 通知红点(tabbar item 右上角) ── */
.app-tab-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #EF4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-sizing: border-box;
  box-shadow: 0 0 0 1.5px white;
  animation: badgePop 0.25s ease-out;
}
@keyframes badgePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
.app-tab-badge.dot {
  min-width: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  padding: 0;
  top: 6px;
  right: 10px;
  font-size: 0;
}

/* ── 登录提示弹框 ── */
.app-login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.app-login-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.app-login-dialog {
  background: white;
  border-radius: 12px;
  padding: 20px 18px 12px;
  width: 82%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transform: scale(0.92);
  transition: transform 0.2s;
}
.app-login-overlay.show .app-login-dialog {
  transform: scale(1);
}
.app-login-title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}
.app-login-text {
  font-size: 13px;
  color: #6B7280;
  margin-bottom: 16px;
  line-height: 1.5;
}
.app-login-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid #F3F4F6;
  padding-top: 10px;
  margin: 0 -18px -12px;
  padding-left: 18px;
  padding-right: 18px;
  padding-bottom: 10px;
}
.app-login-btn {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.app-login-btn:active { opacity: 0.8; }
.app-login-btn.cancel {
  background: #F3F4F6;
  color: #6B7280;
}
.app-login-btn.confirm {
  background: var(--color-primary, #DC2626);
  color: white;
}

/* ── 头像下拉菜单 ── */
.app-avatar-menu {
  position: fixed;
  top: 50px;          /* header 下方 */
  right: 10px;
  min-width: 170px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  z-index: 1999;
  opacity: 0;
  transform: translateY(-6px) scale(0.95);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.app-avatar-menu.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
/* 顶部三角箭头 · 指向头像 */
.app-avatar-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: white;
  transform: rotate(45deg);
  box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
}
.app-avatar-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13px;
  color: #1f2937;
  border-bottom: 1px solid #F3F4F6;
  transition: background 0.15s;
  position: relative;
  background: white;
}
.app-avatar-menu-item:first-child {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}
.app-avatar-menu-item:last-child {
  border-bottom: none;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}
.app-avatar-menu-item:active {
  background: #F9FAFB;
}
.app-avatar-menu-item .menu-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.app-avatar-menu-item.danger {
  color: var(--color-primary, #DC2626);
}

/* 点击外部关闭下拉菜单用的透明遮罩 */
.app-avatar-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1998;
  background: transparent;
  display: none;
}
.app-avatar-menu-backdrop.show {
  display: block;
}
