/* 添加更多现代化UI元素和动画效果 */

/* 渐变背景动画 */
@keyframes gradientAnimation {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

body {
    background: linear-gradient(-45deg, #f9f9f9, #f0f0f0, #e8f4f8, #eef1f5);
    background-size: 400% 400%;
    animation: gradientAnimation 15s ease infinite;
}

/* 改进标题样式 */
.header h1 {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -1px;
}

.header h1::after {
    content: "";
    display: block;
    width: 60px;
    height: 4px;
    background: var(--gradient);
    margin: 10px auto;
    border-radius: 2px;
}

/* 搜索框悬浮效果增强 */
.search-box {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.search-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(108, 92, 231, 0.15);
}

.search-box:focus-within {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(108, 92, 231, 0.2);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

/* 搜索按钮动画 */
#search-button {
    overflow: hidden;
    position: relative;
}

#search-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.5s;
}

#search-button:hover::before {
    left: 100%;
}

/* 结果卡片增强效果 */
.result-card {
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.result-card:hover {
    box-shadow: 0 15px 35px rgba(108, 92, 231, 0.15);
}

/* 高亮动画增强 */
@keyframes enhancedPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(253, 121, 168, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(253, 121, 168, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(253, 121, 168, 0);
        transform: scale(1);
    }
}

.highlight {
    animation: enhancedPulse 2s infinite;
}

/* 事实卡片悬浮效果增强 */
.fact-card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0, 0, 0, 0.05);
    opacity: 1; /* 默认显示 */
    transform: translateY(0); /* 默认不偏移 */
}

.fact-card:hover {
    transform: translateY(-15px) scale(1.03);
    box-shadow: 0 20px 40px rgba(108, 92, 231, 0.2);
}

.fact-icon {
    transition: all 0.3s ease;
}

.fact-card:hover .fact-icon {
    transform: scale(1.1) rotate(10deg);
}

/* 添加暗色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #8c7ae6;
        --secondary-color: #9c88ff;
        --accent-color: #fd79a8;
        --background-color: #1e272e;
        --card-color: #2d3436;
        --text-color: #f5f6fa;
        --text-light: #dcdde1;
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }
    
    body {
        background: linear-gradient(-45deg, #1e272e, #2d3436, #1e3a4c, #2c3e50);
        background-size: 400% 400%;
        animation: gradientAnimation 15s ease infinite;
    }
    
    .search-box {
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    #number-input {
        color: var(--text-color);
        background: var(--card-color);
    }
    
    .result-card, .fact-card {
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .pi-visualization {
        background: rgba(108, 92, 231, 0.15);
    }
}

/* 添加更多动画和过渡效果 */
.header, .search-container, .result-container, .pi-facts {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 1s ease forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    animation-delay: 0.1s;
}

.search-container {
    animation-delay: 0.3s;
}

.result-container {
    animation-delay: 0.5s;
}

.pi-facts {
    animation-delay: 0.7s;
}

/* 添加浮动粒子背景 */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.3;
    animation: float 30s infinite linear;
}

@keyframes float {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
    }
}

/* 改进移动端响应式设计 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2.8rem;
    }
    
    .header h1 .explorer {
        font-size: 2.3rem;
    }
    
    .search-box {
        flex-direction: row;
        border-radius: 15px;
    }
    
    #search-button {
        width: auto;
        padding: 0 1.5rem;
    }
    
    .fact-cards {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .result-card {
        padding: 1.5rem;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 1.5rem;
    }
    
    .fact-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    .search-box:hover {
        transform: none;
        box-shadow: var(--shadow);
    }
    
    .fact-card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }
    
    .fact-card:active {
        transform: scale(0.98);
    }
    
    #search-button:active {
        opacity: 0.8;
    }
}

/* 增强样式 - 提供更现代的视觉效果和动画 */

/* 结果卡片动画 */
.scale-in {
    animation: scale-in 0.3s ease;
}

@keyframes scale-in {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.bounce {
    animation: bounce 0.5s ease;
}

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

/* 加载动画 */
.loader {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 3px solid #3498db;
    width: 25px;
    height: 25px;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 搜索结果高亮 */
.highlight {
    color: #e74c3c;
    font-weight: bold;
    padding: 2px;
    position: relative;
    animation: pulse 2s infinite;
}

.highlight::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #e74c3c;
    animation: underline 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        color: #e74c3c;
    }
    50% {
        color: #c0392b;
    }
}

@keyframes underline {
    0%, 100% {
        opacity: 0.5;
        transform: scaleX(1);
    }
    50% {
        opacity: 1;
        transform: scaleX(1.2);
    }
}

/* 搜索结果强调 */
.result-emphasis {
    font-weight: bold;
    color: #2980b9;
    font-size: 1.1em;
}

/* π探索者标题动画 */
.welcome-animation {
    animation: welcome 1s ease;
}

@keyframes welcome {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 事实卡片动画 */
.fact-card.fade-in {
    animation: card-fade-in 0.5s ease forwards;
}

@keyframes card-fade-in {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 搜索按钮效果 */
#search-button {
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#search-button:hover {
    background-color: #3498db;
    transform: scale(1.05);
}

#search-button.active {
    background-color: #2980b9;
}

/* 搜索输入框动画 */
#number-input {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#number-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* 错误消息样式 */
.error {
    color: #e74c3c;
    font-weight: bold;
}

