/* ============================================
   人脸智能分析 - 自定义样式
   Face Analysis - Custom Styles
   ============================================ */

/* ---------- 全局基础 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ---------- 上传区域拖拽动效 ---------- */
#uploadArea.drag-over {
  border-color: rgba(99, 102, 241, 0.6) !important;
  background: rgba(99, 102, 241, 0.08) !important;
  transform: scale(1.02);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.15);
}

#uploadArea.drag-over #uploadIcon div {
  background: rgba(99, 102, 241, 0.3) !important;
  animation: bounce 0.6s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------- 按钮统一样式 ---------- */
.btn-action {
  border-radius: 14px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  /* 移动端最小触摸目标 44x44px */
  min-height: 44px;
  min-width: 44px;
}
.btn-action:hover:not(:disabled) {
  transform: scale(1.04);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.btn-action:active:not(:disabled) {
  transform: scale(0.96);
}

/* 按钮禁用态：去饱和度 + 低透明度 */
button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  filter: saturate(0.3);
}

/* ---------- 报告卡片统一风格 ---------- */
.report-card {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  -webkit-user-select: none;
  user-select: none;
}

.report-card:last-child {
  margin-bottom: 0;
}

/* hover 高亮效果 */
.report-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.12), 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

/* 综合评价卡片特殊高亮 */
.report-card-highlight {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.15);
}
.report-card-highlight:hover {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.18), 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 人脸检测信息卡片（缩小版） */
.report-card-mini {
  padding: 12px 14px;
  margin-top: 6px;
  opacity: 0.75;
}
.report-card-mini:hover {
  opacity: 1;
}

/* ---------- 卡片标题行 ---------- */
.report-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 0;
}

.report-card-title-sm {
  font-size: 11px;
  margin-bottom: 8px;
  color: #94a3b8;
}

.report-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

/* 卡片头部：图标+标题 左对齐，badge 右对齐 */
.report-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.report-card-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ---------- 进度条统一样式（加粗 + 醒目） ---------- */
.progress-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.progress-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 1s ease-out;
}

