/* 数学公式大全网站样式 */

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding-bottom: 70px; /* 为底部导航栏留出空间 */
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* 头部样式 */
.header {
    background-color: #fff;
    padding: 15px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* 返回按钮绝对定位在标题左侧 */
.back-button {
    position: absolute;
    left: 0;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background-color: #f0f0f0;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.3s;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0;
    text-align: center;
}

.back-button:hover {
    background-color: #e0e0e0;
}

.back-button::before {
    content: '←';
    margin-right: 5px;
}

/* 搜索框样式 */
.search-container {
    background-color: #fff;
    padding: 15px;
    margin: 15px 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-box {
    display: flex;
    gap: 10px;
}

#search-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

#search-input:focus {
    border-color: #4CAF50;
}

#search-button {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#search-button:hover {
    background-color: #45a049;
}

/* 公式列表样式 */
.formula-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

/* 公式卡片样式 */
.formula-card {
    background-color: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.formula-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.formula-card h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
}

.formula-expression {
    font-family: 'Courier New', monospace;
    background-color: #f8f8f8;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 10px;
    color: #666;
    font-size: 14px;
    word-wrap: break-word;
}

.formula-application {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.formula-category {
    display: inline-block;
    padding: 3px 8px;
    background-color: #e3f2fd;
    color: #1976d2;
    border-radius: 12px;
    font-size: 12px;
    margin-bottom: 10px;
}

.formula-card a {
    text-decoration: none;
    color: inherit;
}

/* 收藏按钮样式 */
.favorite-btn,
.favorite-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #ddd;
    transition: color 0.3s;
    padding: 5px;
}

.favorite-btn:hover,
.favorite-button:hover {
    color: #ffcc00;
}

.favorite-btn.favorited,
.favorite-button.favorited {
    color: #ffcc00;
}

/* 公式预览内容样式 */
.formula-preview-content {
    position: relative;
    display: block;
}

/* 分类筛选样式 */
.category-filter {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    margin-bottom: 15px;
}

.category-filter::-webkit-scrollbar {
    display: none;
}

.category-filter button {
    padding: 8px 16px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
}

.category-filter button:hover {
    background-color: #e0e0e0;
}

.category-filter button.active {
    background-color: #4CAF50;
    color: white;
}

/* 底部导航栏样式 */
.nav-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #fff;
    border-top: 1px solid #ddd;
    z-index: 1000;
}

.bottom-nav {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    padding: 5px 10px;
    transition: color 0.3s;
}

.nav-item:hover {
    color: #4CAF50;
}

.nav-item.active {
    color: #4CAF50;
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 5px;
}

.nav-item span {
    font-size: 12px;
}

