@import "variables.css";

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding-bottom: calc(var(--nav-bottom-height) + env(safe-area-inset-bottom, 0px));
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}

input, textarea {
  border: none;
  outline: none;
  font-family: inherit;
}

/* 可访问性：键盘焦点可见 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 触摸友好的交互元素 */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.touch-target:active {
  transform: scale(0.95);
  opacity: 0.8;
  transition: transform 0.1s ease, opacity 0.1s ease;
}

/* 增强的导航按钮触摸热区 */
.nav-btn.touch-enhanced {
  min-height: 44px;
  min-width: 44px;
  padding: 4px;
}

.nav-btn.touch-enhanced:active {
  transform: scale(0.9);
  opacity: 0.7;
}

/* 通用触摸反馈 */
.touch-feedback {
  position: relative;
  overflow: hidden;
}

.touch-feedback::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.touch-feedback:active::before {
  width: 100px;
  height: 100px;
}

/* 可访问性焦点样式 */
:focus-visible {
  outline: 2px solid #d4af37;
  outline-offset: 2px;
  border-radius: 4px;
}

/* 顶部导航 */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--gradient-primary-solid);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--content-padding);
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.header-left {
  display: flex;
  align-items: center;
}

.logo {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  margin-right: 10px;
}

.title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: #fff;
}

.btn-login {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: var(--font-size-sm);
}

/* ========== 统一导航栏 ========== */
.unified-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: var(--navbar-bg);
  display: flex;
  align-items: center;
  padding: 0;
  padding-top: env(safe-area-inset-top, 0px);
  z-index: var(--navbar-z-index);
  box-shadow: var(--navbar-shadow);
}

.unified-navbar__left {
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.unified-navbar__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: var(--navbar-height);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--navbar-back-color);
  font-size: var(--navbar-back-size);
  line-height: 1;
}

.unified-navbar__back-icon {
  font-size: var(--navbar-back-size);
  font-weight: 300;
}

.unified-navbar__title {
  flex: 1;
  text-align: center;
  font-size: var(--navbar-title-size);
  font-weight: var(--navbar-title-weight);
  color: var(--navbar-title-color);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unified-navbar__right {
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.unified-navbar__action {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  font-size: var(--font-size-sm);
  color: var(--primary);
}

/* 渐变背景修饰符（BOSS页面等） */
.unified-navbar--gradient {
  background: var(--gradient-primary-solid);
  box-shadow: none;
}

.unified-navbar--gradient .unified-navbar__title,
.unified-navbar--gradient .unified-navbar__back,
.unified-navbar--gradient .unified-navbar__back-icon,
.unified-navbar--gradient .unified-navbar__action {
  color: #fff;
}

/* 透明背景修饰符 */
.unified-navbar--transparent {
  background: transparent;
  box-shadow: none;
}

/* Expert紫色主题修饰符 */
.unified-navbar--expert {
  --navbar-bg: #6366f1;
  --navbar-title-color: #fff;
  --navbar-back-color: #fff;
}

/* ========== 统一弹窗遮罩 ========== */
.unified-modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-mask-bg);
  z-index: var(--modal-z-index);
  opacity: 0;
  transition: opacity var(--modal-animation-duration) ease;
}

.unified-modal-mask.show {
  opacity: 1;
}

/* ========== 统一模态框 ========== */
.unified-modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: var(--bg-card);
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  z-index: calc(var(--modal-z-index) + 1);
  width: 280px;
  max-width: 90vw;
  opacity: 0;
  transition: all var(--modal-animation-duration) ease;
}

.unified-modal-content.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.unified-modal__header {
  padding: 20px 20px 10px;
  text-align: center;
}

.unified-modal__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.unified-modal__body {
  padding: 10px 20px 20px;
  text-align: center;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: 1.5;
}

.unified-modal__footer {
  display: flex;
  border-top: 1px solid var(--border-light);
}

.unified-modal__btn {
  flex: 1;
  padding: 14px 0;
  text-align: center;
  font-size: var(--font-size-base);
  background: none;
  border: none;
  cursor: pointer;
}

.unified-modal__btn--cancel {
  color: var(--text-secondary);
  border-right: 1px solid var(--border-light);
}

.unified-modal__btn--confirm {
  color: var(--primary);
  font-weight: var(--font-weight-medium);
}

/* ========== 统一操作面板 ========== */
.unified-action-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--modal-z-index) + 1);
  transform: translateY(100%);
  transition: transform var(--modal-animation-duration) ease;
}

.unified-action-sheet.show {
  transform: translateY(0);
}