/* 各主题色进度条 */
.amber-bar {
  background: linear-gradient(90deg, #f59e0b, #f97316);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
}
.blue-bar {
  background: linear-gradient(90deg, #60a5fa, #34d399);
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.3);
}
.pink-bar {
  background: linear-gradient(90deg, #ec4899, #a855f7);
  box-shadow: 0 0 8px rgba(236, 72, 153, 0.3);
}
.emerald-bar {
  background: linear-gradient(90deg, #34d399, #14b8a6);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.3);
}
.teal-bar {
  background: linear-gradient(90deg, #2dd4bf, #14b8a6);
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.3);
}

.progress-bar-num {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 40px;
  text-align: right;
}

/* ---------- 情绪模块：双情绪展示 ---------- */
.emotion-primary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.emotion-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.emotion-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.6;
  margin-top: 4px;
}

/* ---------- 皮肤建议区 ---------- */
.skin-advice {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(45, 212, 191, 0.06);
  border-radius: 8px;
  border: 1px solid rgba(45, 212, 191, 0.1);
  font-size: 11px;
  color: #99f6e4;
  line-height: 1.6;
}

/* ---------- 多人脸切换控件 ---------- */
.face-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.face-switch-tabs {
  flex: 1;
  display: flex;
  gap: 4px;
  justify-content: center;
}

.face-switch-tab {
  padding: 4px 14px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.face-switch-tab:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
}

.face-switch-tab.active {
  color: #fff;
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.4);
  font-weight: 600;
}

.face-switch-arrow {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.face-switch-arrow:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ---------- 文字内容区（左对齐 + 行高放大） ---------- */
.text-content {
  font-size: 12px;
  line-height: 1.8;
  color: #cbd5e1;
  text-align: left;
  white-space: pre-line;
}

/* ---------- 人脸检测信息网格 ---------- */
.face-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.face-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

/* ---------- 人脸检测失败提示 ---------- */
.face-detect-error {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 10px;
  font-size: 12px;
  color: #fca5a5;
}
.face-detect-error.show {
  display: flex;
}
.face-detect-error i {
  color: #f87171;
  flex-shrink: 0;
}

/* ---------- 加载遮罩 ---------- */
#loadingOverlay .animate-spin {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 动画关键帧 ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* 分析进度条动画 */
@keyframes progressIndeterminate {
  0% { width: 0%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

.animate-progress-bar {
  animation: progressIndeterminate 2s ease-in-out infinite;
}

/* ---------- 星级评分 ---------- */
.star-rating {
  display: inline-flex;
  gap: 2px;
}

.star-rating .star {
  font-size: 11px;
  color: #4b5563;
  transition: color 0.3s ease, transform 0.3s ease;
}

.star-rating .star.filled {
  color: #f59e0b;
  text-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.star-rating .star.half {
  position: relative;
  color: #4b5563;
}

.star-rating .star.half::before {
  content: '\f005';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  overflow: hidden;
  color: #f59e0b;
  text-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

/* 星级依次亮起动画 */
.star-rating.animate .star.filled {
  animation: starPop 0.3s ease forwards;
  animation-delay: var(--star-delay, 0s);
  opacity: 0;
}

@keyframes starPop {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  70% {
    transform: scale(1.3);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- Toast 通知 ---------- */
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

#toast.error {
  background: rgba(239, 68, 68, 0.9) !important;
}

#toast.success {
  background: rgba(16, 185, 129, 0.9) !important;
}

#toast.warning {
  background: rgba(245, 158, 11, 0.9) !important;
}

/* ---------- 选中/聚焦样式 ---------- */
button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
}

/* ---------- 摄像头预览翻转（镜像效果） ---------- */
#cameraPreview {
  transform: scaleX(-1);
}

/* ---------- 响应式调整 ---------- */

/* 平板横屏及以下：取消 sticky */
@media (max-width: 1024px) {
  .md\:sticky {
    position: relative !important;
    top: 0 !important;
  }

  .report-card {
    margin-bottom: 10px;
    padding: 14px;
  }

  /* 主布局在平板竖屏时保持双栏但缩小间距 */
  .grid {
    gap: 1rem;
  }

  /* 上传区域在平板缩小内边距 */
  #uploadArea {
    padding: 1.25rem;
    min-height: 180px;
  }

  /* 按钮组在平板缩小 */
  .btn-action {
    padding: 0.65rem 0.85rem !important;
    font-size: 0.8rem !important;
  }
}

/* 平板竖屏 (≤768px)：强制单栏布局 */
@media (max-width: 768px) {
  /* 导航栏紧凑 */
  header .h-16 {
    height: 3.25rem;
  }

  header h1 {
    font-size: 0.85rem;
  }

  header .w-10.h-10 {
    width: 2rem;
    height: 2rem;
  }

  header .w-10.h-10 i {
    font-size: 0.85rem !important;
  }

  /* 顶部间距缩小 */
  main.pt-20 {
    padding-top: 4rem;
  }

  /* 副标题缩小 */
  .text-center.mb-6 p {
    font-size: 0.75rem;
    padding: 0 0.5rem;
  }

  /* 上传区域缩小 */
  #uploadArea {
    padding: 1.25rem 0.75rem;
    min-height: 160px;
    border-radius: 14px;
  }

  #uploadIcon .w-16 {
    width: 3rem;
    height: 3rem;
  }
  #uploadIcon i {
    font-size: 1.5rem !important;
  }

  /* 按钮组换行 + 缩小 */
  .flex.flex-wrap.gap-3.mt-4 {
    gap: 0.5rem;
    margin-top: 0.75rem;
  }

  .btn-action {
    padding: 0.55rem 0.7rem !important;
    font-size: 0.72rem !important;
    border-radius: 10px !important;
    min-width: 80px !important;
  }

  #analyzeBtn {
    min-width: 100px !important;
  }

  /* 提示卡片文字缩小 */
  .grid.grid-cols-1.sm\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 0.5rem;
  }

  /* 结果面板 */
  .report-card {
    margin-bottom: 8px;
    padding: 12px;
    border-radius: 12px;
  }

  .report-card-title {
    font-size: 11px;
  }

  .report-card-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .text-content {
    font-size: 11px;
    line-height: 1.7;
  }

  /* 星级缩小 */
  .star-rating .star {
    font-size: 10px;
  }

  /* 进度条缩小 */
  .progress-bar-track {
    height: 6px;
  }

  /* 情绪主emoji缩小 */
  .emotion-primary .text-4xl {
    font-size: 1.5rem !important;
  }

  /* 人脸检测信息网格单列 */
  .face-info-grid {
    grid-template-columns: 1fr;
    gap: 2px 8px;
  }

  /* 多人脸切换控件缩小 */
  .face-switcher {
    gap: 3px;
    padding: 4px;
  }

  .face-switch-tab {
    padding: 3px 8px;
    font-size: 10px;
  }

  .face-switch-arrow {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }

  /* 页脚缩小 */
  footer {
    padding: 0.75rem 0.5rem;
  }
  footer p, footer span {
    font-size: 0.65rem !important;
  }
}