/* 公式详情页面样式 */
.formula-detail {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.formula-name {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.formula-detail .formula-expression {
    font-size: 20px;
    padding: 15px;
    text-align: center;
    background-color: #f8f8f8;
    border-radius: 8px;
    margin-bottom: 20px;
}

.formula-description,
.formula-application {
    margin-bottom: 15px;
    line-height: 1.8;
}

.related-formulas {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.related-formulas h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
}

.related-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.related-item {
    background-color: #f8f8f8;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
}

.related-item:hover {
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.related-item a {
    text-decoration: none;
    color: #4CAF50;
    font-size: 14px;
    display: block;
}

.related-item h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #333;
}

.related-item p {
    margin: 0;
    color: #666;
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.no-related-formulas {
    text-align: center;
    color: #999;
    padding: 20px;
    font-size: 14px;
    background-color: #f9f9f9;
    border-radius: 6px;
}

/* 收藏页面样式 */
.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.favorites-header h2 {
    font-size: 20px;
    color: #333;
}

#clear-favorites-btn {
    padding: 8px 16px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#clear-favorites-btn:hover {
    background-color: #d32f2f;
}

#favorites-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.formula-item {
    background-color: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.formula-info h4 {
    font-size: 16px;
    margin-bottom: 5px;
}

.formula-info .formula-expression {
    font-size: 14px;
    margin-bottom: 5px;
    color: #666;
}

.formula-stage {
    font-size: 12px;
    color: #999;
}

.formula-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.btn-view {
    background-color: #2196F3;
    color: white;
}

.btn-view:hover {
    background-color: #1976D2;
}

.btn-remove {
    background-color: #f44336;
    color: white;
}

.btn-remove:hover {
    background-color: #d32f2f;
}

.empty-favorites {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* 分类页面样式 */
.stage-nav {
    display: flex;
    overflow-x: auto;
    background-color: #fff;
    padding: 10px 0;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stage-nav::-webkit-scrollbar {
    display: none;
}

.stage-nav a {
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    font-size: 16px;
    white-space: nowrap;
    transition: all 0.3s;
}

.stage-nav a:hover {
    color: #4CAF50;
}

.stage-nav a.active {
    color: #4CAF50;
    font-weight: 600;
    position: relative;
}

.stage-nav a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background-color: #4CAF50;
    border-radius: 3px;
}

.category-section {
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

.category-formulas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.formula-preview {
    background-color: #f8f8f8;
    padding: 10px;
    border-radius: 6px;
    transition: background-color 0.3s;
}

.formula-preview:hover {
    background-color: #e8e8e8;
}

.formula-preview a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.formula-preview h4 {
    font-size: 14px;
    margin-bottom: 5px;
    color: #333;
}

.formula-preview p {
    font-size: 12px;
    color: #666;
    font-family: 'Courier New', monospace;
}

/* 搜索页面样式 */
.search-results-header {
    margin-bottom: 20px;
    text-align: center;
}

.search-results-header h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 5px;
}

.search-results-header p {
    color: #666;
    font-size: 14px;
}

#search-results {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.search-result-item {
    background-color: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-result-item h4 {
    font-size: 16px;
    margin-bottom: 8px;
}

.search-result-item h4 a {
    color: #4CAF50;
    text-decoration: none;
}

.search-result-item .formula-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    line-height: 1.5;
}

.formula-meta {
    display: flex;
    gap: 10px;
}

.formula-meta span {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 12px;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* 未找到公式样式 */
.not-found {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* 关于页面样式 */
.about-section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.about-section h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #333;
}

.about-section h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #4CAF50;
}

.about-section p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.site-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.info-card {
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.info-card h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

.info-card p {
    color: #666;
    font-size: 14px;
}

/* 404错误页面样式 */
.error-page {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.error-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.error-content {
    text-align: center;
    background-color: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
}

.error-number {
    font-size: 80px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.error-content h1 {
    font-size: 28px;
    margin-bottom: 15px;
    color: #333;
}

.error-content p {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
}

.error-suggestions {
    margin-bottom: 30px;
    text-align: left;
}

.error-suggestions h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

.error-suggestions ul {
    list-style: none;
    padding: 0;
}

.error-suggestions li {
    margin-bottom: 10px;
    padding-left: 25px;
    position: relative;
    font-size: 14px;
}

.error-suggestions li i {
    position: absolute;
    left: 0;
    top: 2px;
    color: #4CAF50;
}

.error-suggestions a {
    color: #4CAF50;
    text-decoration: none;
}

.error-suggestions a:hover {
    text-decoration: underline;
}

.error-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #2196F3;
    color: white;
}

.btn-secondary:hover {
    background-color: #0b7dda;
    transform: translateY(-2px);
}

/* 404页面样式 */
.error-page {
    min-height: calc(100vh - 100px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.error-container {
    text-align: center;
    max-width: 500px;
    background-color: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.error-number {
    font-size: 80px;
    font-weight: 700;
    color: #4CAF50;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #4CAF50, #2196F3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.error-description {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
    line-height: 1.6;
}

.error-suggestions {
    margin-bottom: 30px;
    text-align: left;
}

.error-suggestions h4 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
}

.error-suggestions ul {
    list-style-type: none;
    padding: 0;
}

.error-suggestions li {
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
    padding-left: 20px;
    position: relative;
}

.error-suggestions li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #4CAF50;
    font-weight: bold;
}

.error-button {
    display: inline-block;
    padding: 12px 24px;
    background-color: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.3s;
}

.error-button:hover {
    background-color: #45a049;
}

/* 通知样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10000;
}

/* 阶段标题样式 */
.stage-title {
    background: linear-gradient(135deg, #4CAF50, #2196F3);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stage-title h1 {
    font-size: 28px;
    margin-bottom: 10px;
}

.stage-title p {
    font-size: 16px;
    opacity: 0.9;
}

/* 首页样式 */
.home-content {
    padding: 20px 0;
}

.welcome-section {
    background: linear-gradient(135deg, #4CAF50, #2196F3);
    color: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.welcome-section h1 {
    font-size: 32px;
    margin-bottom: 15px;
}

.welcome-section p {
    font-size: 16px;
    margin-bottom: 20px;
    opacity: 0.9;
}

.stage-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stage-button {
    background-color: #fff;
    border: none;
    border-radius: 12px;
    padding: 25px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stage-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.stage-button h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #333;
}

.stage-button p {
    font-size: 14px;
    color: #666;
}

.featured-formulas {
    margin-top: 40px;
}

.featured-formulas h2 {
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.featured-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

/* 响应式设计 */
@media (max-width: 767px) {
    .container {
        padding: 0 10px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .search-box {
        flex-direction: column;
    }
    
    .formula-list {
        grid-template-columns: 1fr;
    }
    
    .formula-detail .formula-expression {
        font-size: 18px;
    }
    
    .related-list {
        grid-template-columns: 1fr;
    }
    
    .stage-buttons {
        grid-template-columns: 1fr;
    }
    
    .featured-list {
        grid-template-columns: 1fr;
    }
    
    .site-info {
        grid-template-columns: 1fr;
    }
    
    .formula-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .formula-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .error-number {
        font-size: 60px;
    }
    
    .error-title {
        font-size: 20px;
    }
    
    .error-button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    /* 移除flex-direction: column，保持水平排列 */
    .header-content {
        /* 保持flex-direction: row (默认) */
        gap: 10px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .back-button {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .stage-title h1 {
        font-size: 24px;
    }
    
    .welcome-section h1 {
        font-size: 28px;
    }
    
    .error-container {
        padding: 30px 20px;
    }
    
    .bottom-nav {
        padding: 8px 0;
    }
    
    .nav-item i {
        font-size: 18px;
    }
    
    .nav-item span {
        font-size: 11px;
    }
}