/**
 * 运动记录插件 - 多配色主题系统
 * 包含多种渐变配色方案和动态背景效果
 */

/* ============================================
   配色方案定义
   ============================================ */

/* 紫色主题（默认） */
:root {
    --theme-purple-primary: #667eea;
    --theme-purple-secondary: #764ba2;
    --theme-purple-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 绿色主题 */
.exercise-theme-green {
    --theme-primary: #10b981;
    --theme-secondary: #059669;
    --theme-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --theme-light: #d1fae5;
    --theme-dark: #065f46;
}

/* 黄色/橙色主题 */
.exercise-theme-yellow {
    --theme-primary: #f59e0b;
    --theme-secondary: #d97706;
    --theme-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --theme-light: #fef3c7;
    --theme-dark: #92400e;
}

/* 红色主题 */
.exercise-theme-red {
    --theme-primary: #ef4444;
    --theme-secondary: #dc2626;
    --theme-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --theme-light: #fee2e2;
    --theme-dark: #991b1b;
}

/* 蓝色主题 */
.exercise-theme-blue {
    --theme-primary: #3b82f6;
    --theme-secondary: #2563eb;
    --theme-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --theme-light: #dbeafe;
    --theme-dark: #1e40af;
}

/* 粉色主题 */
.exercise-theme-pink {
    --theme-primary: #ec4899;
    --theme-secondary: #db2777;
    --theme-gradient: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    --theme-light: #fce7f3;
    --theme-dark: #9f1239;
}

/* 青色主题 */
.exercise-theme-cyan {
    --theme-primary: #06b6d4;
    --theme-secondary: #0891b2;
    --theme-gradient: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    --theme-light: #cffafe;
    --theme-dark: #164e63;
}

/* 紫色主题（默认） */
.exercise-theme-purple {
    --theme-primary: #667eea;
    --theme-secondary: #764ba2;
    --theme-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --theme-light: #e9d5ff;
    --theme-dark: #581c87;
}

/* ============================================
   动态背景效果
   ============================================ */

/* 基础背景容器 */
.exercise-dynamic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    min-height: 100%;
    z-index: -1;
    overflow: hidden;
    background: var(--theme-gradient);
    background-attachment: fixed;
}

/* 确保背景覆盖整个页面内容 */
html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    position: relative;
}

/* 当内容超出视口时，背景也要延伸 */
.exercise-dynamic-bg::after {
    content: '';
    position: absolute;
    top: 100vh;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--theme-gradient);
    z-index: -1;
}

/* 1. 线形流动效果 */
.exercise-bg-lines {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: var(--theme-gradient);
    overflow: hidden;
    background-attachment: fixed;
}

.exercise-bg-lines::before,
.exercise-bg-lines::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    animation: lineFlow 20s linear infinite;
}

.exercise-bg-lines::before {
    top: 20%;
    transform: rotate(45deg);
    animation-delay: 0s;
}

.exercise-bg-lines::after {
    top: 60%;
    transform: rotate(-45deg);
    animation-delay: -10s;
}

@keyframes lineFlow {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

/* 2. 颗粒动画效果 */
.exercise-bg-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: var(--theme-gradient);
    overflow: hidden;
    background-attachment: fixed;
}

.exercise-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: particleFloat 15s infinite ease-in-out;
}

.exercise-particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.exercise-particle:nth-child(2) { left: 20%; animation-delay: 1s; }
.exercise-particle:nth-child(3) { left: 30%; animation-delay: 2s; }
.exercise-particle:nth-child(4) { left: 40%; animation-delay: 3s; }
.exercise-particle:nth-child(5) { left: 50%; animation-delay: 4s; }
.exercise-particle:nth-child(6) { left: 60%; animation-delay: 5s; }
.exercise-particle:nth-child(7) { left: 70%; animation-delay: 6s; }
.exercise-particle:nth-child(8) { left: 80%; animation-delay: 7s; }
.exercise-particle:nth-child(9) { left: 90%; animation-delay: 8s; }

@keyframes particleFloat {
    0%, 100% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    50% {
        transform: translateY(-100px) scale(1);
    }
}

/* 3. 放射效果 */
.exercise-bg-radial {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: var(--theme-gradient);
    overflow: hidden;
    background-attachment: fixed;
}

.exercise-radial-circle {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    animation: radialPulse 8s infinite ease-in-out;
}

.exercise-radial-circle:nth-child(1) {
    width: 300px;
    height: 300px;
    top: -150px;
    left: -150px;
    animation-delay: 0s;
}

.exercise-radial-circle:nth-child(2) {
    width: 500px;
    height: 500px;
    bottom: -250px;
    right: -250px;
    animation-delay: 2s;
}

.exercise-radial-circle:nth-child(3) {
    width: 400px;
    height: 400px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 4s;
}

@keyframes radialPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.1;
    }
}

/* 4. 波纹效果 */
.exercise-bg-waves {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: var(--theme-gradient);
    overflow: hidden;
    background-attachment: fixed;
}

.exercise-wave {
    position: absolute;
    width: 200%;
    height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    animation: waveMove 10s infinite ease-in-out;
}

.exercise-wave:nth-child(1) {
    top: -100px;
    left: -50%;
    animation-delay: 0s;
}

.exercise-wave:nth-child(2) {
    top: 200px;
    left: -50%;
    animation-delay: -2s;
    animation-duration: 12s;
}

.exercise-wave:nth-child(3) {
    top: 500px;
    left: -50%;
    animation-delay: -4s;
    animation-duration: 14s;
}

@keyframes waveMove {
    0% {
        transform: translateX(0) translateY(0);
    }
    50% {
        transform: translateX(25%) translateY(-20px);
    }
    100% {
        transform: translateX(50%) translateY(0);
    }
}

