/* 全局样式 */
:root {
    --primary-color: #28a745;
    --secondary-color: #6c757d;
    --accent-color: #ffc107;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
    color: #333;
    background-color: #f8f9fa;
    line-height: 1.6;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: #218838;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border-bottom: none;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background-color: rgba(0, 0, 0, 0.03);
    border-top: none;
    padding: 1rem 1.25rem;
}

/* 按钮样式 */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #218838;
    border-color: #1e7e34;
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 轮播图样式 */
.swiper {
    width: 100%;
    height: 350px;
    margin-bottom: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

.swiper-slide {
    text-align: center;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.swiper-slide-content {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    width: 100%;
    padding: 1.5rem;
}

.swiper-slide-content h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.swiper-pagination-bullet-active {
    background-color: var(--primary-color);
}

.swiper-button-next,
.swiper-button-prev {
    color: var(--primary-color);
}

/* 食物卡片样式 */
.food-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.food-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.food-card .card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.food-card .card-text {
    margin-bottom: 1rem;
    flex: 1;
}

.food-card .btn {
    align-self: flex-start;
    margin-top: auto;
}

/* 食物分类样式 */
.food-category {
    margin-bottom: 2rem;
}

.food-category h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.food-category h3 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
}

/* 搜索框样式 */
.search-box {
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
}

.search-box .form-control {
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    border: 1px solid #ced4da;
}

.search-box .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(40, 167, 69, 0.25);
}

.search-box .btn {
    padding: 0.75rem 1rem;
}

/* 搜索标签样式 */
.search-tags {
    margin: 1rem 0;
}

.search-tag {
    display: inline-block;
    background-color: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    transition: var(--transition);
}

.search-tag:hover {
    background-color: var(--primary-color);
    color: white;
}

.search-tag-hot {
    background-color: #ffecb5;
    color: #856404;
}

.search-tag-hot:hover {
    background-color: var(--warning-color);
    color: #212529;
}

/* 详情页样式 */
.nutrition-table th {
    width: 30%;
}

.nutrition-table tbody tr:hover {
    background-color: rgba(40, 167, 69, 0.1);
}

.nutrition-search-box {
    max-width: 300px;
}

.highlight {
    background-color: #ffff00;
    padding: 0.2rem 0.1rem;
    border-radius: 0.2rem;
}

/* 分类标签样式 */
.category-badge {
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    transition: var(--transition);
}

.category-badge:hover {
    background-color: #218838;
    color: white;
}

/* 搜索结果样式 */
.search-result-item {
    border-left: 3px solid var(--primary-color);
    padding: 1rem 1rem 1rem 1.5rem;
    margin-bottom: 1.5rem;
    background-color: white;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.search-result-item:hover {
    border-left-color: #218838;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.search-result-item h4 {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* 浏览记录样式 */
.view-history {
    margin-bottom: 2rem;
}

.view-history-title {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
}

.view-history-item {
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
    transition: var(--transition);
}

.view-history-item:hover {
    background-color: rgba(40, 167, 69, 0.05);
}

.view-history-item:last-child {
    border-bottom: none;
}

.view-count {
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* 返回顶部按钮 */
#back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: none;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    line-height: 3rem;
    z-index: 1000;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

#back-to-top:hover {
    background-color: #218838;
    transform: translateY(-3px);
}

/* 面包屑导航 */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    color: var(--secondary-color);
}

/* 响应式调整 */
@media (max-width: 992px) {
    .swiper {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .swiper {
        height: 250px;
    }
    
    .swiper-slide-content h2 {
        font-size: 1.5rem;
    }
    
    .search-box {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .swiper {
        height: 200px;
    }
    
    .swiper-slide-content h2 {
        font-size: 1.2rem;
    }
    
    .swiper-slide-content p {
        font-size: 0.9rem;
    }
    
    .search-box {
        padding: 0.75rem;
    }
    
    .search-box .form-control,
    .search-box .btn {
        padding: 0.5rem 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* 食物分类移动端优化 */
    .food-category .d-flex {
        gap: 0.5rem;
    }
    
    .food-category h2 {
        font-size: 1.25rem;
        line-height: 1.3;
        word-break: break-word;
        hyphens: auto;
    }
    
    .food-category h2 i {
        font-size: 1rem;
    }
    
    .food-category .btn {
        white-space: nowrap;
        min-width: auto;
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* 确保按钮不会被挤压 */
    .flex-shrink-0 {
        flex-shrink: 0 !important;
    }
    
    /* 标题可以适当收缩但保持可读性 */
    .flex-grow-1 {
        flex-grow: 1 !important;
        min-width: 0; /* 允许文本截断 */
    }
}

/* 超小屏幕优化 */
@media (max-width: 400px) {
    .food-category h2 {
        font-size: 1.1rem;
    }
    
    .food-category .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }
    
    .food-category .btn i {
        font-size: 0.8rem;
    }
}