/* 营养追踪组件样式 */

.nutrition-card {
    background-color: var(--color-bg-secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
    padding: var(--spacing-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.nutrition-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.nutrition-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-text);
}

.link-detail {
    font-size: 0.9rem;
    color: var(--color-primary);
    text-decoration: none;
}

/* 进度条样式 */
.progress-item {
    margin-bottom: var(--spacing-md);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.progress-fill {
    height: 100%;
    border: 2px solid var(--color-primary);
    background-color: var(--color-bg-secondary);
    transition: width 0.3s ease;
    flex-shrink: 0; /* 防止压缩 */
}

/* 第一段进度条：左侧圆角 */
.progress-fill:first-child {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

/* 最后一段进度条：右侧圆角 */
.progress-fill:last-child {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

/* 唯一段进度条：全部圆角 */
.progress-fill:first-child:last-child {
    border-radius: 4px;
}

.progress-fill.protein {
    border-color: var(--color-success);
}

.progress-fill.calories {
    border-color: var(--color-warning);
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.progress-fill.over-goal {
    border-color: var(--color-danger);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.progress-fill.calories.over-goal {
    border-left: 0;
}

/* 蛋白质进度条超支时使用 warning 颜色 */
.progress-fill.protein.over-goal {
    border-color: var(--color-warning);
    border-left: 0;
}

/* 进度条分隔线（100%标记） */
.progress-fill.with-divider {
    position: relative;
    border-right-color: transparent;
}

.progress-fill.with-divider::after {
    content: '';
    position: absolute;
    right: -2px;
    top: -6px;
    height: calc(100% + 12px);
    width: 2px;
    background-color: var(--color-text-tertiary);
}

/* 蛋白质进度条的分隔线颜色（绿色） */
.progress-fill.protein.with-divider::after {
    background-color: var(--color-warning);
}

/* 热量进度条的分隔线颜色（橙色） */
.progress-fill.calories.with-divider::after {
    background-color: var(--color-warning);
}

/* 热量进度条超标时的分隔线颜色（红色） */
.progress-fill.calories.over-goal-divider.with-divider::after {
    background-color: var(--color-danger);
}

/* 热量进度条底层背景样式 */
.progress-bg {
    position: absolute;
    height: 100%;
    z-index: 1;
}

.progress-bg.base-calories {
    border: 2px solid var(--color-primary);
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

/* base-calories 是唯一背景时，添加右侧圆角 */
.progress-bg.base-calories.only-bg {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.progress-bg.exercise-calories {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    border: 2px solid var(--color-success);
    border-left: 0;
}

.progress-bg.exercise-calories.no-right-radius {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* 预设食物网格 */
.preset-foods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.preset-food-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs);
    background-color: var(--color-bg-secondary);
    border: 1px solid var(--color-border-light);
    flex-shrink: 0;
    min-width: fit-content;
    width: auto;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

@media (hover: hover) and (pointer: fine) {
    .preset-food-btn:hover:not(.voice-btn):not(.recording) {
        transform: translateY(-1px);
        box-shadow: var(--shadow-sm);
    }
}

.preset-food-btn:active {
    transform: translateY(0);
}

.preset-food-btn .food-icon {
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
}

.preset-food-btn .category-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* 预设食物计数徽章 */
.preset-food-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    color: var(--color-primary);
    font-size: 0.55rem;
    font-weight: 600;
    padding: 2px 5px;
    min-width: 15px;
    text-align: center;
    line-height: 1.2;

}

.preset-food-btn {
    position: relative;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .preset-foods-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: var(--spacing-xs);
    }
}