.unified-action-sheet__panel {
  background: var(--bg-card);
  border-radius: var(--action-sheet-radius) var(--action-sheet-radius) 0 0;
  overflow: hidden;
}

.unified-action-sheet__title {
  padding: 16px;
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.unified-action-sheet__item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--action-sheet-item-height);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  width: 100%;
  cursor: pointer;
}

.unified-action-sheet__item:active {
  background: var(--bg-page);
}

.unified-action-sheet__cancel {
  margin-top: 8px;
  background: var(--bg-card);
}

.unified-action-sheet__cancel .unified-action-sheet__item {
  border-bottom: none;
  color: var(--text-secondary);
}

/* ========== 统一选择器面板 ========== */
.unified-picker {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--modal-z-index) + 1);
  transform: translateY(100%);
  transition: transform var(--modal-animation-duration) ease;
}

.unified-picker.show {
  transform: translateY(0);
}

.unified-picker__panel {
  background: var(--bg-card);
  border-radius: var(--action-sheet-radius) var(--action-sheet-radius) 0 0;
  overflow: hidden;
}

.unified-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

.unified-picker__cancel {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.unified-picker__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.unified-picker__confirm {
  font-size: var(--font-size-base);
  color: var(--primary);
  font-weight: var(--font-weight-medium);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.unified-picker__columns {
  display: flex;
  height: 200px;
  overflow: hidden;
}

.unified-picker__column {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory;
}

.unified-picker__option {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  scroll-snap-align: center;
  cursor: pointer;
}

.unified-picker__option.selected {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

/* ========== 统一空状态 ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state__icon {
  font-size: var(--empty-icon-size);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state__text {
  font-size: var(--empty-text-size);
  color: var(--empty-text-color);
  margin-bottom: 16px;
}

.empty-state__action {
  padding: 8px 24px;
  font-size: var(--font-size-sm);
}

/* 主要内容区域 */
.main-content {
  margin-top: var(--header-height);
  padding: var(--content-padding);
  min-height: calc(100vh - 110px);
}

/* 底部导航 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-bottom-height);
  background: var(--bg-card);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: var(--shadow-nav);
  z-index: 1000;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.3s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.nav-text {
  font-size: var(--font-size-xs);
}

/* 公共按钮样式 */
.btn-primary {
  background: var(--gradient-primary-solid);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  width: 100%;
  margin-top: var(--content-padding-lg);
}

.btn-primary:active {
  opacity: 0.8;
}

/* Toast提示 - 增强版 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 80vw;
  word-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Loading加载 - 增强版，防止滚动穿透 */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
}

.loading-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.loading-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  padding: var(--content-padding-lg);
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  min-width: 120px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(var(--primary-rgb), 0.3);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
  margin: 0 auto 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-content div {
  color: #333;
  font-size: 14px;
  font-weight: 500;
}

/* 添加到桌面提示 */
.install-prompt {
  position: fixed;
  bottom: 70px;
  left: 10px;
  right: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.prompt-content {
  display: flex;
  align-items: center;
  padding: 15px;
  position: relative;
}

.prompt-icon {
  font-size: 40px;
  margin-right: 15px;
}

.prompt-text {
  flex: 1;
}

.prompt-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 4px;
}

.prompt-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.btn-install {
  background: var(--primary);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: var(--font-size-sm);
  margin-right: 10px;
}

.btn-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  font-size: 24px;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* PWA 安装引导模态框 */
.install-guide-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.install-guide-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.install-guide-content {
  background: var(--bg-card);
  width: 85%;
  max-width: 320px;
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.install-guide-modal.show .install-guide-content {
  transform: scale(1);
}

.install-guide-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.install-guide-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.install-guide-steps {
  text-align: left;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.install-guide-step {
  display: flex;
  margin-bottom: 8px;
}

.install-guide-step-num {
  background: var(--primary);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-right: 10px;
  flex-shrink: 0;
  margin-top: 2px;
}

.install-guide-btn {
  background: var(--gradient-primary-solid);
  color: #fff;
  border: none;
  padding: 10px 0;
  width: 100%;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.install-guide-btn:active {
  opacity: 0.9;
}

/* ========== 统一卡片与容器 ========== */
/* 页面容器：限制最大宽度，居中，响应式内边距 */
.page-container {
  padding: 0 var(--content-padding);
}

/* 统一卡片样式 */
.page-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-md);
}

/* 卡片标题 */
.page-card__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* 卡片副标题 */
.page-card__subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 8px;
}

@media screen and (min-width: 768px) {
  .page-container {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 15px;
  }
}