/* 浮动消息通知 */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transform: translateX(0);
    transition: all 0.3s ease;
    max-width: 300px;
}

.message.error {
    background-color: #ffebee;
    border-left: 4px solid #e74c3c;
}

.message.info {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.message.success {
    background-color: #e8f5e9;
    border-left: 4px solid #4caf50;
}

.message.fade-out {
    opacity: 0;
    transform: translateX(30px);
}

/* 搜索历史样式 */
.search-history {
    background-color: #f8f9fa;
    border-radius: 12px;
    margin: 20px 0;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #2c3e50;
}

#clear-history {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#clear-history:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.history-sequence {
    font-weight: bold;
    color: #3498db;
}

.history-position {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* 单个数字闪烁效果 */
.blink {
    animation: blink-animation 0.3s ease;
    display: inline-block;
}

@keyframes blink-animation {
    0% {
        transform: scale(1);
        opacity: 1;
        color: #e74c3c;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.7;
        color: #ff9500;
    }
    100% {
        transform: scale(1);
        opacity: 1;
        color: #e74c3c;
    }
}

/* 增强的π信息部分 */
.pi-more-info {
    background-color: #f1f9ff;
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.pi-more-info h3 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.pi-more-info p {
    color: #34495e;
    line-height: 1.6;
    margin-bottom: 10px;
}

/* 统计计数器 */
.stats-counter {
    display: flex;
    justify-content: space-around;
    margin-top: 25px;
}

.stat {
    text-align: center;
    padding: 15px;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: #2980b9;
    margin-bottom: 8px;
    position: relative;
}

.stat-number:after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 40px;
    height: 3px;
    background-color: #3498db;
    transform: translateX(-50%);
    border-radius: 2px;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 带数字动画的搜索计数器 */
@keyframes count-up {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

#searches-count {
    animation: count-up 1s ease;
}

/* 历史记录导出功能样式 */
.history-actions {
    display: flex;
    gap: 8px;
}

#export-history-btn, #import-history-btn {
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#export-history-btn:hover, #import-history-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.export-btn {
    position: relative;
}

.export-counter {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--accent-color);
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounce 0.5s ease;
}

.pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(253, 121, 168, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(253, 121, 168, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(253, 121, 168, 0);
    }
}

/* 暗色主题适配 */
body.dark-theme #export-history-btn, 
body.dark-theme #import-history-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

body.dark-theme .export-counter {
    background-color: #e74c3c;
}

.file-info {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    font-style: italic;
}

/* 进度条样式 */
.progress-container {
    width: 100%;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    margin: 8px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient);
    width: 0;
    transition: width 0.3s ease;
}

body.dark-theme .progress-container {
    background-color: #2c2c54;
}

body.dark-theme .progress-bar {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

/* 统计对话框样式 */
.stats-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.stats-dialog.show {
    opacity: 1;
    visibility: visible;
}

.stats-dialog.fade-out {
    opacity: 0;
}

.stats-content {
    background-color: #fff;
    border-radius: 12px;
    padding: 25px;
    width: 600px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.stats-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.5rem;
    text-align: center;
}

.stats-content h4 {
    color: var(--primary-color);
    margin: 1rem 0;
    font-size: 1.2rem;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-box {
    text-align: center;
    padding: 15px;
    background: var(--card-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-box .stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.stats-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--card-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.stats-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stats-section li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
}

.stats-section li:last-child {
    border-bottom: none;
}

.stats-section .sequence {
    font-weight: bold;
    color: var(--primary-color);
}

.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-bar-item {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    align-items: center;
    gap: 10px;
}

.stat-bar-wrap {
    height: 20px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    background: var(--gradient);
    border-radius: 10px;
    min-width: 5px;
    transition: width 1s ease;
}

.stat-value {
    font-size: 0.9rem;
    white-space: nowrap;
}

#close-stats {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
    transition: background-color 0.2s;
}

#close-stats:hover {
    background-color: var(--secondary-color);
}

/* 暗色主题适配 */
body.dark-theme .stats-content {
    background-color: #222242;
}

body.dark-theme .stats-content h3,
body.dark-theme .stats-content h4 {
    color: #3498db;
}

body.dark-theme .stat-box {
    background-color: #2c2c54;
}

body.dark-theme .stat-box .stat-value {
    color: #3498db;
}

body.dark-theme .stat-box .stat-label {
    color: #b0b0b0;
}

body.dark-theme .stats-section {
    background-color: #2c2c54;
}

body.dark-theme .stats-section li {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .stats-section .sequence {
    color: #3498db;
}

body.dark-theme .stat-bar-wrap {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .stat-bar {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

body.dark-theme #close-stats {
    background-color: #3498db;
}

body.dark-theme #close-stats:hover {
    background-color: #2980b9;
}

@media (max-width: 768px) {
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-bar-item {
        grid-template-columns: 80px 1fr 60px;
        font-size: 0.9rem;
    }
}

/* 页脚链接样式 */
.footer-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
    position: relative;
}

.footer-link:hover {
    color: var(--secondary-color);
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient);
    transition: width 0.3s ease;
}

.footer-link:hover::after {
    width: 100%;
}

body.dark-theme .footer-link {
    color: #3498db;
}

body.dark-theme .footer-link:hover {
    color: #2980b9;
}
