/**
 * 天机命理 App Shell & Navigation Layout (app-shell.css)
 */

/* 页面整体布局容器 */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--color-bg);
  color: var(--color-text);
  box-sizing: border-box;
}

/* 顶部轻量栏 */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--top-bar-height);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-line);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-sm);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--font-size-lg);
  color: var(--color-brand-deep);
  letter-spacing: 0.5px;
  text-decoration: none;
  cursor: pointer;
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* 主内容工作区 */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4);
  box-sizing: border-box;
}

/* 移动端底部 5 栏固定导航 */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-line);
  z-index: var(--z-nav);
  box-shadow: 0 -2px 10px rgba(43, 39, 34, 0.05);
  box-sizing: border-box;
}

.mobile-nav-items {
  display: flex;
  height: 100%;
  width: 100%;
  justify-content: space-around;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: var(--space-1) 0;
  transition: color 0.15s ease;
  min-height: var(--touch-target);
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
}

.mobile-nav-item .nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.6;
}

.mobile-nav-item.active {
  color: var(--color-brand);
  font-weight: 700;
}

.mobile-nav-item.active .nav-icon {
  transform: scale(1.1);
  transition: transform 0.15s ease;
}

.mobile-nav-item .badge-dot {
  position: absolute;
  top: 6px;
  right: calc(50% - 12px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-brand);
  border: 1.5px solid var(--color-surface);
}

/* 命盘聚合底部抽屉 (Module Drawer) */
.module-drawer-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: var(--z-drawer);
  animation: fadeIn 0.2s ease-out;
}

.module-drawer-content {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4) calc(var(--space-6) + var(--safe-bottom));
  box-shadow: var(--shadow-drawer);
  z-index: calc(var(--z-drawer) + 1);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 80vh;
  overflow-y: auto;
}

.drawer-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  margin: 0 auto var(--space-4);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.drawer-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.drawer-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-2);
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--font-size-base);
  transition: all 0.15s ease;
  min-height: 72px;
  width: 100%;
  box-sizing: border-box;
}

.drawer-grid-item:active, .drawer-grid-item.active, .drawer-grid-item:focus {
  background: var(--color-accent-light);
  border-color: var(--color-accent-2);
  color: var(--color-accent-deep);
  font-weight: 700;
  outline: none;
}

.drawer-grid-item .item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-bottom: var(--space-2);
  color: var(--color-accent-deep, var(--accent, #9a7a3c));
}

.drawer-grid-item .item-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.6;
}

.drawer-grid-item .item-name {
  font-size: var(--font-size-sm);
}

/* 离线状态条 (默认必须隐藏) */
.offline-banner {
  display: none !important;
  background: var(--color-warning-bg);
  border-bottom: 1px solid var(--color-warning);
  color: var(--color-accent-deep);
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-4);
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  position: sticky;
  top: var(--top-bar-height);
  z-index: calc(var(--z-sticky) - 1);
}

.offline-banner.active {
  display: flex !important;
}

/* PWA 安装/更新提示横幅 (默认必须隐藏) */
.pwa-install-prompt, .pwa-update-prompt {
  display: none !important;
  background: var(--color-surface);
  border: 1px solid var(--color-accent-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-md);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.pwa-install-prompt.active, .pwa-update-prompt.active {
  display: flex !important;
}

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

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* 响应式断点控制 */
@media (max-width: 859px) {
  .mobile-bottom-nav {
    display: flex !important;
  }
  .tabbar, #tabbar {
    display: none !important;
  }
  .app-main {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
  }
  .desktop-nav-sidebar {
    display: none !important;
  }
}

@media (min-width: 860px) {
  .mobile-bottom-nav {
    display: none !important;
  }
  .module-drawer-backdrop {
    display: none !important;
  }
}
