/**
 * FODMAP饮食助手 - 前台样式表2.0
 * 包含搜索表单、结果展示等所有前台样式
 */

/* ==============================================
   基础样式重置与通用设置
============================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==============================================
   搜索区域样式
============================================== */

/* 搜索容器 - 实现居中效果 */
.fodmap-search-form-wrapper {
    max-width: 800px;
    width: 90%;
    margin: 30px auto;
    text-align: center;
    padding: 0 15px;
}
.fodmap-search-form-wrapper h2 {
    font-size: 28px;
    font-weight: 600;
    color: #3f72af;
    margin-bottom: 15px;
    line-height: 1.3;
}
.fodmap-search-form-wrapper p {
    font-size: 14px;
    color: #666;
    margin-bottom: 30px;
    line-height: 1.6;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}
.fodmap-search-container {
    max-width: 800px;
    width: 90%;
    margin: 30px auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* 搜索表单样式 */
.fodmap-search-form {
    width: 100%;
    margin-bottom: 20px;
}

/* 搜索输入框容器 */
.fodmap-search-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

/* 搜索输入框样式 */
.fodmap-search-field {
    flex: 1;
    padding: 16px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    color: #333;
    background-color: #fff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* 输入框聚焦效果 */
.fodmap-search-field:focus {
    outline: none;
    border-color: #3f72af; /* 主色调：蓝色 */
    box-shadow: 0 0 0 2px rgba(63, 114, 175, 0.2);
}

/* 搜索按钮样式 - 修复颜色问题 */
.fodmap-search-submit {
    padding: 0 24px;
    background-color: #3f72af;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

/* 按钮图标样式 */
.fodmap-search-submit i {
    font-size: 16px;
}

/* 按钮悬停效果 */
.fodmap-search-submit:hover {
    background-color: #36649e;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* 按钮点击效果 */
.fodmap-search-submit:active {
    background-color: #2d558a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 搜索输入时的实时反馈和加载动画 */
.fodmap-search-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.fodmap-search-loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3f72af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 搜索结果计数样式 */
.fodmap-results-count {
    margin: 1.5rem 0;
    color: #555;
    font-size: 16px;
    font-weight: 500;
    background-color: #f8f9fa;
    padding: 10px 16px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

/* 无结果提示样式 */
.fodmap-no-results {
    margin: 2rem 0;
    color: #777;
    text-align: center;
    padding: 3rem;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px dashed #ddd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.fodmap-no-results:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* 热门搜索标签样式 */
.fodmap-hot-tags {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 14px;
    color: #666;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.fodmap-hot-tags span {
    font-weight: 600;
    color: #333;
    margin-right: 5px;
}

.fodmap-hot-tags a {
    padding: 6px 12px;
    background-color: #f8f9fa;
    color: #3f72af;
    text-decoration: none;
    border-radius: 16px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
    font-size: 13px;
}

.fodmap-hot-tags a:hover {
    background-color: #e3f2fd;
    color: #36649e;
    border-color: #3f72af;
    text-decoration: none;
    transform: translateY(-1px);
}

/* 分页样式 */
.fodmap-pagination {
    margin-top: 30px;
    margin-bottom: 20px;
    text-align: center;
}

.fodmap-pagination ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: inline-flex;
    gap: 5px;
}

.fodmap-pagination li {
    margin: 0;
}

.fodmap-pagination a,
.fodmap-pagination span {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    color: #3f72af;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.fodmap-pagination a:hover {
    background-color: #f0f4f8;
    border-color: #3f72af;
}

.fodmap-pagination li.active span {
    background-color: #3f72af;
    color: #fff;
    border-color: #3f72af;
}

.fodmap-pagination li:first-child a,
.fodmap-pagination li:last-child a {
    background-color: #f8f9fa;
}

.fodmap-pagination li:first-child a:hover,
.fodmap-pagination li:last-child a:hover {
    background-color: #e9ecef;
}

/* ==============================================
   搜索结果样式 (对ul和li进行单独定义)
============================================== */

/* 结果容器 */
.fodmap-search-results-wrapper {
    max-width: 800px;
    width: 90%;
    margin: 2rem auto; /* 优化：调整外边距，使其与搜索区间距合理 */
    padding: 0 15px;
}

/* 结果计数文本 */
.fodmap-results-count {
    margin: 1.5rem 0;
    color: #555;
    font-size: 16px;
}

/* 无结果提示 */
.fodmap-no-results {
    margin: 2rem 0;
    color: #777;
    text-align: center;
    padding: 2rem;
    background-color: #f9f9f9;
    border-radius: 8px;
}

/* --- 开始：对ul进行单独定义 --- */
/* 结果列表 - 两列网格布局 */
.fodmap-search-results-wrapper ul.fodmap-search-results {
    list-style: none;
    padding: 0;
    margin: 2rem 0; /* 优化：仅上下外边距 */
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 两列等宽 */
    gap: 20px; /* 项之间的间距 */
}
/* --- 结束：对ul进行单独定义 --- */

/* --- 开始：对li进行单独定义 --- */
/* 单个食品项 - 垂直布局 */
.fodmap-search-results-wrapper li.fodmap-food-item {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%; /* 确保高度一致 */
    border: 1px solid #f0f0f0;
}

/* 食品项悬停效果 */
.fodmap-search-results-wrapper li.fodmap-food-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #e3f2fd;
}
/* --- 结束：对li进行单独定义 --- */

/* 食品图片 */
.fodmap-food-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: transform 0.3s ease;
}

.fodmap-search-results-wrapper li.fodmap-food-item:hover .fodmap-food-image {
    transform: scale(1.02);
}

/* 食品内容区 */
.fodmap-food-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* 食品名称 */
.food-name {
    margin-bottom: 10px;
    font-size: 19px;
    font-weight: 600;
    color: #222;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* FODMAP等级标签 */
.fodmap-level-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.fodmap-level-badge.level-low {
    background-color: #4CAF50; /* 绿色 */
}

.fodmap-level-badge.level-medium {
    background-color: #FFC107; /* 黄色 */
    color: #333; /* 深色文字提高可读性 */
}

.fodmap-level-badge.level-high {
    background-color: #F44336; /* 红色 */
}

.fodmap-search-results-wrapper li.fodmap-food-item:hover .fodmap-level-badge {
    transform: scale(1.05);
}

/* 食品分类 */
.fodmap-category {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
    background-color: #f8f9fa;
    padding: 6px 12px;
    border-radius: 12px;
    display: inline-block;
    border: 1px solid #e9ecef;
}

.fodmap-search-results-wrapper li.fodmap-food-item:hover .fodmap-category {
    background-color: #e3f2fd;
    border-color: #3f72af;
    color: #3f72af;
}

/* ==============================================
   描述展开/折叠功能样式
============================================== */

/* 描述容器 */
.fodmap-description-container {
    position: relative;
}

/* 默认状态：限制高度并显示省略号 */
.fodmap-description {
    color: #444;
    line-height: 1.6;
    font-size: 15px;
    flex-grow: 1;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 最多显示3行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: all 0.3s ease;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* 展开状态：移除高度限制 */
.fodmap-description.expanded {
    -webkit-line-clamp: unset;
    max-height: 1000px;
    background-color: #e3f2fd;
    border-color: #3f72af;
}

/* 展开/折叠按钮 */
.toggle-description-btn {
    background: none;
    border: 1px solid #3f72af;
    color: #3f72af;
    cursor: pointer;
    font-size: 13px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.toggle-description-btn:hover {
    background-color: #3f72af;
    color: white;
}

/* 按钮展开状态的样式 */
.toggle-description-btn.expanded {
    background-color: #3f72af;
    color: white;
}

.toggle-description-btn.expanded i {
    transform: rotate(180deg);
}

/* ==============================================
   响应式适配
============================================== */

/* 在中等屏幕（768px以下）恢复为一行一个 */
@media (max-width: 768px) {
    /* 响应式布局也需要针对 wrapper 内的 ul 进行调整 */
    .fodmap-search-results-wrapper ul.fodmap-search-results {
        grid-template-columns: 1fr; /* 单列布局 */
    }
    
    .fodmap-food-image {
        height: 150px;
    }
}

/* 小屏幕优化（480px以下） */
@media (max-width: 480px) {
    .fodmap-search-form-wrapper {
        margin: 20px auto;
    }
    
    .fodmap-search-form-wrapper h2 {
        font-size: 24px;
    }
    
    .fodmap-search-form-wrapper p {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .fodmap-search-container {
        margin: 20px auto;
        padding: 20px;
    }
    
    .fodmap-search-input-wrapper {
        flex-direction: column;
        gap: 12px;
    }
    
    .fodmap-search-field {
        padding: 14px 16px;
        font-size: 15px;
        width: 100%;
    }
    
    .fodmap-search-submit {
        padding: 14px 20px;
        width: 100%;
    }
    
    /* 小屏幕隐藏按钮文字，只保留图标 */
    .fodmap-search-submit span {
        display: inline;
    }
    
    /* 热门搜索标签调整 */
    .fodmap-hot-tags {
        gap: 8px;
    }
    
    .fodmap-hot-tags a {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    /* 分页调整 */
    .fodmap-pagination ul {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .fodmap-pagination a,
    .fodmap-pagination span {
        padding: 6px 12px;
        font-size: 13px;
    }
}