/* 5. 律动效果（心跳/呼吸） */
.exercise-bg-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: var(--theme-gradient);
    overflow: hidden;
    background-attachment: fixed;
    animation: pulseBreath 4s infinite ease-in-out;
}

@keyframes pulseBreath {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.95;
    }
}

.exercise-pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulseRing 3s infinite;
}

@keyframes pulseRing {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 200%;
        height: 200%;
        opacity: 0;
    }
}

/* 6. 网格动画效果 */
.exercise-bg-grid {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: var(--theme-gradient);
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    background-attachment: fixed;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 50px 50px;
    }
}

/* 7. 光斑效果 */
.exercise-bg-spotlight {
    position: absolute;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: var(--theme-gradient);
    overflow: hidden;
    background-attachment: fixed;
}

.exercise-spotlight {
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: spotlightMove 15s infinite ease-in-out;
}

.exercise-spotlight:nth-child(1) {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.exercise-spotlight:nth-child(2) {
    bottom: 20%;
    right: 15%;
    animation-delay: -5s;
}

.exercise-spotlight:nth-child(3) {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes spotlightMove {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(100px, 50px) scale(1.2);
    }
    66% {
        transform: translate(-50px, -100px) scale(0.8);
    }
}

/* ============================================
   配色选择器样式（隐藏式设计）
   ============================================ */

/* 配色按钮（触发按钮） */
.exercise-theme-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--theme-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.exercise-theme-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.exercise-theme-toggle-btn:active {
    transform: scale(0.95);
}

.exercise-theme-toggle-btn.active {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
}

/* 遮罩层 */
.exercise-theme-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.exercise-theme-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 主题选择器面板（默认隐藏） */
.exercise-theme-selector {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    min-width: 280px;
    max-width: 320px;
}

.exercise-theme-selector.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* 关闭按钮 */
.exercise-theme-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    color: #666;
    transition: all 0.3s ease;
    line-height: 1;
}

.exercise-theme-close:hover {
    background: #e5e7eb;
    color: #333;
    transform: rotate(90deg);
}

.exercise-theme-selector-title {
    font-size: 1em;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    text-align: center;
    padding-right: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.exercise-theme-selector-title::before {
    content: '🎨';
    font-size: 1.2em;
}

.exercise-theme-mode-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.exercise-theme-auto-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    background: #f9fafb;
    color: #374151;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.exercise-theme-auto-btn:hover {
    border-color: #667eea;
    background: #f3f4f6;
    color: #667eea;
}

.exercise-theme-auto-btn.active {
    border-color: #667eea;
    background: #eef2ff;
    color: #667eea;
}

.exercise-theme-auto-hint {
    font-size: 0.85em;
    color: #6b7280;
    margin-left: 4px;
}

.exercise-theme-colors-label {
    font-size: 0.85em;
    color: #6b7280;
    margin-bottom: 8px;
}

.exercise-theme-colors {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.exercise-theme-color {
    width: 35px;
    height: 35px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    background: var(--theme-gradient);
}

.exercise-theme-color:hover {
    transform: scale(1.1);
    border-color: rgba(0, 0, 0, 0.2);
}

.exercise-theme-color.active {
    border-color: #333;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.exercise-theme-color.exercise-theme-color-today {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.6);
    border-color: rgba(102, 126, 234, 0.8);
}

.exercise-theme-color[data-theme="green"] {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.exercise-theme-color[data-theme="yellow"] {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.exercise-theme-color[data-theme="red"] {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.exercise-theme-color[data-theme="blue"] {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.exercise-theme-color[data-theme="pink"] {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.exercise-theme-color[data-theme="cyan"] {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.exercise-theme-color[data-theme="purple"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.exercise-effect-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

/* 效果选择器滚动条样式 */
.exercise-effect-selector::-webkit-scrollbar {
    width: 4px;
}

.exercise-effect-selector::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.exercise-effect-selector::-webkit-scrollbar-thumb {
    background: var(--theme-primary, #667eea);
    border-radius: 10px;
}

.exercise-effect-btn {
    padding: 8px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    color: #333;
}

.exercise-effect-btn:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
}

.exercise-effect-btn.active {
    background: var(--theme-gradient);
    color: white;
    border-color: transparent;
}

/* 面板动画优化 */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.exercise-theme-selector.active {
    animation: slideUpFade 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 按钮脉冲动画（提示可点击） */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 4px 25px rgba(102, 126, 234, 0.5);
    }
}

.exercise-theme-toggle-btn:not(.active) {
    animation: pulse 2s ease-in-out infinite;
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 手机端：配色按钮始终显示，面板默认隐藏 */
    .exercise-theme-toggle-btn {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 1.3em;
        display: flex !important; /* 确保按钮在手机端显示 */
    }
    
    /* 手机端：面板默认隐藏，点击按钮后才显示 */
    .exercise-theme-selector {
        bottom: 80px;
        right: 20px;
        left: 20px;
        max-width: none;
        padding: 18px;
        /* 默认隐藏状态 */
        transform: translateY(20px) scale(0.9);
        opacity: 0;
        visibility: hidden;
    }
    
    /* 激活状态 */
    .exercise-theme-selector.active {
        transform: translateY(0) scale(1);
        opacity: 1;
        visibility: visible;
    }
    
    .exercise-theme-colors {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .exercise-theme-color {
        width: 32px;
        height: 32px;
    }
    
    .exercise-effect-selector {
        gap: 6px;
        max-height: 250px;
    }
    
    .exercise-effect-btn {
        padding: 8px 12px;
        font-size: 0.8em;
    }
    
    /* 手机端遮罩层 */
    .exercise-theme-overlay {
        /* 确保遮罩层在手机端正常工作 */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}
