/**
 * Face AI 前台样式表
 * 主题系统 - macOS风格
 */

/* ===== CSS变量主题系统 ===== */
:root {
    --color-primary: #e91e8c;
    --color-primary-light: #ff6bb3;
    --color-primary-dark: #d11a7d;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* 暗色模式(默认) */
[data-theme="dark"] {
    --bg-base: #0c0a09;
    --bg-primary: #0c0a09;
    --bg-secondary: #1c1917;
    --bg-tertiary: #292524;
    --bg-elevated: #292524;
    --bg-modal: #1c1917;
    --text-primary: #fafaf9;
    --text-secondary: #a8a29e;
    --text-tertiary: #78716c;
    --border-primary: rgba(255,255,255,0.08);
    --border-secondary: rgba(255,255,255,0.12);
    --shadow-color: rgba(0,0,0,0.5);
    --glass-bg: rgba(12,10,9,0.9);
    --glass-border: rgba(255,255,255,0.08);
    --active-bg: rgba(233,30,140,0.15);
    --active-border: rgba(233,30,140,0.3);
    --selection-bg: rgba(233,30,140,0.3);
    --selection-text: #ffffff;
}

/* 亮色模式 */
[data-theme="light"] {
    --bg-base: #d8dce3;
    --bg-primary: #e2e6ec;
    --bg-secondary: #e8ecf2;
    --bg-tertiary: #dfe3ea;
    --bg-elevated: #e2e6ec;
    --bg-modal: #e2e6ec;
    --text-primary: #1a1a2e;
    --text-secondary: #3a3a4a;
    --text-tertiary: #5a5a6a;
    --border-primary: #c5c9d0;
    --border-secondary: #b5b9c0;
    --shadow-color: rgba(0,0,0,0.1);
    --glass-bg: rgba(226,230,236,0.95);
    --glass-border: rgba(0,0,0,0.1);
    --active-bg: rgba(233,30,140,0.12);
    --active-border: rgba(233,30,140,0.3);
    --selection-bg: rgba(233,30,140,0.2);
    --selection-text: #e91e8c;
}

/* ===== 基础样式 ===== */
* { -webkit-tap-highlight-color: transparent; }
[x-cloak] { display: none !important; }

::selection {
    background-color: var(--selection-bg);
    color: var(--selection-text);
}

html { scroll-behavior: auto; }
body { 
    background-color: var(--bg-base); 
    color: var(--text-primary); 
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

/* ===== 滚动条隐藏 ===== */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ===== 渐变和文字效果 ===== */
.gradient-primary { background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%); }
.text-gradient { 
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== 按钮样式 ===== */
.btn-primary { 
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%); 
    box-shadow: 0 4px 14px rgba(233, 30, 140, 0.3);
}
.btn-primary:hover { 
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
    box-shadow: 0 6px 20px rgba(233, 30, 140, 0.4);
}

/* ===== 魔法按钮样式（任务提交） ===== */
.btn-magic {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffc107;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}
.btn-magic::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1) 0%, rgba(255, 152, 0, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.btn-magic:hover::before {
    opacity: 1;
}
.btn-magic:hover {
    border-color: rgba(255, 193, 7, 0.5);
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.2), inset 0 0 20px rgba(255, 193, 7, 0.05);
    color: #ffca28;
}
.btn-magic:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: #ffc107;
}
.btn-magic:disabled:hover {
    border-color: rgba(255, 193, 7, 0.3);
    box-shadow: none;
}
.btn-magic:disabled:hover::before {
    opacity: 0;
}
.btn-magic .fa-wand-magic-sparkles {
    color: #ffc107;
    filter: drop-shadow(0 0 3px rgba(255, 193, 7, 0.5));
}

/* 浅色模式魔法按钮 */
[data-theme="light"] .btn-magic {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid rgba(255, 152, 0, 0.4);
    color: #e65100;
}
[data-theme="light"] .btn-magic::before {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.08) 0%, rgba(255, 193, 7, 0.04) 100%);
}
[data-theme="light"] .btn-magic:hover {
    border-color: rgba(255, 152, 0, 0.6);
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.15), inset 0 0 20px rgba(255, 152, 0, 0.03);
    color: #ff6f00;
}
[data-theme="light"] .btn-magic:disabled {
    color: #e65100;
}
[data-theme="light"] .btn-magic .fa-wand-magic-sparkles {
    color: #e65100;
    filter: drop-shadow(0 0 3px rgba(255, 152, 0, 0.4));
}

/* ===== macOS风格卡片 ===== */
.card { 
    background: var(--bg-secondary); 
    border: 1px solid var(--border-primary); 
    border-radius: 16px;
    box-shadow: 0 2px 8px var(--shadow-color);
}
.card:hover { 
    border-color: var(--border-secondary); 
    box-shadow: 0 4px 16px var(--shadow-color);
}
.card-elevated {
    background: var(--bg-elevated);
    box-shadow: 0 8px 32px var(--shadow-color);
}

/* ===== Glass效果(已禁用blur) ===== */
.glass {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
}