/* 手机端 (≤640px) */
@media (max-width: 640px) {
  header h1 {
    font-size: 0.95rem;
  }

  #uploadArea {
    padding: 1.5rem 1rem;
    min-height: 180px;
  }

  button {
    padding: 0.625rem 0.75rem !important;
    font-size: 0.75rem !important;
  }

  #resetBtn span {
    display: none !important;
  }

  /* 结果卡片在小屏上宽度自适应 */
  .report-card {
    margin-bottom: 10px;
    padding: 12px 14px;
    border-radius: 12px;
  }

  .report-card-title {
    font-size: 12px;
  }

  .report-card-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .text-content {
    font-size: 11px;
    line-height: 1.7;
  }

  /* 星级在小屏缩小 */
  .star-rating .star {
    font-size: 10px;
  }

  /* 进度条在小屏保持可见 */
  .progress-bar-track {
    height: 6px;
  }

  /* 情绪主emoji缩小 */
  .emotion-primary .text-4xl {
    font-size: 1.75rem !important;
  }

  /* 人脸检测信息网格在小屏单列 */
  .face-info-grid {
    grid-template-columns: 1fr;
    gap: 2px 8px;
  }

  /* 多人脸切换控件小屏适配 */
  .face-switcher {
    gap: 3px;
    padding: 4px;
  }

  .face-switch-tab {
    padding: 3px 10px;
    font-size: 10px;
  }

  .face-switch-arrow {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }
}

/* 极小屏幕 (≤380px) */
@media (max-width: 380px) {
  /* 导航进一步缩小 */
  header .h-16 {
    height: 2.75rem;
  }
  header h1 {
    font-size: 0.75rem;
  }
  header .w-10.h-10 {
    width: 1.75rem;
    height: 1.75rem;
  }

  main.pt-20 {
    padding-top: 3.5rem;
  }
  main.pb-8 {
    padding-bottom: 1rem;
  }
  main.px-4 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .report-card {
    padding: 10px 12px;
  }

  .btn-action {
    font-size: 0.7rem !important;
    padding: 0.5rem 0.6rem !important;
    min-width: 70px !important;
  }

  #analyzeBtn {
    min-width: 90px !important;
  }

  /* 结果面板文字缩小 */
  .report-card-title {
    font-size: 10px;
  }
  .report-card-badge {
    font-size: 9px;
    padding: 1px 6px;
  }
  .text-content {
    font-size: 10px;
  }
  .progress-bar-num {
    font-size: 10px;
  }
  .emotion-desc {
    font-size: 10px;
  }

  /* Toast 缩小 */
  #toast {
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    bottom: 1rem;
  }
}

/* 超大屏 (≥1440px)：居中且有呼吸感 */
@media (min-width: 1440px) {
  main {
    max-width: 80rem !important;
  }
  #uploadArea {
    min-height: 280px;
    padding: 2.5rem 3rem;
  }
  .report-card {
    padding: 20px;
  }
}

/* 横屏手机 (高度很小) */
@media (max-height: 500px) and (orientation: landscape) {
  header .h-16 {
    height: 2.5rem;
  }
  main.pt-20 {
    padding-top: 3rem;
  }
  #uploadArea {
    min-height: 120px;
    padding: 0.75rem;
  }
  #uploadArea .mb-4 {
    margin-bottom: 0.5rem;
  }
  #uploadIcon .w-16 {
    width: 2.25rem;
    height: 2.25rem;
  }
  #uploadIcon i {
    font-size: 1.25rem !important;
  }
  .btn-action {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.65rem !important;
  }
}
