/* 添加主题切换过渡动画 */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* 定义暗色主题变量 */
html[data-theme='dark'], body.dark-theme {
    --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);
    --gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

body.dark-theme {
    background: linear-gradient(-45deg, #1e272e, #2d3436, #1e3a4c, #2c3e50);
    background-size: 400% 400%;
    animation: gradientAnimation 15s ease infinite;
    color: var(--text-color);
}

.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    border: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

body.dark-theme .search-box {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme #number-input {
    color: var(--text-color);
    background: var(--card-color);
}

body.dark-theme .result-card, 
body.dark-theme .fact-card {
    background: var(--card-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .pi-visualization {
    background: rgba(108, 92, 231, 0.15);
    color: var(--text-color);
}

/* 加载动画优化 */
.loader {
    border: 3px solid rgba(108, 92, 231, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    width: 24px;
    height: 24px;
    animation: spin 1s infinite linear;
}

/* 添加进入动画 */
.welcome-animation {
    animation: welcomeAnim 1.5s ease-out forwards;
}

@keyframes welcomeAnim {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    70% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 搜索结果强调 */
.result-emphasis {
    font-weight: bold;
    color: var(--accent-color);
    display: inline-block;
    padding: 0 5px;
    border-radius: 4px;
    background: rgba(253, 121, 168, 0.1);
}

/* 触摸反馈 */
@media (hover: none) {
    .search-box:active {
        transform: scale(0.98);
    }
    
    #search-button:active {
        transform: scale(0.95);
    }
}

/* 改进错误消息样式 */
.error {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 10px 15px;
    border-radius: 8px;
    border-left: 4px solid #e74c3c;
    margin: 10px 0;
}

/* 添加成功消息样式 */
.success {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
    padding: 10px 15px;
    border-radius: 8px;
    border-left: 4px solid #2ecc71;
    margin: 10px 0;
}

/* 主题切换样式 */

/* 暗色主题 */
body.dark-theme {
    background-color: #1a1a2e;
    color: #e0e0e0;
}

body.dark-theme .pi-explorer {
    background-color: #1a1a2e;
}

body.dark-theme .header h1 {
    color: #e0e0e0;
}

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

body.dark-theme .subtitle {
    color: #b0b0b0;
}

body.dark-theme .search-box {
    background-color: #222242;
    border-color: #2c2c54;
}

body.dark-theme #number-input {
    color: #e0e0e0;
    background-color: #222242;
}

body.dark-theme #number-input::placeholder {
    color: #8c8c8c;
}

body.dark-theme #search-button {
    background-color: #3498db;
    color: #e0e0e0;
}

body.dark-theme .hint {
    color: #8c8c8c;
}

body.dark-theme .result-card {
    background-color: #222242;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

body.dark-theme .result-header h2 {
    color: #e0e0e0;
}

body.dark-theme .loader {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: #3498db;
}

body.dark-theme .result-emphasis {
    color: #3498db;
}

body.dark-theme .pi-visualization {
    background-color: #2c2c54;
    color: #b0b0b0;
}

body.dark-theme .highlight {
    color: #e74c3c;
}

body.dark-theme .pi-facts {
    background-color: #222242;
}

body.dark-theme .pi-facts h3 {
    color: #e0e0e0;
}

body.dark-theme .fact-card {
    background-color: #2c2c54;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

body.dark-theme .fact-icon {
    color: #3498db;
}

body.dark-theme .fact-card p {
    color: #b0b0b0;
}

body.dark-theme footer {
    color: #8c8c8c;
}

body.dark-theme .search-history {
    background-color: #222242;
}

body.dark-theme .history-header h3 {
    color: #e0e0e0;
}

body.dark-theme .history-item {
    background-color: #2c2c54;
}

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

body.dark-theme .history-position {
    color: #b0b0b0;
}

body.dark-theme .pi-more-info {
    background-color: #222242;
}

body.dark-theme .pi-more-info h3 {
    color: #e0e0e0;
}

body.dark-theme .pi-more-info p {
    color: #b0b0b0;
}

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

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

body.dark-theme .message {
    background-color: #222242;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-theme .message.error {
    background-color: #3c1c1c;
}

body.dark-theme .message.info {
    background-color: #1c2c3c;
}

body.dark-theme .message.success {
    background-color: #1c3c1c;
}

/* 主题切换按钮 */
#theme-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: #3498db;
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, transform 0.3s;
}

#theme-toggle:hover {
    background-color: rgba(52, 152, 219, 0.1);
    transform: rotate(15deg);
}

body.dark-theme #theme-toggle {
    color: #f1c40f;
}

body.dark-theme #theme-toggle:hover {
    background-color: rgba(241, 196, 15, 0.1);
}

/* 快捷键帮助对话框 */
.shortcuts-help {
    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;
}

.shortcuts-help.show {
    opacity: 1;
    visibility: visible;
}

.shortcuts-help.fade-out {
    opacity: 0;
}

.shortcuts-content {
    background-color: #fff;
    border-radius: 12px;
    padding: 25px;
    width: 350px;
    max-width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.shortcuts-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.3rem;
    text-align: center;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.shortcut-item:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 25px;
}

.shortcut-key {
    background-color: #f1f1f1;
    padding: 5px 10px;
    border-radius: 5px;
    font-family: monospace;
    font-weight: bold;
    color: #333;
}

.shortcut-desc {
    color: #555;
}

#close-help {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s;
}

#close-help:hover {
    background-color: #2980b9;
}

/* 暗色主题下的快捷键帮助 */
body.dark-theme .shortcuts-content {
    background-color: #222242;
}

body.dark-theme .shortcuts-content h3 {
    color: #e0e0e0;
}

body.dark-theme .shortcut-item {
    border-bottom-color: #333;
}

body.dark-theme .shortcut-key {
    background-color: #2c2c54;
    color: #b0b0b0;
}

body.dark-theme .shortcut-desc {
    color: #b0b0b0;
}

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

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