/**
 * Feature Overlay - 统一功能遮罩弹窗组件
 *
 * 用途：替代分散的功能墙实现（FeatureWall.showUpgradeDialog, NetworkQualityFeatureWall, global-license-reminder）
 * 复用：feature-wall.css 的配色变量、毛玻璃效果、动画
 * 特性：焦点陷阱、键盘导航、30天免打扰、响应式布局
 */

/* ========== 容器与遮罩 ========== */

.feature-overlay {
  position: fixed;
  inset: 0;
  z-index: 60; /* 高于 feature-wall 的 50 */
  display: none; /* 默认隐藏 */
}

.feature-overlay:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* 背景遮罩（毛玻璃效果）*/
.feature-overlay__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: opacity 0.3s ease;
}

/* ========== 主面板 ========== */

.feature-overlay__panel {
  position: relative;
  max-width: 28rem;
  width: 100%;
  background-color: white;
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 2rem;
  transform: scale(0.96) translateY(8px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none; /* 移除默认焦点样式，通过自定义样式处理 */
}

/* 深色模式 */
.dark .feature-overlay__panel {
  background-color: rgb(30 41 59); /* slate-800 */
}

/* 显示动画 */
.feature-overlay:not(.hidden) .feature-overlay__panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* 焦点状态（键盘导航）*/
.feature-overlay__panel:focus-visible {
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04),
    0 0 0 3px rgba(251, 191, 36, 0.5); /* 琥珀色焦点环 */
}

/* ========== 关闭按钮 ========== */

.feature-overlay__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  color: rgb(156 163 175); /* gray-400 */
  cursor: pointer;
  transition: all 0.2s;
  z-index: 1;
}

.feature-overlay__close:hover {
  color: rgb(107 114 128); /* gray-500 */
  background-color: rgb(249 250 251); /* gray-50 */
}

.dark .feature-overlay__close:hover {
  color: rgb(209 213 219); /* gray-300 */
  background-color: rgb(51 65 85); /* slate-700 */
}

.feature-overlay__close:focus-visible {
  outline: 2px solid rgb(251 191 36); /* amber-500 */
  outline-offset: 2px;
}

/* ========== 头部：图标 + 标题 + 副标题 ========== */

.feature-overlay__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.5rem;
}

/* 图标（渐变圆形背景 + 星星图标）*/
.feature-overlay__icon {
  width: 4rem;
  height: 4rem;
  background: linear-gradient(135deg, rgb(251 191 36), rgb(249 115 22)); /* amber-500 → orange-600 */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 10px 15px -3px rgba(251, 191, 36, 0.3);
}

.feature-overlay__icon i {
  color: white;
  font-size: 1.5rem; /* 24px */
}

/* 标题 */
.feature-overlay__title {
  font-size: 1.5rem; /* 24px */
  font-weight: 700;
  color: rgb(17 24 39); /* gray-900 */
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
}

.dark .feature-overlay__title {
  color: white;
}

/* 副标题（需要的套餐等）*/
.feature-overlay__subtitle {
  font-size: 0.875rem; /* 14px */
  color: rgb(107 114 128); /* gray-500 */
  margin: 0;
  line-height: 1.5;
}

.dark .feature-overlay__subtitle {
  color: rgb(156 163 175); /* gray-400 */
}

/* ========== 内容区（功能说明）========== */

.feature-overlay__content {
  background-color: rgb(249 250 251); /* gray-50 */
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem; /* 14px */
  color: rgb(55 65 81); /* gray-700 */
  line-height: 1.6;
}

.dark .feature-overlay__content {
  background-color: rgb(51 65 85 / 0.5); /* slate-700 半透明 */
  color: rgb(209 213 219); /* gray-300 */
}

/* 内容为空时隐藏 */
.feature-overlay__content:empty {
  display: none;
  margin: 0;
  padding: 0;
}

/* ========== 操作按钮组 ========== */

.feature-overlay__actions {
  display: flex;
  gap: 0.75rem;
  flex-direction: column; /* 移动端默认垂直 */
}

/* 中等屏幕及以上：水平布局 */
@media (min-width: 640px) {
  .feature-overlay__actions {
    flex-direction: row;
  }
}

/* 按钮基础样式 */
.feature-overlay__btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem; /* 14px */
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

.feature-overlay__btn i {
  font-size: 1rem; /* 16px，图标稍大 */
}

/* 次要按钮（30天不提醒）*/
.feature-overlay__btn--secondary {
  background-color: rgb(243 244 246); /* gray-100 */
  color: rgb(55 65 81); /* gray-700 */
  border: 1px solid rgb(229 231 235); /* gray-200 */
}

.feature-overlay__btn--secondary:hover {
  background-color: rgb(229 231 235); /* gray-200 */
  color: rgb(17 24 39); /* gray-900 */
}

.dark .feature-overlay__btn--secondary {
  background-color: rgb(51 65 85); /* slate-700 */
  color: rgb(209 213 219); /* gray-300 */
  border-color: rgb(71 85 105); /* slate-600 */
}

.dark .feature-overlay__btn--secondary:hover {
  background-color: rgb(71 85 105); /* slate-600 */
  color: white;
}

/* 主要按钮（立即升级）*/
.feature-overlay__btn--primary {
  background: linear-gradient(135deg, rgb(251 191 36), rgb(249 115 22)); /* amber-500 → orange-600 */
  color: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.feature-overlay__btn--primary:hover {
  background: linear-gradient(135deg, rgb(245 158 11), rgb(234 88 12)); /* amber-600 → orange-700 */
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.feature-overlay__btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* 焦点状态（键盘导航）*/
.feature-overlay__btn:focus-visible {
  outline: 2px solid rgb(251 191 36); /* amber-500 */
  outline-offset: 2px;
}

/* ========== 响应式优化 ========== */

/* 移动端优化 */
@media (max-width: 640px) {
  .feature-overlay__panel {
    max-width: calc(100vw - 2rem);
    padding: 1.5rem;
  }

  .feature-overlay__icon {
    width: 3.5rem;
    height: 3.5rem;
  }

  .feature-overlay__icon i {
    font-size: 1.25rem; /* 20px */
  }

  .feature-overlay__title {
    font-size: 1.25rem; /* 20px */
  }

  .feature-overlay__btn {
    padding: 0.625rem 1rem;
  }
}

/* 超小屏幕（<400px）*/
@media (max-width: 400px) {
  .feature-overlay {
    padding: 0.5rem;
  }

  .feature-overlay__panel {
    padding: 1.25rem;
  }

  .feature-overlay__header {
    margin-bottom: 1rem;
  }

  .feature-overlay__content {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  .feature-overlay__actions {
    gap: 0.5rem;
  }
}

/* ========== 打印样式 ========== */

@media print {
  .feature-overlay {
    display: none !important;
  }
}

/* ========== 可访问性增强 ========== */

/* 减少动画（用户偏好设置）*/
@media (prefers-reduced-motion: reduce) {
  .feature-overlay__panel,
  .feature-overlay__backdrop,
  .feature-overlay__btn {
    transition: none;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .feature-overlay__panel {
    border: 2px solid currentColor;
  }

  .feature-overlay__btn--secondary {
    border-width: 2px;
  }
}