/* ===== 弹窗样式 ===== */
.modal-overlay {
    background: rgba(0,0,0,0.85);
}
.modal-content {
    background: var(--bg-modal);
    border: 1px solid var(--border-secondary);
    box-shadow: 0 24px 80px -12px rgba(0,0,0,0.5);
}

/* ===== 标签样式 ===== */
.tag-hot { background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%); }
.tag-discount { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.tag-new { background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%); }

/* ===== 主题颜色类 ===== */
.text-primary { color: var(--color-primary); }
.bg-primary { background-color: var(--color-primary); }
.bg-surface { background-color: var(--bg-secondary); }
.bg-surface-light { background-color: var(--bg-tertiary); }
.bg-surface-elevated { background-color: var(--bg-elevated); }

.text-themed { color: var(--text-primary); }
.text-themed-secondary { color: var(--text-secondary); }
.text-themed-tertiary { color: var(--text-tertiary); }

.border-subtle { border-color: var(--border-primary); }
.border-themed { border-color: var(--border-secondary); }

.divide-themed > :not([hidden]) ~ :not([hidden]) {
    border-top-width: 1px;
    border-color: var(--border-primary);
}

/* ===== 间距工具类 ===== */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.-translate-x-1\/2 { transform: translateX(-50%); }
.z-\[100\] { z-index: 100; }

/* ===== 性能优化：平衡体验与性能 ===== */

/* 1. 禁用持续循环动画（GPU密集型） */
.animate-gradient-x, .animate-pulse {
    animation: none !important;
}

/* 2. 禁用模糊效果（GPU密集型） */
.backdrop-blur, .blur-sm, .blur-md, .blur-lg, .blur-xl, .blur-2xl, .blur-3xl {
    filter: none !important;
    -webkit-filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* 3. 优化过渡效果：使用更短的时间和高性能属性 */
.transition, .transition-all {
    transition-duration: 150ms !important;
    transition-property: opacity, transform, background-color, border-color, color !important;
}
.transition-colors {
    transition-duration: 150ms !important;
    transition-property: background-color, border-color, color !important;
}
.transition-opacity {
    transition-duration: 150ms !important;
    transition-property: opacity !important;
}
.transition-transform {
    transition-duration: 150ms !important;
    transition-property: transform !important;
}

/* 4. 轻量级入场动画（只执行一次） */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.animate-fade-in {
    animation: fadeIn 200ms ease-out forwards;
}
.animate-slide-up {
    animation: slideUp 200ms ease-out forwards;
}
.animate-scale-in {
    animation: scaleIn 200ms ease-out forwards;
}

/* 5. Alpine.js过渡优化 */
[x-transition], [x-transition\:enter], [x-transition\:leave] {
    transition-duration: 150ms !important;
}

/* 6. Hover效果优化：使用transform代替其他属性 */
.group:hover .group-hover\:scale-105,
.hover\:scale-105:hover {
    transform: scale(1.02) !important; /* 减小缩放幅度 */
}

/* 7. FontAwesome旋转动画保留但优化 */
.fa-spin {
    animation-duration: 1.5s !important; /* 减慢旋转速度 */
}

/* 8. 减少重绘：仅在需要时使用will-change */
.modal-content, .card:hover {
    will-change: transform, opacity;
}

/* 9. 移动端进一步优化 */
@media (max-width: 768px) {
    .transition, .transition-all, .transition-colors, .transition-opacity, .transition-transform {
        transition-duration: 100ms !important;
    }
    .group:hover .group-hover\:scale-105,
    .hover\:scale-105:hover {
        transform: none !important; /* 移动端禁用hover缩放 */
    }
}

/* 10. 减少动画偏好的用户 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== 文本样式 ===== */
.text-balance { text-wrap: balance; }

/* ===== 响应式容器 ===== */
@media (min-width: 768px) {
    .container-main { max-width: 640px; }
}
@media (min-width: 1024px) {
    .container-main { max-width: 960px; }
}
@media (min-width: 1280px) {
    .container-main { max-width: 1120px; }
}

/* ===== 安全区域 ===== */
.safe-bottom { padding-bottom: var(--safe-area-bottom); }
.pb-safe { padding-bottom: calc(5rem + var(--safe-area-bottom)); }
@media (min-width: 768px) {
    .pb-safe { padding-bottom: 2rem; }
}

/* ===== Tab标签自适应 ===== */
@media (max-width: 640px) {
    .tab-label-custom::after { content: '自定义'; }
}
@media (min-width: 641px) {
    .tab-label-custom::after { content: '自定义换脸'; }
}

/* ===== 表单样式 ===== */
input, button, textarea, select { font-family: inherit; }

.input-field {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    outline: none;
}
.input-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.1);
    background: var(--bg-secondary);
}
.input-field::placeholder { color: var(--text-tertiary); }

/* 输入框图标居中 */
.input-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    line-height: 1;
}
.input-icon i {
    display: block;
    line-height: 1;
    font-size: 14px;
    transform: translateY(0);
}

